56753ff
From 5c8ce128ec78d17a8a0f49115dc07726a3d3f0c1 Mon Sep 17 00:00:00 2001
56753ff
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@gmail.com>
56753ff
Date: Tue, 17 Apr 2012 14:32:41 +0200
56753ff
Subject: [PATCH 507/509] Do not use pa_simple PulseAudio API
56753ff
56753ff
Unfortunately, pa_simple is a limited API which doesn't let us
56753ff
retrieve the associated pa_stream. It is needed to control the volume
56753ff
of the stream.
56753ff
56753ff
In v4:
56753ff
- add missing braces
56753ff
56753ff
Signed-off-by: Marc-Andr? Lureau <marcandre.lureau@redhat.com>
56753ff
Signed-off-by: malc <av1474@comtv.ru>
56753ff
---
56753ff
 audio/paaudio.c |  377 +++++++++++++++++++++++++++++++++++++++++++++++++------
56753ff
 1 file changed, 339 insertions(+), 38 deletions(-)
56753ff
56753ff
diff --git a/audio/paaudio.c b/audio/paaudio.c
56753ff
index d1f3912..6f50c1c 100644
56753ff
--- a/audio/paaudio.c
56753ff
+++ b/audio/paaudio.c
56753ff
@@ -2,8 +2,7 @@
56753ff
 #include "qemu-common.h"
56753ff
 #include "audio.h"
56753ff
 
56753ff
-#include <pulse/simple.h>
56753ff
-#include <pulse/error.h>
56753ff
+#include <pulse/pulseaudio.h>
56753ff
 
56753ff
 #define AUDIO_CAP "pulseaudio"
56753ff
 #include "audio_int.h"
56753ff
@@ -15,7 +14,7 @@ typedef struct {
56753ff
     int live;
56753ff
     int decr;
56753ff
     int rpos;
56753ff
-    pa_simple *s;
56753ff
+    pa_stream *stream;
56753ff
     void *pcm_buf;
56753ff
     struct audio_pt pt;
56753ff
 } PAVoiceOut;
56753ff
@@ -26,17 +25,23 @@ typedef struct {
56753ff
     int dead;
56753ff
     int incr;
56753ff
     int wpos;
56753ff
-    pa_simple *s;
56753ff
+    pa_stream *stream;
56753ff
     void *pcm_buf;
56753ff
     struct audio_pt pt;
56753ff
+    const void *read_data;
56753ff
+    size_t read_index, read_length;
56753ff
 } PAVoiceIn;
56753ff
 
56753ff
-static struct {
56753ff
+typedef struct {
56753ff
     int samples;
56753ff
     char *server;
56753ff
     char *sink;
56753ff
     char *source;
56753ff
-} conf = {
56753ff
+    pa_threaded_mainloop *mainloop;
56753ff
+    pa_context *context;
56753ff
+} paaudio;
56753ff
+
56753ff
+static paaudio glob_paaudio = {
56753ff
     .samples = 4096,
56753ff
 };
56753ff
 
56753ff
@@ -51,6 +56,126 @@ static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...)
56753ff
     AUD_log (AUDIO_CAP, "Reason: %s\n", pa_strerror (err));
56753ff
 }
56753ff
 
