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;
|
fHeader = 0;
|
||||||
fStereoState = 0;
|
fStereoState = 0;
|
||||||
fSpeexOutputLength = 0;
|
fSpeexOutputLength = 0;
|
||||||
fStartTime = 0;
|
|
||||||
fFrameSize = 0;
|
fFrameSize = 0;
|
||||||
fOutputBufferSize = 0;
|
fOutputBufferSize = 0;
|
||||||
}
|
}
|
||||||
@ -250,8 +249,7 @@ SpeexDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
float * out_buffer = static_cast<float *>(buffer);
|
float * out_buffer = static_cast<float *>(buffer);
|
||||||
int32 out_bytes_needed = fOutputBufferSize;
|
int32 out_bytes_needed = fOutputBufferSize;
|
||||||
|
|
||||||
mediaHeader->start_time = fStartTime;
|
bool start = false;
|
||||||
//TRACE("SpeexDecoder: Decoding start time %.6f\n", fStartTime / 1000000.0);
|
|
||||||
|
|
||||||
while (out_bytes_needed >= fSpeexOutputLength) {
|
while (out_bytes_needed >= fSpeexOutputLength) {
|
||||||
// get a new packet
|
// get a new packet
|
||||||
@ -266,7 +264,10 @@ SpeexDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
TRACE("SpeexDecoder::Decode: GetNextChunk failed\n");
|
TRACE("SpeexDecoder::Decode: GetNextChunk failed\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
fStartTime = mh.start_time;
|
if (!start) {
|
||||||
|
mediaHeader->start_time = mh.start_time;
|
||||||
|
start = true;
|
||||||
|
}
|
||||||
speex_bits_read_from(&fBits, (char*)chunkBuffer, chunkSize);
|
speex_bits_read_from(&fBits, (char*)chunkBuffer, chunkSize);
|
||||||
for (int frame = 0 ; frame < fHeader->frames_per_packet ; frame++) {
|
for (int frame = 0 ; frame < fHeader->frames_per_packet ; frame++) {
|
||||||
int ret = speex_decode(fDecoderState, &fBits, out_buffer);
|
int ret = speex_decode(fDecoderState, &fBits, out_buffer);
|
||||||
@ -293,9 +294,6 @@ SpeexDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
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;
|
*frameCount = (fOutputBufferSize - out_bytes_needed) / fFrameSize;
|
||||||
|
|
||||||
if (out_buffer != buffer) {
|
if (out_buffer != buffer) {
|
||||||
|
@ -47,7 +47,6 @@ VorbisDecoder::VorbisDecoder()
|
|||||||
vorbis_info_init(&fInfo);
|
vorbis_info_init(&fInfo);
|
||||||
vorbis_comment_init(&fComment);
|
vorbis_comment_init(&fComment);
|
||||||
|
|
||||||
fStartTime = 0;
|
|
||||||
fFrameSize = 0;
|
fFrameSize = 0;
|
||||||
fOutputBufferSize = 0;
|
fOutputBufferSize = 0;
|
||||||
}
|
}
|
||||||
@ -171,8 +170,7 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
uint8 * out_buffer = static_cast<uint8 *>(buffer);
|
uint8 * out_buffer = static_cast<uint8 *>(buffer);
|
||||||
int32 out_bytes_needed = fOutputBufferSize;
|
int32 out_bytes_needed = fOutputBufferSize;
|
||||||
|
|
||||||
mediaHeader->start_time = fStartTime;
|
bool start = false;
|
||||||
//TRACE("VorbisDecoder: Decoding start time %.6f\n", fStartTime / 1000000.0);
|
|
||||||
|
|
||||||
while (out_bytes_needed > 0) {
|
while (out_bytes_needed > 0) {
|
||||||
int samples;
|
int samples;
|
||||||
@ -194,7 +192,10 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
TRACE("VorbisDecoder::Decode: chunk not ogg_packet-sized\n");
|
TRACE("VorbisDecoder::Decode: chunk not ogg_packet-sized\n");
|
||||||
return B_ERROR;
|
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);
|
ogg_packet * packet = static_cast<ogg_packet*>(chunkBuffer);
|
||||||
if (vorbis_synthesis(&fBlock,packet)==0) {
|
if (vorbis_synthesis(&fBlock,packet)==0) {
|
||||||
vorbis_synthesis_blockin(&fDspState,&fBlock);
|
vorbis_synthesis_blockin(&fDspState,&fBlock);
|
||||||
@ -227,8 +228,6 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
// report back how many samples we consumed
|
// report back how many samples we consumed
|
||||||
vorbis_synthesis_read(&fDspState,samples);
|
vorbis_synthesis_read(&fDspState,samples);
|
||||||
|
|
||||||
//fStartTime += (1000000LL * samples) / fInfo.rate;
|
|
||||||
//TRACE("VorbisDecoder: fStartTime inc'd to %.6f\n", fStartTime / 1000000.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -30,7 +30,6 @@ private:
|
|||||||
vorbis_comment fComment;
|
vorbis_comment fComment;
|
||||||
vorbis_dsp_state fDspState;
|
vorbis_dsp_state fDspState;
|
||||||
vorbis_block fBlock;
|
vorbis_block fBlock;
|
||||||
bigtime_t fStartTime;
|
|
||||||
int fFrameSize;
|
int fFrameSize;
|
||||||
int fOutputBufferSize;
|
int fOutputBufferSize;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user