Now sets the mediaHeader->start_time in Decode() (hopefully correct).

Also fixed a crashing bug if the decoder was not setup with data from
the MusePackReader.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6172 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-01-20 01:06:43 +00:00
parent d179491229
commit 09d31e11ec
2 changed files with 14 additions and 2 deletions
@@ -9,6 +9,8 @@
MusePackDecoder::MusePackDecoder()
:
fDecoder(NULL)
{
}
@@ -26,6 +28,8 @@ MusePackDecoder::Setup(media_format *ioEncodedFormat, const void *infoBuffer, in
return B_BAD_VALUE;
fDecoder = (MPC_decoder *)infoBuffer;
fFrameRate = fDecoder->fInfo->simple.SampleFreq;
fStartTime = 0;
return B_OK;
}
@@ -36,7 +40,7 @@ MusePackDecoder::NegotiateOutputFormat(media_format *format)
// ToDo: rework the underlying MPC engine to be more flexible
format->type = B_MEDIA_RAW_AUDIO;
format->u.raw_audio.frame_rate = fDecoder->fInfo->simple.SampleFreq;
format->u.raw_audio.frame_rate = fFrameRate;
format->u.raw_audio.channel_count = fDecoder->fInfo->simple.Channels;
format->u.raw_audio.format = media_raw_audio_format::B_AUDIO_FLOAT;
format->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN;
@@ -55,6 +59,7 @@ MusePackDecoder::NegotiateOutputFormat(media_format *format)
status_t
MusePackDecoder::Seek(uint32 seekTo, int64 seekFrame, int64 *frame, bigtime_t seekTime, bigtime_t *time)
{
fStartTime = 0;
return B_OK;
}
@@ -64,10 +69,15 @@ MusePackDecoder::Decode(void *buffer, int64 *_frameCount, media_header *mediaHea
{
// ToDo: add error checking (check for broken frames)
mediaHeader->start_time = fStartTime;
uint32 ring = fDecoder->Zaehler;
*_frameCount = fDecoder->DECODE((MPC_SAMPLE_FORMAT *)buffer);
off_t frameCount = fDecoder->DECODE((MPC_SAMPLE_FORMAT *)buffer);
fDecoder->UpdateBuffer(ring);
fStartTime += bigtime_t(1000.0 * frameCount * FRAMELEN / (fFrameRate / 1000) + 0.5);
*_frameCount = frameCount;
return B_OK;
}
@@ -31,6 +31,8 @@ class MusePackDecoder : public Decoder {
private:
MPC_decoder *fDecoder;
StreamInfo *fInfo;
float fFrameRate;
off_t fStartTime;
};
#endif /* MUSEPACK_DECODER_H */