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
code.
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
/* EOS needs running clock */
if (GST_BASE_SINK_CAST (psink)->eos ||
- g_atomic_int_get (&GST_BASE_AUDIO_SINK (psink)->abidata.
- ABI.eos_rendering))
+ g_atomic_int_get (&GST_BASE_AUDIO_SINK (psink)->abidata.ABI.
+ eos_rendering))
gst_pulsering_set_corked (pbuf, FALSE, FALSE);
pa_threaded_mainloop_unlock (mainloop);
{
GstPulseSink *pulsesink = GST_PULSESINK (element);
GstStateChangeReturn ret;
- guint res;
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
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");
{
GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (userdata);
- pulsesrc->operation_success = !!success;
+ pulsesrc->operation_success = ! !success;
pa_threaded_mainloop_signal (pulsesrc->mainloop, 0);
}
{
GstStateChangeReturn ret;
GstPulseSrc *this = GST_PULSESRC_CAST (element);
- int e;
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
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 =
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)
/* 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)) {
+ GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
+ ("payload_len %u > mtu %u", payload_len,
+ GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)));
+ return GST_FLOW_ERROR;
+ }
+
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;