]> code.delx.au - pulseaudio/commitdiff
devices: Use wrapper functions to set the *_volume and *_mute callbacks.
authorColin Guthrie <colin@mageia.org>
Sun, 17 Jul 2011 14:29:29 +0000 (15:29 +0100)
committerColin Guthrie <colin@mageia.org>
Tue, 19 Jul 2011 18:50:43 +0000 (19:50 +0100)
This is not currently useful but future commits will make further
changes concerning automatic setting of flags and event delivery
that makes this structure necessary.

17 files changed:
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c
src/modules/bluetooth/module-bluetooth-device.c
src/modules/echo-cancel/module-echo-cancel.c
src/modules/module-equalizer-sink.c
src/modules/module-ladspa-sink.c
src/modules/module-solaris.c
src/modules/module-tunnel.c
src/modules/module-virtual-sink.c
src/modules/module-virtual-source.c
src/modules/module-waveout.c
src/modules/oss/module-oss.c
src/modules/raop/module-raop-sink.c
src/pulsecore/sink.c
src/pulsecore/sink.h
src/pulsecore/source.c
src/pulsecore/source.h

index 0164040d636add838e98b4d495c96c0b51a710c4..98cb75fc90b7973c852863ff35ce15529b8e037e 100644 (file)
@@ -1777,9 +1777,9 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
             u->sink->n_volume_steps = u->mixer_path->max_volume - u->mixer_path->min_volume + 1;
         }
 
-        u->sink->get_volume = sink_get_volume_cb;
-        u->sink->set_volume = sink_set_volume_cb;
-        u->sink->write_volume = sink_write_volume_cb;
+        pa_sink_set_get_volume_callback(u->sink, sink_get_volume_cb);
+        pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
+        pa_sink_set_write_volume_callback(u->sink, sink_write_volume_cb);
 
         u->sink->flags |= PA_SINK_HW_VOLUME_CTRL;
         if (u->mixer_path->has_dB) {
@@ -1796,8 +1796,8 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
     if (!u->mixer_path->has_mute) {
         pa_log_info("Driver does not support hardware mute control, falling back to software mute control.");
     } else {
-        u->sink->get_mute = sink_get_mute_cb;
-        u->sink->set_mute = sink_set_mute_cb;
+        pa_sink_set_get_mute_callback(u->sink, sink_get_mute_cb);
+        pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
         u->sink->flags |= PA_SINK_HW_MUTE_CTRL;
         pa_log_info("Using hardware mute control.");
     }
index f847b1ee546f84e7c070094defd73862a634f90a..94c14cbb7f928892e5e3495d9938da15460941d5 100644 (file)
@@ -1552,9 +1552,9 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
             u->source->n_volume_steps = u->mixer_path->max_volume - u->mixer_path->min_volume + 1;
         }
 