56753ff
+#define CHECK_SUCCESS_GOTO(c, rerror, expression, label)        \
56753ff
+    do {                                                        \
56753ff
+        if (!(expression)) {                                    \
56753ff
+            if (rerror) {                                       \
56753ff
+                *(rerror) = pa_context_errno ((c)->context);    \
56753ff
+            }                                                   \
56753ff
+            goto label;                                         \
56753ff
+        }                                                       \
56753ff
+    } while (0);
56753ff
+
56753ff
+#define CHECK_DEAD_GOTO(c, stream, rerror, label)                       \
56753ff
+    do {                                                                \
56753ff
+        if (!(c)->context || !PA_CONTEXT_IS_GOOD (pa_context_get_state((c)->context)) || \
56753ff
+            !(stream) || !PA_STREAM_IS_GOOD (pa_stream_get_state ((stream)))) { \
56753ff
+            if (((c)->context && pa_context_get_state ((c)->context) == PA_CONTEXT_FAILED) || \
56753ff
+                ((stream) && pa_stream_get_state ((stream)) == PA_STREAM_FAILED)) { \
56753ff
+                if (rerror) {                                           \
56753ff
+                    *(rerror) = pa_context_errno ((c)->context);        \
56753ff
+                }                                                       \
56753ff
+            } else {                                                    \
56753ff
+                if (rerror) {                                           \
56753ff
+                    *(rerror) = PA_ERR_BADSTATE;                        \
56753ff
+                }                                                       \
56753ff
+            }                                                           \
56753ff
+            goto label;                                                 \
56753ff
+        }                                                               \
56753ff
+    } while (0);
56753ff
+
56753ff
+static int qpa_simple_read (PAVoiceIn *p, void *data, size_t length, int *rerror)
56753ff
+{
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+
56753ff
+    pa_threaded_mainloop_lock (g->mainloop);
56753ff
+
56753ff
+    CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail);
56753ff
+
56753ff
+    while (length > 0) {
56753ff
+        size_t l;
56753ff
+
56753ff
+        while (!p->read_data) {
56753ff
+            int r;
56753ff
+
56753ff
+            r = pa_stream_peek (p->stream, &p->read_data, &p->read_length);
56753ff
+            CHECK_SUCCESS_GOTO (g, rerror, r == 0, unlock_and_fail);
56753ff
+
56753ff
+            if (!p->read_data) {
56753ff
+                pa_threaded_mainloop_wait (g->mainloop);
56753ff
+                CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail);
56753ff
+            } else {
56753ff
+                p->read_index = 0;
56753ff
+            }
56753ff
+        }
56753ff
+
56753ff
+        l = p->read_length < length ? p->read_length : length;
56753ff
+        memcpy (data, (const uint8_t *) p->read_data+p->read_index, l);
56753ff
+
56753ff
+        data = (uint8_t *) data + l;
56753ff
+        length -= l;
56753ff
+
56753ff
+        p->read_index += l;
56753ff
+        p->read_length -= l;
56753ff
+
56753ff
+        if (!p->read_length) {
56753ff
+            int r;
56753ff
+
56753ff
+            r = pa_stream_drop (p->stream);
56753ff
+            p->read_data = NULL;
56753ff
+            p->read_length = 0;
56753ff
+            p->read_index = 0;
56753ff
+
56753ff
+            CHECK_SUCCESS_GOTO (g, rerror, r == 0, unlock_and_fail);
56753ff
+        }
56753ff
+    }
56753ff
+
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+    return 0;
56753ff
+
56753ff
+unlock_and_fail:
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+    return -1;
56753ff
+}
56753ff
+
56753ff
+static int qpa_simple_write (PAVoiceOut *p, const void *data, size_t length, int *rerror)
56753ff
+{
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+
56753ff
+    pa_threaded_mainloop_lock (g->mainloop);
56753ff
+
56753ff
+    CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail);
56753ff
+
56753ff
+    while (length > 0) {
56753ff
+        size_t l;
56753ff
+        int r;
56753ff
+
56753ff
+        while (!(l = pa_stream_writable_size (p->stream))) {
56753ff
+            pa_threaded_mainloop_wait (g->mainloop);
56753ff
+            CHECK_DEAD_GOTO (g, p->stream, rerror, unlock_and_fail);
56753ff
+        }
56753ff
+
56753ff
+        CHECK_SUCCESS_GOTO (g, rerror, l != (size_t) -1, unlock_and_fail);
56753ff
+
56753ff
+        if (l > length) {
56753ff
+            l = length;
56753ff
+        }
56753ff
+
56753ff
+        r = pa_stream_write (p->stream, data, l, NULL, 0LL, PA_SEEK_RELATIVE);
56753ff
+        CHECK_SUCCESS_GOTO (g, rerror, r >= 0, unlock_and_fail);
56753ff
+
56753ff
+        data = (const uint8_t *) data + l;
56753ff
+        length -= l;
56753ff
+    }
56753ff
+
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+    return 0;
56753ff
+
56753ff
+unlock_and_fail:
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+    return -1;
56753ff
+}
56753ff
+
56753ff
 static void *qpa_thread_out (void *arg)
