[pulseaudio-discuss] [PATCH 01/11] devices: Use wrapper functions to set the *_volume and *_mute callbacks.
Colin Guthrie
colin at mageia.org
Mon Jul 18 03:36:44 PDT 2011
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.
---
src/modules/alsa/alsa-sink.c | 10 ++++----
src/modules/alsa/alsa-source.c | 10 ++++----
src/modules/bluetooth/module-bluetooth-device.c | 8 +++---
src/modules/echo-cancel/module-echo-cancel.c | 12 ++++----
src/modules/module-equalizer-sink.c | 4 +-
src/modules/module-ladspa-sink.c | 4 +-
src/modules/module-solaris.c | 12 ++++----
src/modules/module-tunnel.c | 4 +-
src/modules/module-virtual-sink.c | 4 +-
src/modules/module-virtual-source.c | 4 +-
src/modules/module-waveout.c | 4 +-
src/modules/oss/module-oss.c | 8 +++---
src/modules/raop/module-raop-sink.c | 4 +-
src/pulsecore/sink.c | 30 +++++++++++++++++++++++
src/pulsecore/sink.h | 23 ++++++++++++-----
src/pulsecore/source.c | 30 +++++++++++++++++++++++
src/pulsecore/source.h | 21 +++++++++++----
17 files changed, 135 insertions(+), 57 deletions(-)
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 0164040..98cb75f 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -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.");
}
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index f847b1e..94c14cb 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -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.");
}
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 288ad2f..61600d9 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -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 */
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index a03fa82..cc06d47 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -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);
diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c
index e7d8790..03b166b 100644
--- a/src/modules/module-equalizer-sink.c
+++ b/src/modules/module-equalizer-sink.c
@@ -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);
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 9cce269..aed6270 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -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);
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 0e4e401..ce6af8a 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -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;
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index 4b1ae7d..e7e0871 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -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;
diff --git a/src/modules/module-virtual-sink.c b/src/modules/module-virtual-sink.c
index a6be244..a880df4 100644
--- a/src/modules/module-virtual-sink.c
+++ b/src/modules/module-virtual-sink.c
@@ -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);
diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c
index e15f4b9..f5c5e67 100644
--- a/src/modules/module-virtual-source.c
+++ b/src/modules/module-virtual-source.c
@@ -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);
diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c
index f0710b7..53efce9 100644
--- a/src/modules/module-waveout.c
+++ b/src/modules/module-waveout.c
@@ -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;
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 2a99d11..a22b315 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -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;
}
diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c
index 87e7bc1..2600441 100644
--- a/src/modules/raop/module-raop-sink.c
+++ b/src/modules/raop/module-raop-sink.c
@@ -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);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 45761a6..f7e4b6a 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -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);
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 85c22ec..c725e88 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -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;
@@ -142,7 +145,7 @@ struct pa_sink {
* 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 */
+ 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
@@ -162,7 +165,7 @@ struct pa_sink {
* 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 */
+ 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
@@ -175,26 +178,26 @@ struct pa_sink {
* 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 */
+ 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 */
+ 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 */
+ 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 +342,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);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 7024802..1ec8027 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -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);
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index b68dfd5..dec71a9 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -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;
@@ -112,12 +115,12 @@ struct pa_source {
* 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 */
+ 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 */
+ 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
@@ -130,22 +133,22 @@ struct pa_source {
* 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 */
+ 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 */
+ 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 */
+ 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 +273,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);
--
1.7.6
More information about the pulseaudio-discuss
mailing list