summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThibaut Mattern <thibaut.mattern@gmail.com>2008-01-09 23:50:53 +0100
committerThibaut Mattern <thibaut.mattern@gmail.com>2008-01-09 23:50:53 +0100
commitfae005057d84a7dec9828568f63fb3e3777d3546 (patch)
treef1bdbba0abe6116f68df3a4cb1a98fc25091a82b /src
parent5d789eac0040b27fd8069be3cdc574a8477f0d51 (diff)
downloadxine-lib-fae005057d84a7dec9828568f63fb3e3777d3546.tar.gz
xine-lib-fae005057d84a7dec9828568f63fb3e3777d3546.tar.bz2
Added padding delay to the first and the last frame.
Output 8 zero-bytes at the end of the stream to flush the decoder.
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_mpgaudio.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index f4fb8fefa..17916f837 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -555,7 +555,22 @@ static int parse_frame_payload(demux_mpgaudio_t *this,
buf->content = buf->mem;
buf->type = BUF_AUDIO_MPEG;
buf->decoder_info[0] = 1;
- buf->decoder_flags = decoder_flags|BUF_FLAG_FRAME_END;
+ buf->decoder_flags = decoder_flags | BUF_FLAG_FRAME_END;
+
+ /* send encoder padding */
+ if (this->xing_header) {
+ if (frame_pos == this->mpg_frame_start) {
+ lprintf("sending a start padding of %d samples.\n", this->xing_header->start_delay);
+ buf->decoder_flags = buf->decoder_flags | BUF_FLAG_AUDIO_PADDING;
+ buf->decoder_info[1] = this->xing_header->start_delay;
+ buf->decoder_info[2] = 0;
+ } else if ((frame_pos + this->cur_frame.size) == this->mpg_frame_end) {
+ lprintf("sending a end padding of %d samples.\n", this->xing_header->end_delay);
+ buf->decoder_flags = buf->decoder_flags | BUF_FLAG_AUDIO_PADDING;
+ buf->decoder_info[1] = 0;
+ buf->decoder_info[2] = this->xing_header->end_delay;
+ }
+ }
this->audio_fifo->put(this->audio_fifo, buf);
lprintf("send buffer: pts=%"PRId64"\n", pts);
@@ -678,9 +693,18 @@ static int demux_mpgaudio_send_chunk (demux_plugin_t *this_gen) {
demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
- if (!demux_mpgaudio_next (this, 0, 0))
- this->status = DEMUX_FINISHED;
+ if (!demux_mpgaudio_next (this, 0, 0)) {
+ /* Hack: send 8 zero bytes to flush the libmad decoder */
+ buf_element_t *buf;
+ buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo);
+ buf->type = BUF_AUDIO_MPEG;
+ buf->decoder_flags = BUF_FLAG_FRAME_END;
+ buf->size = 8;
+ memset(buf->content, 0, buf->size);
+ this->audio_fifo->put(this->audio_fifo, buf);
+ this->status = DEMUX_FINISHED;
+ }
return this->status;
}