56753ff
 {
56753ff
     PAVoiceOut *pa = arg;
56753ff
@@ -77,7 +202,7 @@ static void *qpa_thread_out (void *arg)
56753ff
             }
56753ff
         }
56753ff
 
56753ff
-        decr = to_mix = audio_MIN (pa->live, conf.samples >> 2);
56753ff
+        decr = to_mix = audio_MIN (pa->live, glob_paaudio.samples >> 2);
56753ff
         rpos = pa->rpos;
56753ff
 
56753ff
         if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
56753ff
@@ -91,8 +216,8 @@ static void *qpa_thread_out (void *arg)
56753ff
 
56753ff
             hw->clip (pa->pcm_buf, src, chunk);
56753ff
 
56753ff
-            if (pa_simple_write (pa->s, pa->pcm_buf,
56753ff
-                                 chunk << hw->info.shift, &error) < 0) {
56753ff
+            if (qpa_simple_write (pa, pa->pcm_buf,
56753ff
+                                  chunk << hw->info.shift, &error) < 0) {
56753ff
                 qpa_logerr (error, "pa_simple_write failed\n");
56753ff
                 return NULL;
56753ff
             }
56753ff
@@ -169,7 +294,7 @@ static void *qpa_thread_in (void *arg)
56753ff
             }
56753ff
         }
56753ff
 
56753ff
-        incr = to_grab = audio_MIN (pa->dead, conf.samples >> 2);
56753ff
+        incr = to_grab = audio_MIN (pa->dead, glob_paaudio.samples >> 2);
56753ff
         wpos = pa->wpos;
56753ff
 
56753ff
         if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
56753ff
@@ -181,8 +306,8 @@ static void *qpa_thread_in (void *arg)
56753ff
             int chunk = audio_MIN (to_grab, hw->samples - wpos);
56753ff
             void *buf = advance (pa->pcm_buf, wpos);
56753ff
 
56753ff
-            if (pa_simple_read (pa->s, buf,
56753ff
-                                chunk << hw->info.shift, &error) < 0) {
56753ff
+            if (qpa_simple_read (pa, buf,
56753ff
+                                 chunk << hw->info.shift, &error) < 0) {
56753ff
                 qpa_logerr (error, "pa_simple_read failed\n");
56753ff
                 return NULL;
56753ff
             }
56753ff
@@ -283,6 +408,109 @@ static audfmt_e pa_to_audfmt (pa_sample_format_t fmt, int *endianness)
56753ff
     }
56753ff
 }
56753ff
 
