summaryrefslogtreecommitdiffstats
path: root/pulse/ctl_pulse.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-07-31 15:25:44 +0200
committerTakashi Iwai <tiwai@suse.de>2009-08-03 12:35:35 +0200
commitbe8799947bac41c50460111b0ac20ff8176b6b47 (patch)
treeccd42a7b78abd2208146da406c33e860dc7449e0 /pulse/ctl_pulse.c
parentae9a633d98988d072307284a260e985a4c660501 (diff)
pulse: get rid of a number of assert()s
Instead of hitting an assert when any of the plugin functions is called in an invalid context we should return a clean error to make sure programs are not unnecessarily aborted. This should fix issues such as http://pulseaudio.org/ticket/595 Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'pulse/ctl_pulse.c')
-rw-r--r--pulse/ctl_pulse.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/pulse/ctl_pulse.c b/pulse/ctl_pulse.c
index c6cf9e2..2caa29b 100644
--- a/pulse/ctl_pulse.c
+++ b/pulse/ctl_pulse.c
@@ -125,8 +125,9 @@ static void event_cb(pa_context * c, pa_subscription_event_type_t t,
pa_operation *o;
assert(ctl);
- assert(ctl->p);
- assert(ctl->p->context);
+
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return;
o = pa_context_get_sink_info_by_name(ctl->p->context, ctl->sink,
sink_info_cb, ctl);
@@ -148,8 +149,9 @@ static int pulse_update_volume(snd_ctl_pulse_t * ctl)
pa_operation *o;
assert(ctl);
- assert(ctl->p);
- assert(ctl->p->context);
+
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
o = pa_context_get_sink_info_by_name(ctl->p->context, ctl->sink,
sink_info_cb, ctl);
@@ -203,6 +205,9 @@ static int pulse_elem_list(snd_ctl_ext_t * ext, unsigned int offset,
assert(ctl);
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
+
snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
pa_threaded_mainloop_lock(ctl->p->mainloop);
@@ -260,7 +265,9 @@ static int pulse_get_attribute(snd_ctl_ext_t * ext, snd_ctl_ext_key_t key,
return -EINVAL;
assert(ctl);
- assert(ctl->p);
+
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
@@ -311,7 +318,9 @@ static int pulse_read_integer(snd_ctl_ext_t * ext, snd_ctl_ext_key_t key,
pa_cvolume *vol = NULL;
assert(ctl);
- assert(ctl->p);
+
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
@@ -361,7 +370,9 @@ static int pulse_write_integer(snd_ctl_ext_t * ext, snd_ctl_ext_key_t key,
pa_cvolume *vol = NULL;
assert(ctl);
- assert(ctl->p && ctl->p->context);
+
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);
@@ -465,6 +476,9 @@ static void pulse_subscribe_events(snd_ctl_ext_t * ext, int subscribe)
assert(ctl);
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return;
+
pa_threaded_mainloop_lock(ctl->p->mainloop);
ctl->subscribed = !!(subscribe & SND_CTL_EVENT_MASK_VALUE);
@@ -481,6 +495,9 @@ static int pulse_read_event(snd_ctl_ext_t * ext, snd_ctl_elem_id_t * id,
assert(ctl);
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
+
pa_threaded_mainloop_lock(ctl->p->mainloop);
if (!ctl->updated || !ctl->subscribed)
@@ -526,7 +543,9 @@ static int pulse_ctl_poll_revents(snd_ctl_ext_t * ext, struct pollfd *pfd,
int err = 0;
assert(ctl);
- assert(ctl->p);
+
+ if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
+ return -EBADFD;
pa_threaded_mainloop_lock(ctl->p->mainloop);