diff --git a/src/add-ons/media/plugins/musepack/MusePackDecoder.cpp b/src/add-ons/media/plugins/musepack/MusePackDecoder.cpp index 220a30bf3b..7c0b35dd7f 100644 --- a/src/add-ons/media/plugins/musepack/MusePackDecoder.cpp +++ b/src/add-ons/media/plugins/musepack/MusePackDecoder.cpp @@ -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; } diff --git a/src/add-ons/media/plugins/musepack/MusePackDecoder.h b/src/add-ons/media/plugins/musepack/MusePackDecoder.h index 3fad36e467..eb8141e012 100644 --- a/src/add-ons/media/plugins/musepack/MusePackDecoder.h +++ b/src/add-ons/media/plugins/musepack/MusePackDecoder.h @@ -31,6 +31,8 @@ class MusePackDecoder : public Decoder { private: MPC_decoder *fDecoder; StreamInfo *fInfo; + float fFrameRate; + off_t fStartTime; }; #endif /* MUSEPACK_DECODER_H */