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:
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
|
|
||||||
MusePackDecoder::MusePackDecoder()
|
MusePackDecoder::MusePackDecoder()
|
||||||
|
:
|
||||||
|
fDecoder(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +28,8 @@ MusePackDecoder::Setup(media_format *ioEncodedFormat, const void *infoBuffer, in
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
fDecoder = (MPC_decoder *)infoBuffer;
|
fDecoder = (MPC_decoder *)infoBuffer;
|
||||||
|
fFrameRate = fDecoder->fInfo->simple.SampleFreq;
|
||||||
|
fStartTime = 0;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +40,7 @@ MusePackDecoder::NegotiateOutputFormat(media_format *format)
|
|||||||
// ToDo: rework the underlying MPC engine to be more flexible
|
// ToDo: rework the underlying MPC engine to be more flexible
|
||||||
|
|
||||||
format->type = B_MEDIA_RAW_AUDIO;
|
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.channel_count = fDecoder->fInfo->simple.Channels;
|
||||||
format->u.raw_audio.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
format->u.raw_audio.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||||
format->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN;
|
format->u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN;
|
||||||
@@ -55,6 +59,7 @@ MusePackDecoder::NegotiateOutputFormat(media_format *format)
|
|||||||
status_t
|
status_t
|
||||||
MusePackDecoder::Seek(uint32 seekTo, int64 seekFrame, int64 *frame, bigtime_t seekTime, bigtime_t *time)
|
MusePackDecoder::Seek(uint32 seekTo, int64 seekFrame, int64 *frame, bigtime_t seekTime, bigtime_t *time)
|
||||||
{
|
{
|
||||||
|
fStartTime = 0;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +69,15 @@ MusePackDecoder::Decode(void *buffer, int64 *_frameCount, media_header *mediaHea
|
|||||||
{
|
{
|
||||||
// ToDo: add error checking (check for broken frames)
|
// ToDo: add error checking (check for broken frames)
|
||||||
|
|
||||||
|
mediaHeader->start_time = fStartTime;
|
||||||
|
|
||||||
uint32 ring = fDecoder->Zaehler;
|
uint32 ring = fDecoder->Zaehler;
|
||||||
*_frameCount = fDecoder->DECODE((MPC_SAMPLE_FORMAT *)buffer);
|
off_t frameCount = fDecoder->DECODE((MPC_SAMPLE_FORMAT *)buffer);
|
||||||
fDecoder->UpdateBuffer(ring);
|
fDecoder->UpdateBuffer(ring);
|
||||||
|
|
||||||
|
fStartTime += bigtime_t(1000.0 * frameCount * FRAMELEN / (fFrameRate / 1000) + 0.5);
|
||||||
|
*_frameCount = frameCount;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class MusePackDecoder : public Decoder {
|
|||||||
private:
|
private:
|
||||||
MPC_decoder *fDecoder;
|
MPC_decoder *fDecoder;
|
||||||
StreamInfo *fInfo;
|
StreamInfo *fInfo;
|
||||||
|
float fFrameRate;
|
||||||
|
off_t fStartTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MUSEPACK_DECODER_H */
|
#endif /* MUSEPACK_DECODER_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user