summaryrefslogtreecommitdiffstats
path: root/pulse/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/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/pulse.c')
-rw-r--r--pulse/pulse.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/pulse/pulse.c b/pulse/pulse.c
index 3940238..95d8dde 100644
--- a/pulse/pulse.c
+++ b/pulse/pulse.c
@@ -32,8 +32,9 @@ int pulse_check_connection(snd_pulse_t * p)
pa_context_state_t state;
assert(p);
- assert(p->context);
- assert(p->mainloop);
+
+ if (!p->context || !p->mainloop)
+ return -EBADFD;
state = pa_context_get_state(p->context);
@@ -77,8 +78,12 @@ int pulse_wait_operation(snd_pulse_t * p, pa_operation * o)
{
assert(p);
assert(o);
- assert(p->state == PULSE_STATE_READY);
- assert(p->mainloop);
+
+ if (p->state != PULSE_STATE_READY)
+ return -EBADFD;
+
+ if (!p->mainloop)
+ return -EBADFD;
for (;;) {
int err;
@@ -103,8 +108,12 @@ int pulse_wait_stream_state(snd_pulse_t * p, pa_stream * stream,
assert(p);
assert(stream);
- assert(p->state == PULSE_STATE_READY);
- assert(p->mainloop);
+
+ if (p->state != PULSE_STATE_READY)
+ return -EBADFD;
+
+ if (!p->mainloop)
+ return -EBADFD;
for (;;) {
int err;
@@ -197,7 +206,9 @@ snd_pulse_t *pulse_new(void)
p->context =
pa_context_new(pa_threaded_mainloop_get_api(p->mainloop), buf);
- assert(p->context);
+
+ if (!p->context)
+ goto fail;
pa_context_set_state_callback(p->context, context_state_cb, p);
@@ -246,9 +257,12 @@ int pulse_connect(snd_pulse_t * p, const char *server)
int err;
assert(p);
- assert(p->context);
- assert(p->mainloop);
- assert(p->state == PULSE_STATE_INIT);
+
+ if (!p->context || !p->mainloop)
+ return -EBADFD;
+
+ if (p->state != PULSE_STATE_INIT)
+ return -EBADFD;
pa_threaded_mainloop_lock(p->mainloop);