56753ff
+static void context_state_cb (pa_context *c, void *userdata)
56753ff
+{
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+
56753ff
+    switch (pa_context_get_state(c)) {
56753ff
+    case PA_CONTEXT_READY:
56753ff
+    case PA_CONTEXT_TERMINATED:
56753ff
+    case PA_CONTEXT_FAILED:
56753ff
+        pa_threaded_mainloop_signal (g->mainloop, 0);
56753ff
+        break;
56753ff
+
56753ff
+    case PA_CONTEXT_UNCONNECTED:
56753ff
+    case PA_CONTEXT_CONNECTING:
56753ff
+    case PA_CONTEXT_AUTHORIZING:
56753ff
+    case PA_CONTEXT_SETTING_NAME:
56753ff
+        break;
56753ff
+    }
56753ff
+}
56753ff
+
56753ff
+static void stream_state_cb (pa_stream *s, void * userdata)
56753ff
+{
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+
56753ff
+    switch (pa_stream_get_state (s)) {
56753ff
+
56753ff
+    case PA_STREAM_READY:
56753ff
+    case PA_STREAM_FAILED:
56753ff
+    case PA_STREAM_TERMINATED:
56753ff
+        pa_threaded_mainloop_signal (g->mainloop, 0);
56753ff
+        break;
56753ff
+
56753ff
+    case PA_STREAM_UNCONNECTED:
56753ff
+    case PA_STREAM_CREATING:
56753ff
+        break;
56753ff
+    }
56753ff
+}
56753ff
+
56753ff
+static void stream_request_cb (pa_stream *s, size_t length, void *userdata)
56753ff
+{
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+
56753ff
+    pa_threaded_mainloop_signal (g->mainloop, 0);
56753ff
+}
56753ff
+
56753ff
+static pa_stream *qpa_simple_new (
56753ff
+        const char *server,
56753ff
+        const char *name,
56753ff
+        pa_stream_direction_t dir,
56753ff
+        const char *dev,
56753ff
+        const char *stream_name,
56753ff
+        const pa_sample_spec *ss,
56753ff
+        const pa_channel_map *map,
56753ff
+        const pa_buffer_attr *attr,
56753ff
+        int *rerror)
56753ff
+{
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+    int r;
56753ff
+    pa_stream *stream;
56753ff
+
56753ff
+    pa_threaded_mainloop_lock (g->mainloop);
56753ff
+
56753ff
+    stream = pa_stream_new (g->context, name, ss, map);
56753ff
+    if (!stream) {
56753ff
+        goto fail;
56753ff
+    }
56753ff
+
56753ff
+    pa_stream_set_state_callback (stream, stream_state_cb, g);
56753ff
+    pa_stream_set_read_callback (stream, stream_request_cb, g);
56753ff
+    pa_stream_set_write_callback (stream, stream_request_cb, g);
56753ff
+
56753ff
+    if (dir == PA_STREAM_PLAYBACK) {
56753ff
+        r = pa_stream_connect_playback (stream, dev, attr,
56753ff
+                                        PA_STREAM_INTERPOLATE_TIMING
56753ff
+                                        |PA_STREAM_ADJUST_LATENCY
56753ff
+                                        |PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL);
56753ff
+    } else {
56753ff
+        r = pa_stream_connect_record (stream, dev, attr,
56753ff
+                                      PA_STREAM_INTERPOLATE_TIMING
56753ff
+                                      |PA_STREAM_ADJUST_LATENCY
56753ff
+                                      |PA_STREAM_AUTO_TIMING_UPDATE);
56753ff
+    }
56753ff
+
56753ff
+    if (r < 0) {
56753ff
+      goto fail;
56753ff
+    }
56753ff
+
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+
56753ff
+    return stream;
56753ff
+
56753ff
+fail:
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+
56753ff
+    if (stream) {
56753ff
+        pa_stream_unref (stream);
56753ff
+    }
56753ff
+
56753ff
+    qpa_logerr (pa_context_errno (g->context),
56753ff
+                "stream_new() failed\n");
56753ff
+
56753ff
+    return NULL;
56753ff
+}
56753ff
+
56753ff
 static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
