mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
- Add error reporting
Original commit message from CVS: - Add error reporting - never return a NULL buffer
This commit is contained in:
parent
0eb4d2208e
commit
ae07474bb2
1 changed files with 14 additions and 3 deletions
|
@ -25,7 +25,9 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/soundcard.h>
|
#include <sys/soundcard.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <gstosssrc.h>
|
#include <gstosssrc.h>
|
||||||
#include <gstosscommon.h>
|
#include <gstosscommon.h>
|
||||||
|
@ -258,22 +260,31 @@ gst_osssrc_get (GstPad *pad)
|
||||||
|
|
||||||
readbytes = read (src->common.fd,GST_BUFFER_DATA (buf),
|
readbytes = read (src->common.fd,GST_BUFFER_DATA (buf),
|
||||||
src->buffersize);
|
src->buffersize);
|
||||||
|
if (readbytes < 0) {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
gst_element_error (GST_ELEMENT (src), "error reading data (%s)",
|
||||||
|
strerror (errno));
|
||||||
|
return GST_BUFFER (gst_event_new (GST_EVENT_INTERRUPT));
|
||||||
|
}
|
||||||
|
|
||||||
if (readbytes == 0) {
|
if (readbytes == 0) {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
gst_element_set_eos (GST_ELEMENT (src));
|
gst_element_set_eos (GST_ELEMENT (src));
|
||||||
return NULL;
|
return GST_BUFFER (gst_event_new (GST_EVENT_INTERRUPT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GST_PAD_CAPS (pad)) {
|
if (!GST_PAD_CAPS (pad)) {
|
||||||
/* nothing was negotiated, we can decide on a format */
|
/* nothing was negotiated, we can decide on a format */
|
||||||
if (!gst_osssrc_negotiate (pad)) {
|
if (!gst_osssrc_negotiate (pad)) {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
gst_element_error (GST_ELEMENT (src), "could not negotiate format");
|
gst_element_error (GST_ELEMENT (src), "could not negotiate format");
|
||||||
return NULL;
|
return GST_BUFFER (gst_event_new (GST_EVENT_INTERRUPT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (src->common.bps == 0) {
|
if (src->common.bps == 0) {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
gst_element_error (GST_ELEMENT (src), "no format negotiated");
|
gst_element_error (GST_ELEMENT (src), "no format negotiated");
|
||||||
return NULL;
|
return GST_BUFFER (gst_event_new (GST_EVENT_INTERRUPT));
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_BUFFER_SIZE (buf) = readbytes;
|
GST_BUFFER_SIZE (buf) = readbytes;
|
||||||
|
|
Loading…
Reference in a new issue