mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
make flacdec work with unconnected src pad
Original commit message from CVS: make flacdec work with unconnected src pad
This commit is contained in:
parent
38eadd4b76
commit
055ee4d5cc
1 changed files with 47 additions and 39 deletions
|
@ -428,25 +428,30 @@ gst_flacdec_write (const FLAC__SeekableStreamDecoder *decoder,
|
|||
GstEvent *discont;
|
||||
|
||||
flacdec->need_discont = FALSE;
|
||||
|
||||
|
||||
|
||||
|
||||
if (!GST_PAD_CAPS (flacdec->srcpad)) {
|
||||
if (flacdec->seek_pending) {
|
||||
flacdec->total_samples = flacdec->seek_value;
|
||||
}
|
||||
|
||||
GST_DEBUG (0, "send discont");
|
||||
if (GST_PAD_IS_USABLE (flacdec->srcpad)) {
|
||||
GST_DEBUG (0, "send discont");
|
||||
|
||||
format = GST_FORMAT_TIME;
|
||||
gst_pad_convert (flacdec->srcpad, GST_FORMAT_DEFAULT, flacdec->total_samples,
|
||||
&format, &time);
|
||||
format = GST_FORMAT_BYTES;
|
||||
gst_pad_convert (flacdec->srcpad, GST_FORMAT_DEFAULT, flacdec->total_samples,
|
||||
&format, &bytes);
|
||||
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
|
||||
GST_FORMAT_BYTES, bytes,
|
||||
GST_FORMAT_DEFAULT, flacdec->total_samples,
|
||||
format = GST_FORMAT_TIME;
|
||||
gst_pad_convert (flacdec->srcpad, GST_FORMAT_DEFAULT,
|
||||
flacdec->total_samples, &format, &time);
|
||||
format = GST_FORMAT_BYTES;
|
||||
gst_pad_convert (flacdec->srcpad, GST_FORMAT_DEFAULT,
|
||||
flacdec->total_samples, &format, &bytes);
|
||||
discont = gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME, time,
|
||||
GST_FORMAT_BYTES, bytes,
|
||||
GST_FORMAT_DEFAULT, flacdec->total_samples,
|
||||
NULL);
|
||||
|
||||
gst_pad_push (flacdec->srcpad, GST_BUFFER (discont));
|
||||
gst_pad_push (flacdec->srcpad, GST_BUFFER (discont));
|
||||
}
|
||||
}
|
||||
|
||||
if (!GST_PAD_CAPS (flacdec->srcpad)) {
|
||||
|
@ -469,38 +474,38 @@ gst_flacdec_write (const FLAC__SeekableStreamDecoder *decoder,
|
|||
flacdec->frequency = frame->header.sample_rate;
|
||||
}
|
||||
|
||||
outbuf = gst_buffer_new ();
|
||||
GST_BUFFER_SIZE (outbuf) = samples * channels * ((depth+7)>>3);
|
||||
GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = flacdec->total_samples * GST_SECOND / frame->header.sample_rate;
|
||||
|
||||
if (depth == 8) {
|
||||
guint8 *outbuffer = (guint8 *)GST_BUFFER_DATA (outbuf);
|
||||
|
||||
for (i=0; i<samples; i++) {
|
||||
for (j=0; j < channels; j++) {
|
||||
*outbuffer++ = (guint8) buffer[j][i];
|
||||
if (GST_PAD_IS_USABLE (flacdec->srcpad)) {
|
||||
outbuf = gst_buffer_new ();
|
||||
GST_BUFFER_SIZE (outbuf) = samples * channels * ((depth+7)>>3);
|
||||
GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = flacdec->total_samples * GST_SECOND / frame->header.sample_rate;
|
||||
|
||||
if (depth == 8) {
|
||||
guint8 *outbuffer = (guint8 *)GST_BUFFER_DATA (outbuf);
|
||||
|
||||
for (i=0; i<samples; i++) {
|
||||
for (j=0; j < channels; j++) {
|
||||
*outbuffer++ = (guint8) buffer[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (depth == 16) {
|
||||
guint16 *outbuffer = (guint16 *)GST_BUFFER_DATA (outbuf);
|
||||
|
||||
for (i=0; i<samples; i++) {
|
||||
for (j=0; j < channels; j++) {
|
||||
*outbuffer++ = (guint16) buffer[j][i];
|
||||
else if (depth == 16) {
|
||||
guint16 *outbuffer = (guint16 *)GST_BUFFER_DATA (outbuf);
|
||||
|
||||
for (i=0; i<samples; i++) {
|
||||
for (j=0; j < channels; j++) {
|
||||
*outbuffer++ = (guint16) buffer[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
g_warning ("flacdec: invalid depth %d found\n", depth);
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
gst_pad_push (flacdec->srcpad, outbuf);
|
||||
}
|
||||
else {
|
||||
g_warning ("flacdec: invalid depth %d found\n", depth);
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
|
||||
flacdec->total_samples += samples;
|
||||
|
||||
gst_pad_push (flacdec->srcpad, outbuf);
|
||||
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -548,8 +553,10 @@ gst_flacdec_loop (GstElement *element)
|
|||
FLAC__seekable_stream_decoder_finish(flacdec->decoder);
|
||||
flacdec->init = TRUE;
|
||||
|
||||
event = gst_event_new (GST_EVENT_EOS);
|
||||
gst_pad_push (flacdec->srcpad, GST_BUFFER (event));
|
||||
if (GST_PAD_IS_USABLE (flacdec->srcpad)) {
|
||||
event = gst_event_new (GST_EVENT_EOS);
|
||||
gst_pad_push (flacdec->srcpad, GST_BUFFER (event));
|
||||
}
|
||||
gst_element_set_eos (element);
|
||||
}
|
||||
GST_DEBUG (GST_CAT_PLUGIN_INFO, "flacdec: _loop end");
|
||||
|
@ -764,3 +771,4 @@ gst_flacdec_get_property (GObject *object, guint prop_id,
|
|||
g_warning ("Unknown property id\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue