new and improved start time for better sync���!
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6628 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
eaa176da6c
commit
73da0c41c1
@ -51,7 +51,6 @@ SpeexDecoder::SpeexDecoder()
|
||||
fHeader = 0;
|
||||
fStereoState = 0;
|
||||
fSpeexOutputLength = 0;
|
||||
fStartTime = 0;
|
||||
fFrameSize = 0;
|
||||
fOutputBufferSize = 0;
|
||||
}
|
||||
@ -250,9 +249,8 @@ SpeexDecoder::Decode(void *buffer, int64 *frameCount,
|
||||
float * out_buffer = static_cast<float *>(buffer);
|
||||
int32 out_bytes_needed = fOutputBufferSize;
|
||||
|
||||
mediaHeader->start_time = fStartTime;
|
||||
//TRACE("SpeexDecoder: Decoding start time %.6f\n", fStartTime / 1000000.0);
|
||||
|
||||
bool start = false;
|
||||
|
||||
while (out_bytes_needed >= fSpeexOutputLength) {
|
||||
// get a new packet
|
||||
void *chunkBuffer;
|
||||
@ -266,7 +264,10 @@ SpeexDecoder::Decode(void *buffer, int64 *frameCount,
|
||||
TRACE("SpeexDecoder::Decode: GetNextChunk failed\n");
|
||||
return status;
|
||||
}
|
||||
fStartTime = mh.start_time;
|
||||
if (!start) {
|
||||
mediaHeader->start_time = mh.start_time;
|
||||
start = true;
|
||||
}
|
||||
speex_bits_read_from(&fBits, (char*)chunkBuffer, chunkSize);
|
||||
for (int frame = 0 ; frame < fHeader->frames_per_packet ; frame++) {
|
||||
int ret = speex_decode(fDecoderState, &fBits, out_buffer);
|
||||
@ -293,9 +294,6 @@ SpeexDecoder::Decode(void *buffer, int64 *frameCount,
|
||||
}
|
||||
|
||||
done:
|
||||
uint samples = ((uint8*)out_buffer - (uint8*)buffer) / fFrameSize;
|
||||
//fStartTime += (1000000LL * samples) / fHeader->rate;
|
||||
//TRACE("SpeexDecoder: fStartTime inc'd to %.6f\n", fStartTime / 1000000.0);
|
||||
*frameCount = (fOutputBufferSize - out_bytes_needed) / fFrameSize;
|
||||
|
||||
if (out_buffer != buffer) {
|
||||
|
@ -47,7 +47,6 @@ VorbisDecoder::VorbisDecoder()
|
||||
vorbis_info_init(&fInfo);
|
||||
vorbis_comment_init(&fComment);
|
||||
|
||||
fStartTime = 0;
|
||||
fFrameSize = 0;
|
||||
fOutputBufferSize = 0;
|
||||
}
|
||||
@ -170,9 +169,8 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
||||
// TRACE("VorbisDecoder::Decode\n");
|
||||
uint8 * out_buffer = static_cast<uint8 *>(buffer);
|
||||
int32 out_bytes_needed = fOutputBufferSize;
|
||||
|
||||
mediaHeader->start_time = fStartTime;
|
||||
//TRACE("VorbisDecoder: Decoding start time %.6f\n", fStartTime / 1000000.0);
|
||||
|
||||
bool start = false;
|
||||
|
||||
while (out_bytes_needed > 0) {
|
||||
int samples;
|
||||
@ -194,7 +192,10 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
||||
TRACE("VorbisDecoder::Decode: chunk not ogg_packet-sized\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
fStartTime = mh.start_time;
|
||||
if (!start) {
|
||||
mediaHeader->start_time = mh.start_time;
|
||||
start = true;
|
||||
}
|
||||
ogg_packet * packet = static_cast<ogg_packet*>(chunkBuffer);
|
||||
if (vorbis_synthesis(&fBlock,packet)==0) {
|
||||
vorbis_synthesis_blockin(&fDspState,&fBlock);
|
||||
@ -227,8 +228,6 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
||||
// report back how many samples we consumed
|
||||
vorbis_synthesis_read(&fDspState,samples);
|
||||
|
||||
//fStartTime += (1000000LL * samples) / fInfo.rate;
|
||||
//TRACE("VorbisDecoder: fStartTime inc'd to %.6f\n", fStartTime / 1000000.0);
|
||||
}
|
||||
|
||||
done:
|
||||
|
@ -30,7 +30,6 @@ private:
|
||||
vorbis_comment fComment;
|
||||
vorbis_dsp_state fDspState;
|
||||
vorbis_block fBlock;
|
||||
bigtime_t fStartTime;
|
||||
int fFrameSize;
|
||||
int fOutputBufferSize;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user