mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 21:45:33 +00:00
Add a rewind method to the sound decoder
This commit is contained in:
parent
afa2cb6de7
commit
db46bf39b3
6 changed files with 29 additions and 1 deletions
|
@ -29,6 +29,10 @@ size_t FFmpeg_Decoder::read(char *buffer, size_t bytes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void FFmpeg_Decoder::rewind()
|
||||
{
|
||||
fail("Not currently working");
|
||||
}
|
||||
|
||||
FFmpeg_Decoder::FFmpeg_Decoder()
|
||||
{
|
||||
|
|
|
@ -20,7 +20,9 @@ namespace MWSound
|
|||
virtual void close();
|
||||
|
||||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes);
|
||||
virtual void rewind();
|
||||
|
||||
FFmpeg_Decoder();
|
||||
virtual ~FFmpeg_Decoder();
|
||||
|
|
|
@ -109,6 +109,23 @@ size_t MpgSnd_Decoder::read(char *buffer, size_t bytes)
|
|||
return got;
|
||||
}
|
||||
|
||||
void MpgSnd_Decoder::rewind()
|
||||
{
|
||||
if(!mSndFile && !mMpgFile)
|
||||
fail("No open file");
|
||||
|
||||
if(mSndFile)
|
||||
{
|
||||
if(sf_seek(mSndFile, 0, SEEK_SET) == -1)
|
||||
fail("seek failed");
|
||||
}
|
||||
else if(mMpgFile)
|
||||
{
|
||||
if(mpg123_seek(mMpgFile, 0, SEEK_SET) < 0)
|
||||
fail("seek failed");
|
||||
}
|
||||
}
|
||||
|
||||
MpgSnd_Decoder::MpgSnd_Decoder() : mSndFile(NULL), mMpgFile(NULL)
|
||||
{
|
||||
static bool initdone = false;
|
||||
|
|
|
@ -23,7 +23,9 @@ namespace MWSound
|
|||
virtual void close();
|
||||
|
||||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes);
|
||||
virtual void rewind();
|
||||
|
||||
MpgSnd_Decoder();
|
||||
public:
|
||||
|
|
|
@ -225,7 +225,8 @@ void OpenAL_SoundStream::stop()
|
|||
alSourceStop(mSource);
|
||||
alSourcei(mSource, AL_BUFFER, 0);
|
||||
throwALerror();
|
||||
// FIXME: Rewind decoder
|
||||
|
||||
mDecoder->rewind();
|
||||
}
|
||||
|
||||
bool OpenAL_SoundStream::isPlaying()
|
||||
|
|
|
@ -27,7 +27,9 @@ namespace MWSound
|
|||
virtual void close() = 0;
|
||||
|
||||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes) = 0;
|
||||
virtual void rewind() = 0;
|
||||
|
||||
virtual ~Sound_Decoder() { }
|
||||
|
||||
|
|
Loading…
Reference in a new issue