mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
dvdemux: don't screw up first audio buffer
Query the audio format, esp. dvdemux->num_channels, before we use that variable to allocate the initial buffer. That way we don't accidentally push a zero-sized buffer as first audio buffer.
This commit is contained in:
parent
6c6e96becd
commit
42936a73e6
1 changed files with 21 additions and 21 deletions
|
@ -1235,30 +1235,10 @@ gst_dvdemux_demux_audio (GstDVDemux * dvdemux, GstBuffer * buffer,
|
|||
GstBuffer *outbuf;
|
||||
gint frequency, channels;
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (num_samples *
|
||||
sizeof (gint16) * dvdemux->channels);
|
||||
|
||||
a_ptr = (gint16 *) GST_BUFFER_DATA (outbuf);
|
||||
|
||||
for (i = 0; i < num_samples; i++) {
|
||||
for (j = 0; j < dvdemux->channels; j++) {
|
||||
*(a_ptr++) = dvdemux->audio_buffers[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
GST_DEBUG ("pushing audio %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (dvdemux->time_segment.last_stop));
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = dvdemux->time_segment.last_stop;
|
||||
GST_BUFFER_DURATION (outbuf) = duration;
|
||||
GST_BUFFER_OFFSET (outbuf) = dvdemux->audio_offset;
|
||||
dvdemux->audio_offset += num_samples;
|
||||
GST_BUFFER_OFFSET_END (outbuf) = dvdemux->audio_offset;
|
||||
|
||||
if (!dvdemux->audiosrcpad)
|
||||
gst_dvdemux_add_audio_pad (dvdemux);
|
||||
|
||||
/* check if format changed */
|
||||
/* get initial format or check if format changed */
|
||||
frequency = dv_get_frequency (dvdemux->decoder);
|
||||
channels = dv_get_num_channels (dvdemux->decoder);
|
||||
|
||||
|
@ -1280,6 +1260,26 @@ gst_dvdemux_demux_audio (GstDVDemux * dvdemux, GstBuffer * buffer,
|
|||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (num_samples *
|
||||
sizeof (gint16) * dvdemux->channels);
|
||||
|
||||
a_ptr = (gint16 *) GST_BUFFER_DATA (outbuf);
|
||||
|
||||
for (i = 0; i < num_samples; i++) {
|
||||
for (j = 0; j < dvdemux->channels; j++) {
|
||||
*(a_ptr++) = dvdemux->audio_buffers[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
GST_DEBUG ("pushing audio %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (dvdemux->time_segment.last_stop));
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = dvdemux->time_segment.last_stop;
|
||||
GST_BUFFER_DURATION (outbuf) = duration;
|
||||
GST_BUFFER_OFFSET (outbuf) = dvdemux->audio_offset;
|
||||
dvdemux->audio_offset += num_samples;
|
||||
GST_BUFFER_OFFSET_END (outbuf) = dvdemux->audio_offset;
|
||||
|
||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (dvdemux->audiosrcpad));
|
||||
|
||||
ret = gst_pad_push (dvdemux->audiosrcpad, outbuf);
|
||||
|
|
Loading…
Reference in a new issue