-        u->source->get_volume = source_get_volume_cb;
-        u->source->set_volume = source_set_volume_cb;
-        u->source->write_volume = source_write_volume_cb;
+        pa_source_set_get_volume_callback(u->source, source_get_volume_cb);
+        pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
+        pa_source_set_write_volume_callback(u->source, source_write_volume_cb);
 
         u->source->flags |= PA_SOURCE_HW_VOLUME_CTRL;
         if (u->mixer_path->has_dB) {
@@ -1571,8 +1571,8 @@ static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB, pa_bool_t sync_v
     if (!u->mixer_path->has_mute) {
         pa_log_info("Driver does not support hardware mute control, falling back to software mute control.");
     } else {
-        u->source->get_mute = source_get_mute_cb;
-        u->source->set_mute = source_set_mute_cb;
+        pa_source_set_get_mute_callback(u->source, source_get_mute_cb);
+        pa_source_set_set_mute_callback(u->source, source_set_mute_cb);
         u->source->flags |= PA_SOURCE_HW_MUTE_CTRL;
         pa_log_info("Using hardware mute control.");
     }
index 288ad2fdbf208f2c79ee93b3a31b0f6b3172c50a..61600d9f5ec6a8ccb86ee65cae420462805fbc53 100644 (file)
@@ -2040,7 +2040,7 @@ static int add_sink(struct userdata *u) {
     }
 
     if (u->profile == PROFILE_HSP) {
-        u->sink->set_volume = sink_set_volume_cb;
+        pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
         u->sink->n_volume_steps = 16;
 
         k = pa_sprintf_malloc("bluetooth-device@%p", (void*) u->sink);
@@ -2111,7 +2111,7 @@ static int add_source(struct userdata *u) {
     }
 
     if (u->profile == PROFILE_HSP) {
-        u->source->set_volume = source_set_volume_cb;
+        pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
         u->source->n_volume_steps = 16;
 
         k = pa_sprintf_malloc("bluetooth-device@%p", (void*) u->source);
@@ -2510,8 +2510,8 @@ static void restore_sco_volume_callbacks(struct userdata *u) {
     pa_assert(u);
     pa_assert(USE_SCO_OVER_PCM(u));
 
-    u->hsp.sco_sink->set_volume = u->hsp.sco_sink_set_volume;
-    u->hsp.sco_source->set_volume = u->hsp.sco_source_set_volume;
+    pa_sink_set_set_volume_callback(u->hsp.sco_sink, u->hsp.sco_sink_set_volume);
+    pa_source_set_set_volume_callback(u->hsp.sco_source, u->hsp.sco_source_set_volume);
 }
 
 /* Run from main thread */
index a03fa820fb3653db8d1e5ef530d9b584ec9a64b5..cc06d471bc2bce4cca6a2a6253f091e65557c914 100644 (file)
@@ -1535,10 +1535,10 @@ int pa__init(pa_module*m) {
     u->source->parent.process_msg = source_process_msg_cb;
     u->source->set_state = source_set_state_cb;
     u->source->update_requested_latency = source_update_requested_latency_cb;
-    u->source->set_volume = source_set_volume_cb;
-    u->source->set_mute = source_set_mute_cb;
-    u->source->get_volume = source_get_volume_cb;
-    u->source->get_mute = source_get_mute_cb;
+    pa_source_set_get_volume_callback(u->source, source_get_volume_cb);
+    pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
+    pa_source_set_get_mute_callback(u->source, source_get_mute_cb);
+    pa_source_set_set_mute_callback(u->source, source_set_mute_cb);
     u->source->userdata = u;
 
     pa_source_set_asyncmsgq(u->source, source_master->asyncmsgq);
@@ -1584,8 +1584,8 @@ int pa__init(pa_module*m) {
     u->sink->set_state = sink_set_state_cb;
     u->sink->update_requested_latency = sink_update_requested_latency_cb;
     u->sink->request_rewind = sink_request_rewind_cb;
-    u->sink->set_volume = sink_set_volume_cb;
-    u->sink->set_mute = sink_set_mute_cb;
+    pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
+    pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
     u->sink->userdata = u;
 
     pa_sink_set_asyncmsgq(u->sink, sink_master->asyncmsgq);
index e7d8790a3ad1a696693a48bd2417bda0e00ffec8..03b166b98c04034d46abcefad456c1115f1dacee 100644 (file)
@@ -1191,8 +1191,8 @@ int pa__init(pa_module*m) {
     u->sink->set_state = sink_set_state_cb;
     u->sink->update_requested_latency = sink_update_requested_latency_cb;
     u->sink->request_rewind = sink_request_rewind_cb;
-    u->sink->set_volume = sink_set_volume_cb;
-    u->sink->set_mute = sink_set_mute_cb;
+    pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
+    pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
     u->sink->userdata = u;
 
     u->input_q = pa_memblockq_new(0,  MEMBLOCKQ_MAXLENGTH, 0, fs, 1, 1, 0, &u->sink->silence);
index 9cce269d9b4560ee25ad5028f5bda013e4bde492..aed6270bd2d356d6fcd0541cbc437404ac5d8b2c 100644 (file)
@@ -896,8 +896,8 @@ int pa__init(pa_module*m) {
     u->sink->set_state = sink_set_state_cb;
     u->sink->update_requested_latency = sink_update_requested_latency_cb;
     u->sink->request_rewind = sink_request_rewind_cb;
-    u->sink->set_volume = sink_set_volume_cb;
-    u->sink->set_mute = sink_set_mute_cb;
+    pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
+    pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
     u->sink->userdata = u;
 
     pa_sink_set_asyncmsgq(u->sink, master->asyncmsgq);
index 0e4e4017a8558caadda9e214ab9240a69b740855..ce6af8a3369d99528c602dfbb73f4c402f027810 100644 (file)
@@ -949,8 +949,8 @@ int pa__init(pa_module *m) {
         pa_source_set_rtpoll(u->source, u->rtpoll);
         pa_source_set_fixed_latency(u->source, pa_bytes_to_usec(u->buffer_size, &u->source->sample_spec));
 
-        u->source->get_volume = source_get_volume;
-        u->source->set_volume = source_set_volume;
+        pa_source_set_get_volume_callback(u->source, source_get_volume);
+        pa_source_set_set_volume_callback(u->source, source_set_volume);
         u->source->refresh_volume = TRUE;
     } else
         u->source = NULL;
@@ -994,10 +994,10 @@ int pa__init(pa_module *m) {
         pa_sink_set_max_request(u->sink, u->buffer_size);
         pa_sink_set_max_rewind(u->sink, u->buffer_size);
 
-        u->sink->get_volume = sink_get_volume;
-        u->sink->set_volume = sink_set_volume;
-        u->sink->get_mute = sink_get_mute;
-        u->sink->set_mute = sink_set_mute;
+        pa_sink_set_get_volume_callback(u->sink, sink_get_volume);
+        pa_sink_set_set_volume_callback(u->sink, sink_set_volume);
+        pa_sink_set_get_mute_callback(u->sink, sink_get_mute);
+        pa_sink_set_set_mute_callback(u->sink, sink_set_mute);
         u->sink->refresh_volume = u->sink->refresh_muted = TRUE;
     } else
         u->sink = NULL;
index 4b1ae7dfebc33a375d119726116946a8c4641450..e7e08717d124ef87f06d1534deff31fbe8ff1aea 100644 (file)
@@ -2014,8 +2014,8 @@ int pa__init(pa_module*m) {
     u->sink->parent.process_msg = sink_process_msg;
     u->sink->userdata = u;
     u->sink->set_state = sink_set_state;
-    u->sink->set_volume = sink_set_volume;
-    u->sink->set_mute = sink_set_mute;
+    pa_sink_set_set_volume_callback(u->sink, sink_set_volume);
+    pa_sink_set_set_mute_callback(u->sink, sink_set_mute);
 
     u->sink->refresh_volume = u->sink->refresh_muted = FALSE;
 
index a6be2446b7822306ff82c669562fde7663da2156..a880df4f65bc4e61ca8af2ffcd63bfd1cf048421 100644 (file)
@@ -567,8 +567,8 @@ int pa__init(pa_module*m) {
     u->sink->set_state = sink_set_state_cb;
     u->sink->update_requested_latency = sink_update_requested_latency_cb;
     u->sink->request_rewind = sink_request_rewind_cb;
-    u->sink->set_volume = use_volume_sharing ? NULL : sink_set_volume_cb;
-    u->sink->set_mute = sink_set_mute_cb;
+    pa_sink_set_set_volume_callback(u->sink, use_volume_sharing ? NULL : sink_set_volume_cb);
+    pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
     u->sink->userdata = u;
 
     pa_sink_set_asyncmsgq(u->sink, master->asyncmsgq);
index e15f4b9401a941aa84d2277486e3301367a7ba88..f5c5e67025e9658cb91e357d335dda8da6179fed 100644 (file)
@@ -594,8 +594,8 @@ int pa__init(pa_module*m) {
     u->source->parent.process_msg = source_process_msg_cb;
     u->source->set_state = source_set_state_cb;
     u->source->update_requested_latency = source_update_requested_latency_cb;
-    u->source->set_volume = use_volume_sharing ? NULL : source_set_volume_cb;
-    u->source->set_mute = source_set_mute_cb;
+    pa_source_set_set_volume_callback(u->source, use_volume_sharing ? NULL : source_set_volume_cb);
+    pa_source_set_set_mute_callback(u->source, source_set_mute_cb);
     u->source->userdata = u;
 
     pa_source_set_asyncmsgq(u->source, master->asyncmsgq);
index f0710b7e90f7579fae8a25254c983c86e820c094..53efce9ec920ab028cfb8adb9916bed3e21e6475 100644 (file)
@@ -637,8 +637,8 @@ int pa__init(pa_module *m) {
         pa_sink_new_data_done(&data);
 
         pa_assert(u->sink);
-        u->sink->get_volume = sink_get_volume_cb;
-        u->sink->set_volume = sink_set_volume_cb;
+        pa_sink_set_get_volume_callback(u->sink, sink_get_volume_cb);
+        pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
         u->sink->userdata = u;
         pa_sink_set_description(u->sink, description);
         u->sink->parent.process_msg = process_msg;
index 2a99d1191d807b4eaff4bc2d41e16bf40cff1077..a22b315d1f14e5e356aa052c5d1c533004e0cf1b 100644 (file)
@@ -1423,8 +1423,8 @@ int pa__init(pa_module*m) {
             if (u->sink && (u->mixer_devmask & (SOUND_MASK_VOLUME|SOUND_MASK_PCM))) {
                 pa_log_debug("Found hardware mixer track for playback.");
                 u->sink->flags |= PA_SINK_HW_VOLUME_CTRL;
-                u->sink->get_volume = sink_get_volume;
-                u->sink->set_volume = sink_set_volume;
+                pa_sink_set_get_volume_callback(u->sink, sink_get_volume);
+                pa_sink_set_set_volume_callback(u->sink, sink_set_volume);
                 u->sink->n_volume_steps = 101;
                 do_close = FALSE;
             }
@@ -1432,8 +1432,8 @@ int pa__init(pa_module*m) {
             if (u->source && (u->mixer_devmask & (SOUND_MASK_RECLEV|SOUND_MASK_IGAIN))) {
                 pa_log_debug("Found hardware mixer track for recording.");
                 u->source->flags |= PA_SOURCE_HW_VOLUME_CTRL;
-                u->source->get_volume = source_get_volume;
-                u->source->set_volume = source_set_volume;
+                pa_source_set_get_volume_callback(u->source, source_get_volume);
+                pa_source_set_set_volume_callback(u->source, source_set_volume);
                 u->source->n_volume_steps = 101;
                 do_close = FALSE;
             }
index 87e7bc17f9b9004c9a90124c1e8102c196e9a791..2600441524b370a8c49a907dd1720b0db3dc86e3 100644 (file)
@@ -594,8 +594,8 @@ int pa__init(pa_module*m) {
 
     u->sink->parent.process_msg = sink_process_msg;
     u->sink->userdata = u;
-    u->sink->set_volume = sink_set_volume_cb;
-    u->sink->set_mute = sink_set_mute_cb;
+    pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
+    pa_sink_set_set_mute_callback(u->sink, sink_set_mute_cb);
     u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK|PA_SINK_HW_VOLUME_CTRL;
 
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
index 45761a6c5e7c2eec9e2d5db5f9dbca2add33ed53..f7e4b6a273b8ca8399b803e082bee55d432f5a0e 100644 (file)
@@ -449,6 +449,36 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
     return 0;
 }
 
+void pa_sink_set_get_volume_callback(pa_sink *s, pa_sink_cb_t cb) {
+    pa_assert(s);
+
+    s->get_volume = cb;
+}
+
+void pa_sink_set_set_volume_callback(pa_sink *s, pa_sink_cb_t cb) {
+    pa_assert(s);
+
+    s->set_volume = cb;
+}
+
+void pa_sink_set_write_volume_callback(pa_sink *s, pa_sink_cb_t cb) {
+    pa_assert(s);
+
+    s->write_volume = cb;
+}
+
+void pa_sink_set_get_mute_callback(pa_sink *s, pa_sink_cb_t cb) {
+    pa_assert(s);
+
+    s->get_mute = cb;
+}
+
+void pa_sink_set_set_mute_callback(pa_sink *s, pa_sink_cb_t cb) {
+    pa_assert(s);
+
+    s->set_mute = cb;
+}
+
 /* Called from main context */
 void pa_sink_put(pa_sink* s) {
     pa_sink_assert_ref(s);
index 85c22ec66fb88f976b2590bb62ccd587d8edba89..669ce20b530748c275ef51b19e6a2c94bac2126e 100644 (file)
@@ -65,6 +65,9 @@ struct pa_device_port {
 
 #define PA_DEVICE_PORT_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_device_port))))
 
+/* A generic definition for void callback functions */
+typedef void(*pa_sink_cb_t)(pa_sink *s);
+
 struct pa_sink {
     pa_msgobject parent;
 
@@ -141,8 +144,11 @@ struct pa_sink {
      * PA_SINK_MESSAGE_GET_VOLUME (the main thread is waiting while
      * the message is being processed), so there's no choice of where
      * to do the volume reading - it has to be done in the IO thread
-     * always. */
-    void (*get_volume)(pa_sink *s);             /* may be NULL */
+     * always.
+     *
+     * You must use the function pa_sink_set_get_volume_callback() to
+     * set this callback. */
+    pa_sink_cb_t get_volume; /* may be NULL */
 
     /* Sink drivers that support hardware volume must set this
      * callback. This is called when the hardware volume needs to be
@@ -161,8 +167,11 @@ struct pa_sink {
      * requested volume the hardware volume can be set, and update
      * s->real_volume and/or s->soft_volume so that they together
      * match the actual hardware volume that will be set later in the
-     * write_volume callback. */
-    void (*set_volume)(pa_sink *s);             /* ditto */
+     * write_volume callback.
+     *
+     * You must use the function pa_sink_set_set_volume_callback() to
+     * set this callback. */
+    pa_sink_cb_t set_volume; /* may be NULL */
 
     /* Sink drivers that set PA_SINK_SYNC_VOLUME must provide this
      * callback. This callback is not used with sinks that do not set
@@ -174,27 +183,36 @@ struct pa_sink {
      * The call is done inside pa_sink_volume_change_apply(), which is
      * not called automatically - it is the driver's responsibility to
      * schedule that function to be called at the right times in the
-     * IO thread. */
-    void (*write_volume)(pa_sink *s);           /* ditto */
+     * IO thread.
+     *
+     * You must use the function pa_sink_set_write_volume_callback() to
+     * set this callback. */
+    pa_sink_cb_t write_volume; /* may be NULL */
 
     /* Called when the mute setting is queried. A PA_SINK_MESSAGE_GET_MUTE
      * message will also be sent. Called from IO thread if PA_SINK_SYNC_VOLUME
      * flag is set otherwise from main loop context. If refresh_mute is FALSE
-     * neither this function is called nor a message is sent.*/
-    void (*get_mute)(pa_sink *s);               /* ditto */
+     * neither this function is called nor a message is sent.
+     *
+     * You must use the function pa_sink_set_get_mute_callback() to
+     * set this callback. */
+    pa_sink_cb_t get_mute; /* may be NULL */
 
     /* Called when the mute setting shall be changed. A PA_SINK_MESSAGE_SET_MUTE
      * message will also be sent. Called from IO thread if PA_SINK_SYNC_VOLUME
-     * flag is set otherwise from main loop context. */
-    void (*set_mute)(pa_sink *s);               /* ditto */
+     * flag is set otherwise from main loop context.
+     *
+     * You must use the function pa_sink_set_set_mute_callback() to
+     * set this callback. */
+    pa_sink_cb_t set_mute; /* may be NULL */
 
     /* Called when a rewind request is issued. Called from IO thread
      * context. */
-    void (*request_rewind)(pa_sink *s);        /* ditto */
+    pa_sink_cb_t request_rewind; /* may be NULL */
 
     /* Called when a the requested latency is changed. Called from IO
      * thread context. */
-    void (*update_requested_latency)(pa_sink *s); /* ditto */
+    pa_sink_cb_t update_requested_latency; /* may be NULL */
 
     /* Called whenever the port shall be changed. Called from main
      * thread. */
@@ -339,6 +357,12 @@ pa_sink* pa_sink_new(
         pa_sink_new_data *data,
         pa_sink_flags_t flags);
 
+void pa_sink_set_get_volume_callback(pa_sink *s, pa_sink_cb_t cb);
+void pa_sink_set_set_volume_callback(pa_sink *s, pa_sink_cb_t cb);
+void pa_sink_set_write_volume_callback(pa_sink *s, pa_sink_cb_t cb);
+void pa_sink_set_get_mute_callback(pa_sink *s, pa_sink_cb_t cb);
+void pa_sink_set_set_mute_callback(pa_sink *s, pa_sink_cb_t cb);
+
 void pa_sink_put(pa_sink *s);
 void pa_sink_unlink(pa_sink* s);
 
index 70248026d059fdc5c8366d014342089b3faaf5c8..1ec80271acbaaae98cf56c92a8ccd9434cd67237 100644 (file)
@@ -381,6 +381,36 @@ static int source_set_state(pa_source *s, pa_source_state_t state) {
     return 0;
 }
 
+void pa_source_set_get_volume_callback(pa_source *s, pa_source_cb_t cb) {
+    pa_assert(s);
+
+    s->get_volume = cb;
+}
+
+void pa_source_set_set_volume_callback(pa_source *s, pa_source_cb_t cb) {
+    pa_assert(s);
+
+    s->set_volume = cb;
+}
+
+void pa_source_set_write_volume_callback(pa_source *s, pa_source_cb_t cb) {
+    pa_assert(s);
+
+    s->write_volume = cb;
+}
+
+void pa_source_set_get_mute_callback(pa_source *s, pa_source_cb_t cb) {
+    pa_assert(s);
+
+    s->get_mute = cb;
+}
+
+void pa_source_set_set_mute_callback(pa_source *s, pa_source_cb_t cb) {
+    pa_assert(s);
+
+    s->set_mute = cb;
+}
+
 /* Called from main context */
 void pa_source_put(pa_source *s) {
     pa_source_assert_ref(s);
index b68dfd59482828887cab6b3f1a343749ce2d3764..52186cdfb3526a34b43f16e75b256191f84c890e 100644 (file)
@@ -53,6 +53,9 @@ static inline pa_bool_t PA_SOURCE_IS_LINKED(pa_source_state_t x) {
     return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE || x == PA_SOURCE_SUSPENDED;
 }
 
+/* A generic definition for void callback functions */
+typedef void(*pa_source_cb_t)(pa_source *s);
+
 struct pa_source {
     pa_msgobject parent;
 
@@ -111,13 +114,19 @@ struct pa_source {
     /* Callled when the volume is queried. Called from main loop
      * context. If this is NULL a PA_SOURCE_MESSAGE_GET_VOLUME message
      * will be sent to the IO thread instead. If refresh_volume is
-     * FALSE neither this function is called nor a message is sent. */
-    void (*get_volume)(pa_source *s);         /* ditto */
+     * FALSE neither this function is called nor a message is sent.
+     *
+     * You must use the function pa_source_set_get_volume_callback() to
+     * set this callback. */
+    pa_source_cb_t get_volume; /* may be NULL */
 
     /* Called when the volume shall be changed. Called from main loop
      * context. If this is NULL a PA_SOURCE_MESSAGE_SET_VOLUME message
-     * will be sent to the IO thread instead. */
-    void (*set_volume)(pa_source *s);         /* ditto */
+     * will be sent to the IO thread instead.
+     *
+     * You must use the function pa_source_set_set_volume_callback() to
+     * set this callback. */
+    pa_source_cb_t set_volume; /* may be NULL */
 
     /* Source drivers that set PA_SOURCE_SYNC_VOLUME must provide this
      * callback. This callback is not used with source that do not set
@@ -129,23 +138,32 @@ struct pa_source {
      * The call is done inside pa_source_volume_change_apply(), which is
      * not called automatically - it is the driver's responsibility to
      * schedule that function to be called at the right times in the
-     * IO thread. */
-    void (*write_volume)(pa_source *s);       /* ditto */
+     * IO thread.
+     *
+     * You must use the function pa_source_set_write_volume_callback() to
+     * set this callback. */
+    pa_source_cb_t write_volume; /* may be NULL */
 
     /* Called when the mute setting is queried. Called from main loop
      * context. If this is NULL a PA_SOURCE_MESSAGE_GET_MUTE message
      * will be sent to the IO thread instead. If refresh_mute is
-     * FALSE neither this function is called nor a message is sent.*/
-    void (*get_mute)(pa_source *s);           /* ditto */
+     * FALSE neither this function is called nor a message is sent.
+     *
+     * You must use the function pa_source_set_get_mute_callback() to
+     * set this callback. */
+    pa_source_cb_t get_mute; /* may be NULL */
 
     /* Called when the mute setting shall be changed. Called from main
      * loop context. If this is NULL a PA_SOURCE_MESSAGE_SET_MUTE
-     * message will be sent to the IO thread instead. */
-    void (*set_mute)(pa_source *s);           /* ditto */
+     * message will be sent to the IO thread instead.
+     *
+     * You must use the function pa_source_set_set_mute_callback() to
+     * set this callback. */
+    pa_source_cb_t set_mute; /* may be NULL */
 
     /* Called when a the requested latency is changed. Called from IO
      * thread context. */
-    void (*update_requested_latency)(pa_source *s); /* ditto */
+    pa_source_cb_t update_requested_latency; /* may be NULL */
 
     /* Called whenever the port shall be changed. Called from main
      * thread. */
@@ -270,6 +288,12 @@ pa_source* pa_source_new(
         pa_source_new_data *data,
         pa_source_flags_t flags);
 
+void pa_source_set_get_volume_callback(pa_source *s, pa_source_cb_t cb);
+void pa_source_set_set_volume_callback(pa_source *s, pa_source_cb_t cb);
+void pa_source_set_write_volume_callback(pa_source *s, pa_source_cb_t cb);
+void pa_source_set_get_mute_callback(pa_source *s, pa_source_cb_t cb);
+void pa_source_set_set_mute_callback(pa_source *s, pa_source_cb_t cb);
+
 void pa_source_put(pa_source *s);
 void pa_source_unlink(pa_source *s);