Commit f3259353 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

pulse, speexenc, rtpgsmpay: don't use g_assert() for error handling

Don't use g_assert() for error handling, even if they're highly unlikely.
Either we *know* that something can't happen, in which case we
should just not handle it, or we think something can happen, but it is
very very unlikely that it will ever happen, in which case we should
handle it like any other error instead of asserting.

g_assert() is best left for conditions we have control of, like checking
internal consistency of our code, not checking return values of external

Fixes a bunch of warnings when compiling with -DG_DISABLE_ASSERT:
gstrtpgsmpay.c: In function 'gst_rtp_gsm_pay_handle_buffer':
gstrtpgsmpay.c:130:17: warning: variable 'rtpgsmpay' set but not used
gstspeexenc.c: In function 'gst_speex_enc_encode':
gstspeexenc.c:904:19: warning: variable 'written' set but not used
pulsesink.c: In function 'gst_pulsesink_change_state':
pulsesink.c:2725:9: warning: variable 'res' set but not used
pulsesrc.c: In function 'gst_pulsesrc_change_state':
pulsesrc.c:1253:7: warning: variable 'e' set but not used
parent b005dfea
......@@ -1072,8 +1072,8 @@ gst_pulseringbuffer_start (GstRingBuffer * buf)
/* EOS needs running clock */
if (GST_BASE_SINK_CAST (psink)->eos ||
g_atomic_int_get (&GST_BASE_AUDIO_SINK (psink)->abidata.
g_atomic_int_get (&GST_BASE_AUDIO_SINK (psink)->abidata.ABI.
gst_pulsering_set_corked (pbuf, FALSE, FALSE);
pa_threaded_mainloop_unlock (mainloop);
......@@ -2722,7 +2722,6 @@ gst_pulsesink_change_state (GstElement * element, GstStateChange transition)
GstPulseSink *pulsesink = GST_PULSESINK (element);
GstStateChangeReturn ret;
guint res;
switch (transition) {
......@@ -2732,8 +2731,7 @@ gst_pulsesink_change_state (GstElement * element, GstStateChange transition)
if (!(mainloop = pa_threaded_mainloop_new ()))
goto mainloop_failed;
mainloop_ref_ct = 1;
res = pa_threaded_mainloop_start (mainloop);
g_assert (res == 0);
pa_threaded_mainloop_start (mainloop);
g_mutex_unlock (pa_shared_resource_mutex);
} else {
GST_INFO_OBJECT (element, "reusing pa main loop thread");
......@@ -1112,7 +1112,7 @@ gst_pulsesrc_success_cb (pa_stream * s, int success, void *userdata)
GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (userdata);
pulsesrc->operation_success = !!success;
pulsesrc->operation_success = ! !success;
pa_threaded_mainloop_signal (pulsesrc->mainloop, 0);
......@@ -1250,15 +1250,13 @@ gst_pulsesrc_change_state (GstElement * element, GstStateChange transition)
GstStateChangeReturn ret;
GstPulseSrc *this = GST_PULSESRC_CAST (element);
int e;
switch (transition) {
this->mainloop = pa_threaded_mainloop_new ();
g_assert (this->mainloop);
e = pa_threaded_mainloop_start (this->mainloop);
g_assert (e == 0);
pa_threaded_mainloop_start (this->mainloop);
if (!this->mixer)
this->mixer =
......@@ -934,7 +934,12 @@ gst_speex_enc_encode (GstSpeexEnc * enc, gboolean flush)
written = speex_bits_write (&enc->bits,
(gchar *) GST_BUFFER_DATA (outbuf), outsize);
g_assert (written == outsize);
if (G_UNLIKELY (written != outsize)) {
GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
GST_BUFFER_SIZE (outbuf) = written;
speex_bits_reset (&enc->bits);
if (!dtx_ret)
......@@ -143,9 +143,15 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* FIXME, only one GSM frame per RTP packet for now */
payload_len = size;
/* FIXME, just error out for now */
if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)) {
("payload_len %u > mtu %u", payload_len,
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay));
/* copy timestamp and duration */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment