]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
pulse: get rid of redundant state variable
authorLennart Poettering <mznyfn@0pointer.de>
Tue, 4 Aug 2009 21:54:42 +0000 (23:54 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 4 Aug 2009 21:58:22 +0000 (23:58 +0200)
snd_pulse_t::state was mostly shadowing the state of
pa_context_get_state(snd_pulse_t::context), so get rid of it and use the
state of the context directly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
pulse/pulse.c
pulse/pulse.h

index c313182cf0495650339be022cce6da8e943eb35e..9c0517183293a9ce7a137633aca74437b8b824b0 100644 (file)
@@ -59,12 +59,6 @@ int pulse_wait_operation(snd_pulse_t * p, pa_operation * o)
        assert(p);
        assert(o);
 
-       if (p->state != PULSE_STATE_READY)
-               return -EBADFD;
-
-       if (!p->mainloop)
-               return -EBADFD;
-
        for (;;) {
                int err;
 
@@ -124,8 +118,6 @@ snd_pulse_t *pulse_new(void)
        if (!p)
                return NULL;
 
-       p->state = PULSE_STATE_INIT;
-
        if (pipe(fd)) {
                free(p);
                return NULL;
@@ -192,13 +184,15 @@ void pulse_free(snd_pulse_t * p)
 int pulse_connect(snd_pulse_t * p, const char *server)
 {
        int err;
+       pa_context_state_t state;
 
        assert(p);
 
        if (!p->context || !p->mainloop)
                return -EBADFD;
 
-       if (p->state != PULSE_STATE_INIT)
+       state = pa_context_get_state(p->context);
+       if (state != PA_CONTEXT_UNCONNECTED)
                return -EBADFD;
 
        pa_threaded_mainloop_lock(p->mainloop);
@@ -221,8 +215,6 @@ int pulse_connect(snd_pulse_t * p, const char *server)
 
        pa_threaded_mainloop_unlock(p->mainloop);
 
-       p->state = PULSE_STATE_READY;
-
        return 0;
 
       error:
index 51f9a11309b415c336185a44f96a1d20957e746c..e98124f284cb848f39b30ef32400cd087d24fd7b 100644 (file)
@@ -31,12 +31,6 @@ typedef struct snd_pulse {
        pa_context *context;
 
        int thread_fd, main_fd;
-
-       enum {
-               PULSE_STATE_INIT,
-               PULSE_STATE_READY,
-       } state;
-
 } snd_pulse_t;
 
 int pulse_check_connection(snd_pulse_t * p);