mirror of
https://github.com/rwengine/openrw.git
synced 2024-10-05 16:47:19 +02:00
47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
#pragma once
|
|
#ifndef _MADSTREAM_HPP_
|
|
#define _MADSTREAM_HPP_
|
|
#include <mad.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/mman.h>
|
|
#include <fcntl.h>
|
|
#include <SFML/Audio.hpp>
|
|
#include <stdint.h>
|
|
#include <iostream>
|
|
#include <rw/defines.hpp>
|
|
|
|
|
|
#include <vector>
|
|
|
|
class MADStream : public sf::SoundStream
|
|
{
|
|
mad_decoder mDecoder;
|
|
unsigned int mMadSampleRate;
|
|
unsigned int mMadChannels;
|
|
unsigned char* mFdm;
|
|
struct stat mStat;
|
|
unsigned int mReadProgress;
|
|
std::vector<int16_t> mCurrentSamples;
|
|
|
|
static inline signed int scale(mad_fixed_t sample);
|
|
static mad_flow ms_header(void* user, mad_header const* header);
|
|
static mad_flow ms_input(void* user, mad_stream* stream);
|
|
static mad_flow ms_output(void* user, mad_header const* header, mad_pcm* pcm);
|
|
static mad_flow ms_error(void* user, mad_stream* stream, mad_frame* frame);
|
|
|
|
virtual bool onGetData(sf::SoundStream::Chunk& data);
|
|
|
|
virtual void onSeek(sf::Time timeOffset);
|
|
|
|
public:
|
|
|
|
MADStream();
|
|
~MADStream();
|
|
|
|
bool openFromFile(const std::string& loc);
|
|
};
|
|
|
|
#endif
|