56753ff
 {
56753ff
     int error;
56753ff
@@ -306,24 +534,24 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
56753ff
 
56753ff
     obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
56753ff
 
56753ff
-    pa->s = pa_simple_new (
56753ff
-        conf.server,
56753ff
+    pa->stream = qpa_simple_new (
56753ff
+        glob_paaudio.server,
56753ff
         "qemu",
56753ff
         PA_STREAM_PLAYBACK,
56753ff
-        conf.sink,
56753ff
+        glob_paaudio.sink,
56753ff
         "pcm.playback",
56753ff
         &ss,
56753ff
         NULL,                   /* channel map */
56753ff
         &ba,                    /* buffering attributes */
56753ff
         &error
56753ff
         );
56753ff
-    if (!pa->s) {
56753ff
+    if (!pa->stream) {
56753ff
         qpa_logerr (error, "pa_simple_new for playback failed\n");
56753ff
         goto fail1;
56753ff
     }
56753ff
 
56753ff
     audio_pcm_init_info (&hw->info, &obt_as);
56753ff
-    hw->samples = conf.samples;
56753ff
+    hw->samples = glob_paaudio.samples;
56753ff
     pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
56753ff
     pa->rpos = hw->rpos;
56753ff
     if (!pa->pcm_buf) {
56753ff
@@ -342,8 +570,10 @@ static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
56753ff
     g_free (pa->pcm_buf);
56753ff
     pa->pcm_buf = NULL;
56753ff
  fail2:
56753ff
-    pa_simple_free (pa->s);
56753ff
-    pa->s = NULL;
56753ff
+    if (pa->stream) {
56753ff
+        pa_stream_unref (pa->stream);
56753ff
+        pa->stream = NULL;
56753ff
+    }
56753ff
  fail1:
56753ff
     return -1;
56753ff
 }
56753ff
@@ -361,24 +591,24 @@ static int qpa_init_in (HWVoiceIn *hw, struct audsettings *as)
56753ff
 
56753ff
     obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
56753ff
 
56753ff
-    pa->s = pa_simple_new (
56753ff
-        conf.server,
56753ff
+    pa->stream = qpa_simple_new (
56753ff
+        glob_paaudio.server,
56753ff
         "qemu",
56753ff
         PA_STREAM_RECORD,
56753ff
-        conf.source,
56753ff
+        glob_paaudio.source,
56753ff
         "pcm.capture",
56753ff
         &ss,
56753ff
         NULL,                   /* channel map */
56753ff
         NULL,                   /* buffering attributes */
56753ff
         &error
56753ff
         );
56753ff
-    if (!pa->s) {
56753ff
+    if (!pa->stream) {
56753ff
         qpa_logerr (error, "pa_simple_new for capture failed\n");
56753ff
         goto fail1;
56753ff
     }
56753ff
 
56753ff
     audio_pcm_init_info (&hw->info, &obt_as);
56753ff
-    hw->samples = conf.samples;
56753ff
+    hw->samples = glob_paaudio.samples;
56753ff
     pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
56753ff
     pa->wpos = hw->wpos;
56753ff
     if (!pa->pcm_buf) {
56753ff
@@ -397,8 +627,10 @@ static int qpa_init_in (HWVoiceIn *hw, struct audsettings *as)
56753ff
     g_free (pa->pcm_buf);
56753ff
     pa->pcm_buf = NULL;
56753ff
  fail2:
56753ff
-    pa_simple_free (pa->s);
56753ff
-    pa->s = NULL;
56753ff
+    if (pa->stream) {
56753ff
+        pa_stream_unref (pa->stream);
56753ff
+        pa->stream = NULL;
56753ff
+    }
56753ff
  fail1:
56753ff
     return -1;
56753ff
 }
56753ff
@@ -413,9 +645,9 @@ static void qpa_fini_out (HWVoiceOut *hw)
56753ff
     audio_pt_unlock_and_signal (&pa->pt, AUDIO_FUNC);
56753ff
     audio_pt_join (&pa->pt, &ret, AUDIO_FUNC);
56753ff
 
56753ff
-    if (pa->s) {
56753ff
-        pa_simple_free (pa->s);
56753ff
-        pa->s = NULL;
56753ff
+    if (pa->stream) {
56753ff
+        pa_stream_unref (pa->stream);
56753ff
+        pa->stream = NULL;
56753ff
     }
56753ff
 
56753ff
     audio_pt_fini (&pa->pt, AUDIO_FUNC);
56753ff
@@ -433,9 +665,9 @@ static void qpa_fini_in (HWVoiceIn *hw)
56753ff
     audio_pt_unlock_and_signal (&pa->pt, AUDIO_FUNC);
56753ff
     audio_pt_join (&pa->pt, &ret, AUDIO_FUNC);
56753ff
 
56753ff
-    if (pa->s) {
56753ff
-        pa_simple_free (pa->s);
56753ff
-        pa->s = NULL;
56753ff
+    if (pa->stream) {
56753ff
+        pa_stream_unref (pa->stream);
56753ff
+        pa->stream = NULL;
56753ff
     }
56753ff
 
56753ff
     audio_pt_fini (&pa->pt, AUDIO_FUNC);
56753ff
@@ -460,37 +692,106 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...)
56753ff
 /* common */
56753ff
 static void *qpa_audio_init (void)
56753ff
 {
56753ff
-    return &conf;
56753ff
+    paaudio *g = &glob_paaudio;
56753ff
+
56753ff
+    g->mainloop = pa_threaded_mainloop_new ();
56753ff
+    if (!g->mainloop) {
56753ff
+        goto fail;
56753ff
+    }
56753ff
+
56753ff
+    g->context = pa_context_new (pa_threaded_mainloop_get_api (g->mainloop), glob_paaudio.server);
56753ff
+    if (!g->context) {
56753ff
+        goto fail;
56753ff
+    }
56753ff
+
56753ff
+    pa_context_set_state_callback (g->context, context_state_cb, g);
56753ff
+
56753ff
+    if (pa_context_connect (g->context, glob_paaudio.server, 0, NULL) < 0) {
56753ff
+        qpa_logerr (pa_context_errno (g->context),
56753ff
+                    "pa_context_connect() failed\n");
56753ff
+        goto fail;
56753ff
+    }
56753ff
+
56753ff
+    pa_threaded_mainloop_lock (g->mainloop);
56753ff
+
56753ff
+    if (pa_threaded_mainloop_start (g->mainloop) < 0) {
56753ff
+        goto unlock_and_fail;
56753ff
+    }
56753ff
+
56753ff
+    for (;;) {
56753ff
+        pa_context_state_t state;
56753ff
+
56753ff
+        state = pa_context_get_state (g->context);
56753ff
+
56753ff
+        if (state == PA_CONTEXT_READY) {
56753ff
+            break;
56753ff
+        }
56753ff
+
56753ff
+        if (!PA_CONTEXT_IS_GOOD (state)) {
56753ff
+            qpa_logerr (pa_context_errno (g->context),
56753ff
+                        "Wrong context state\n");
56753ff
+            goto unlock_and_fail;
56753ff
+        }
56753ff
+
56753ff
+        /* Wait until the context is ready */
56753ff
+        pa_threaded_mainloop_wait (g->mainloop);
56753ff
+    }
56753ff
+
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+
56753ff
+    return &glob_paaudio;
56753ff
+
56753ff
+unlock_and_fail:
56753ff
+    pa_threaded_mainloop_unlock (g->mainloop);
56753ff
+fail:
56753ff
+    AUD_log (AUDIO_CAP, "Failed to initialize PA context");
56753ff
+    return NULL;
56753ff
 }
56753ff
 
56753ff
 static void qpa_audio_fini (void *opaque)
56753ff
 {
56753ff
-    (void) opaque;
56753ff
+    paaudio *g = opaque;
56753ff
+
56753ff
+    if (g->mainloop) {
56753ff
+        pa_threaded_mainloop_stop (g->mainloop);
56753ff
+    }
56753ff
+
56753ff
+    if (g->context) {
56753ff
+        pa_context_disconnect (g->context);
56753ff
+        pa_context_unref (g->context);
56753ff
+        g->context = NULL;
56753ff
+    }
56753ff
+
56753ff
+    if (g->mainloop) {
56753ff
+        pa_threaded_mainloop_free (g->mainloop);
56753ff
+    }
56753ff
+
56753ff
+    g->mainloop = NULL;
56753ff
 }
56753ff
 
56753ff
 struct audio_option qpa_options[] = {
56753ff
     {
56753ff
         .name  = "SAMPLES",
56753ff
         .tag   = AUD_OPT_INT,
56753ff
-        .valp  = &conf.samples,
56753ff
+        .valp  = &glob_paaudio.samples,
56753ff
         .descr = "buffer size in samples"
56753ff
     },
56753ff
     {
56753ff
         .name  = "SERVER",
56753ff
         .tag   = AUD_OPT_STR,
56753ff
-        .valp  = &conf.server,
56753ff
+        .valp  = &glob_paaudio.server,
56753ff
         .descr = "server address"
56753ff
     },
56753ff
     {
56753ff
         .name  = "SINK",
56753ff
         .tag   = AUD_OPT_STR,
56753ff
-        .valp  = &conf.sink,
56753ff
+        .valp  = &glob_paaudio.sink,
56753ff
         .descr = "sink device name"
56753ff
     },
56753ff
     {
56753ff
         .name  = "SOURCE",
56753ff
         .tag   = AUD_OPT_STR,
56753ff
-        .valp  = &conf.source,
56753ff
+        .valp  = &glob_paaudio.source,
56753ff
         .descr = "source device name"
56753ff
     },
56753ff
     { /* End of list */ }
56753ff
-- 
56753ff
1.7.10
56753ff