summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am5
-rw-r--r--src/daemon/cmdline.c2
-rw-r--r--src/daemon/daemon-conf.c20
-rw-r--r--src/daemon/main.c2
-rw-r--r--src/modules/alsa/alsa-mixer.c16
-rw-r--r--src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf7
-rw-r--r--src/modules/alsa/mixer/paths/analog-output-mono.conf7
-rw-r--r--src/modules/alsa/mixer/paths/analog-output.conf7
-rw-r--r--src/modules/gconf/module-gconf.c9
-rw-r--r--src/modules/module-combine.c2
-rw-r--r--src/modules/module-ladspa-sink.c72
-rw-r--r--src/modules/module-udev-detect.c158
-rw-r--r--src/pulse/glib-mainloop.h4
-rw-r--r--src/pulse/mainloop.h4
-rw-r--r--src/pulse/thread-mainloop.h4
-rw-r--r--src/pulsecore/core-util.c93
-rw-r--r--src/pulsecore/core-util.h4
-rw-r--r--src/pulsecore/core.c2
-rw-r--r--src/pulsecore/core.h2
-rw-r--r--src/pulsecore/msgobject.c14
-rw-r--r--src/pulsecore/msgobject.h8
-rw-r--r--src/pulsecore/object.c18
-rw-r--r--src/pulsecore/object.h51
-rw-r--r--src/pulsecore/play-memblockq.c3
-rw-r--r--src/pulsecore/protocol-esound.c3
-rw-r--r--src/pulsecore/protocol-native.c15
-rw-r--r--src/pulsecore/protocol-simple.c3
-rw-r--r--src/pulsecore/sink-input.c18
-rw-r--r--src/pulsecore/sink-input.h14
-rw-r--r--src/pulsecore/sink.c18
-rw-r--r--src/pulsecore/sink.h2
-rw-r--r--src/pulsecore/sound-file-stream.c3
-rw-r--r--src/pulsecore/source-output.c2
-rw-r--r--src/pulsecore/source-output.h2
-rw-r--r--src/pulsecore/source.c2
-rw-r--r--src/pulsecore/source.h2
36 files changed, 405 insertions, 193 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 17011cd3..fd440991 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,6 +74,7 @@ AM_CFLAGS = \
$(LIBSAMPLERATE_CFLAGS) \
$(LIBSNDFILE_CFLAGS) \
$(LIBSPEEX_CFLAGS) \
+ -DPA_BUILDDIR=\"$(abs_builddir)\" \
-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
-DPA_BINARY=\"$(PA_BINARY)\" \
@@ -83,8 +84,8 @@ AM_CFLAGS = \
-DAO_REQUIRE_CAS \
-DPULSE_LOCALEDIR=\"$(pulselocaledir)\" \
-DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\" \
- -DPA_ALSA_PATHS_DIR=\"$(alsapathsdir)\" \
- -DPA_ALSA_PROFILE_SETS_DIR=\"$(alsaprofilesetsdir)\"
+ -DPA_ALSA_PATHS_DIR=\"$(alsapathsdir)\" \
+ -DPA_ALSA_PROFILE_SETS_DIR=\"$(alsaprofilesetsdir)\"
AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)
diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
index ecb38486..3ebc9270 100644
--- a/src/daemon/cmdline.c
+++ b/src/daemon/cmdline.c
@@ -385,7 +385,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
pa_xfree(conf->script_commands);
conf->script_commands = pa_strbuf_tostring_free(buf);
- if (!conf->script_commands) {
+ if (conf->script_commands) {
pa_xfree(conf->script_commands);
conf->script_commands = NULL;
}
diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index 9a87b555..ec1ec5ce 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -133,9 +133,25 @@ static const pa_daemon_conf default_conf = {
};
pa_daemon_conf* pa_daemon_conf_new(void) {
- pa_daemon_conf *c = pa_xnewdup(pa_daemon_conf, &default_conf, 1);
+ pa_daemon_conf *c;
+
+ c = pa_xnewdup(pa_daemon_conf, &default_conf, 1);
+
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+
+ /* We abuse __OPTIMIZE__ as a check whether we are a debug build
+ * or not. If we are and are run from the build tree then we
+ * override the search path to point to our build tree */
+
+ if (pa_run_from_build_tree()) {
+ pa_log_notice("Detected that we are run from the build tree, fixing search path.");
+ c->dl_search_path = pa_xstrdup(PA_BUILDDIR "/.libs/");
+
+ } else
+
+#endif
+ c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
- c->dl_search_path = pa_xstrdup(PA_DLSEARCHPATH);
return c;
}
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 8521e720..72984590 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -774,6 +774,8 @@ int main(int argc, char *argv[]) {
pa_log_info(_("Using state directory %s."), s);
pa_xfree(s);
+ pa_log_info(_("Using modules directory %s."), conf->dl_search_path);
+
pa_log_info(_("Running in system mode: %s"), pa_yes_no(pa_in_system_mode()));
if (pa_in_system_mode())
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index a4c2ee0f..61c92cd0 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -929,7 +929,7 @@ static int element_zero_volume(pa_alsa_element *e, snd_mixer_t *m) {
int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m) {
pa_alsa_element *e;
- int r;
+ int r = 0;
pa_assert(m);
pa_assert(p);
@@ -1849,7 +1849,12 @@ pa_alsa_path* pa_alsa_path_new(const char *fname, pa_alsa_direction_t direction)
items[1].data = &p->description;
items[2].data = &p->name;
- fn = pa_maybe_prefix_path(fname, PA_ALSA_PATHS_DIR);
+ fn = pa_maybe_prefix_path(fname,
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+ pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/paths/" :
+#endif
+ PA_ALSA_PATHS_DIR);
+
r = pa_config_parse(fn, NULL, items, p);
pa_xfree(fn);
@@ -3110,7 +3115,12 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
if (!fname)
fname = "default.conf";
- fn = pa_maybe_prefix_path(fname, PA_ALSA_PROFILE_SETS_DIR);
+ fn = pa_maybe_prefix_path(fname,
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+ pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/profile-sets/" :
+#endif
+ PA_ALSA_PROFILE_SETS_DIR);
+
r = pa_config_parse(fn, NULL, items, ps);
pa_xfree(fn);
diff --git a/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf b/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf
index 2db976a5..3457d4a2 100644
--- a/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf
@@ -41,9 +41,12 @@ volume = merge
override-map.1 = lfe
override-map.2 = lfe,lfe
+; This profile path is intended to control the speaker, not the
+; headphones. But it should not hurt if we leave the headphone jack
+; enabled nonetheless.
[Element Headphone]
-switch = off
-volume = off
+switch = mute
+volume = zero
[Element Speaker]
switch = mute
diff --git a/src/modules/alsa/mixer/paths/analog-output-mono.conf b/src/modules/alsa/mixer/paths/analog-output-mono.conf
index a58cc970..dc270cfe 100644
--- a/src/modules/alsa/mixer/paths/analog-output-mono.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-mono.conf
@@ -38,9 +38,12 @@ volume = merge
override-map.1 = all
override-map.2 = all-left,all-right
+; This profile path is intended to control the speaker, not the
+; headphones. But it should not hurt if we leave the headphone jack
+; enabled nonetheless.
[Element Headphone]
-switch = off
-volume = off
+switch = mute
+volume = zero
[Element Speaker]
switch = mute
diff --git a/src/modules/alsa/mixer/paths/analog-output.conf b/src/modules/alsa/mixer/paths/analog-output.conf
index b412a437..f71a05a1 100644
--- a/src/modules/alsa/mixer/paths/analog-output.conf
+++ b/src/modules/alsa/mixer/paths/analog-output.conf
@@ -37,9 +37,12 @@ override-map.2 = all-left,all-right
switch = off
volume = off
+; This profile path is intended to control the speaker, not the
+; headphones. But it should not hurt if we leave the headphone jack
+; enabled nonetheless.
[Element Headphone]
-switch = off
-volume = off
+switch = mute
+volume = zero
[Element Speaker]
switch = mute
diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c
index c01ebbf6..85523b39 100644
--- a/src/modules/gconf/module-gconf.c
+++ b/src/modules/gconf/module-gconf.c
@@ -52,9 +52,6 @@ PA_MODULE_LOAD_ONCE(TRUE);
#define MAX_MODULES 10
#define BUF_MAX 2048
-/* #undef PA_GCONF_HELPER */
-/* #define PA_GCONF_HELPER "/home/lennart/projects/pulseaudio/src/gconf-helper" */
-
struct module_item {
char *name;
char *args;
@@ -343,7 +340,11 @@ int pa__init(pa_module*m) {
u->io_event = NULL;
u->buf_fill = 0;
- if ((u->fd = pa_start_child_for_read(PA_GCONF_HELPER, NULL, &u->pid)) < 0)
+ if ((u->fd = pa_start_child_for_read(
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+ pa_run_from_build_tree() ? PA_BUILDDIR "/.libs/gconf-helper" :
+#endif
+ PA_GCONF_HELPER, NULL, &u->pid)) < 0)
goto fail;
u->io_event = m->core->mainloop->io_new(
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 582cbce1..e90ef11c 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -1161,6 +1161,8 @@ int pa__init(pa_module*m) {
pa_channel_map slaves_map;
pa_bool_t is_first_slave = TRUE;
+ pa_sample_spec_init(&slaves_spec);
+
while ((n = pa_split(slaves, ",", &split_state))) {
pa_sink *slave_sink;
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index f2d53d00..233f90c4 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -99,7 +99,7 @@ static const char* const valid_modargs[] = {
};
/* Called from I/O thread context */
-static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
+static int sink_process_msg_cb(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
struct userdata *u = PA_SINK(o)->userdata;
switch (code) {
@@ -130,7 +130,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
}
/* Called from main context */
-static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
+static int sink_set_state_cb(pa_sink *s, pa_sink_state_t state) {
struct userdata *u;
pa_sink_assert_ref(s);
@@ -145,7 +145,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
}
/* Called from I/O thread context */
-static void sink_request_rewind(pa_sink *s) {
+static void sink_request_rewind_cb(pa_sink *s) {
struct userdata *u;
pa_sink_assert_ref(s);
@@ -160,7 +160,7 @@ static void sink_request_rewind(pa_sink *s) {
}
/* Called from I/O thread context */
-static void sink_update_requested_latency(pa_sink *s) {
+static void sink_update_requested_latency_cb(pa_sink *s) {
struct userdata *u;
pa_sink_assert_ref(s);
@@ -176,6 +176,34 @@ static void sink_update_requested_latency(pa_sink *s) {
pa_sink_get_requested_latency_within_thread(s));
}
+/* Called from main context */
+static void sink_set_volume_cb(pa_sink *s) {
+ struct userdata *u;
+
+ pa_sink_assert_ref(s);
+ pa_assert_se(u = s->userdata);
+
+ if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+ return;
+
+ pa_sink_input_set_volume(u->sink_input, &s->real_volume, s->save_volume, TRUE);
+}
+
+/* Called from main context */
+static void sink_set_mute_cb(pa_sink *s) {
+ struct userdata *u;
+
+ pa_sink_assert_ref(s);
+ pa_assert_se(u = s->userdata);
+
+ if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+ return;
+
+ pa_sink_input_set_mute(u->sink_input, s->muted, s->save_muted);
+}
+
/* Called from I/O thread context */
static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk) {
struct userdata *u;
@@ -394,6 +422,26 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
pa_sink_update_flags(u->sink, PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY, dest->flags);
}
+/* Called from main context */
+static void sink_input_volume_changed_cb(pa_sink_input *i) {
+ struct userdata *u;
+
+ pa_sink_input_assert_ref(i);
+ pa_assert_se(u = i->userdata);
+
+ pa_sink_volume_changed(u->sink, &i->volume);
+}
+
+/* Called from main context */
+static void sink_input_mute_changed_cb(pa_sink_input *i) {
+ struct userdata *u;
+
+ pa_sink_input_assert_ref(i);
+ pa_assert_se(u = i->userdata);
+
+ pa_sink_mute_changed(u->sink, i->muted);
+}
+
int pa__init(pa_module*m) {
struct userdata *u;
pa_sample_spec ss;
@@ -731,7 +779,9 @@ int pa__init(pa_module*m) {
goto fail;
}
- u->sink = pa_sink_new(m->core, &sink_data, master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY));
+ u->sink = pa_sink_new(m->core, &sink_data,
+ PA_SINK_HW_MUTE_CTRL|PA_SINK_HW_VOLUME_CTRL|PA_SINK_DECIBEL_VOLUME|
+ (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
pa_sink_new_data_done(&sink_data);
if (!u->sink) {
@@ -739,10 +789,12 @@ int pa__init(pa_module*m) {
goto fail;
}
- u->sink->parent.process_msg = sink_process_msg;
- u->sink->set_state = sink_set_state;
- u->sink->update_requested_latency = sink_update_requested_latency;
- u->sink->request_rewind = sink_request_rewind;
+ u->sink->parent.process_msg = sink_process_msg_cb;
+ 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;
u->sink->userdata = u;
pa_sink_set_asyncmsgq(u->sink, master->asyncmsgq);
@@ -775,6 +827,8 @@ int pa__init(pa_module*m) {
u->sink_input->state_change = sink_input_state_change_cb;
u->sink_input->may_move_to = sink_input_may_move_to_cb;
u->sink_input->moving = sink_input_moving_cb;
+ u->sink_input->volume_changed = sink_input_volume_changed_cb;
+ u->sink_input->mute_changed = sink_input_mute_changed_cb;
u->sink_input->userdata = u;
pa_sink_put(u->sink);
diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 0b30fd54..1d67c0cc 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -45,8 +45,10 @@ PA_MODULE_USAGE(
struct device {
char *path;
- pa_bool_t accessible;
+ pa_bool_t accessible:1;
+ pa_bool_t need_verify:1;
char *card_name;
+ char *args;
uint32_t module;
};
@@ -78,6 +80,7 @@ static void device_free(struct device *d) {
pa_xfree(d->path);
pa_xfree(d->card_name);
+ pa_xfree(d->args);
pa_xfree(d);
}
@@ -103,23 +106,43 @@ static void verify_access(struct userdata *u, struct device *d) {
pa_assert(u);
pa_assert(d);
- if (!(card = pa_namereg_get(u->core, d->card_name, PA_NAMEREG_CARD)))
- return;
-
cd = pa_sprintf_malloc("%s/snd/controlC%s", udev_get_dev_path(u->udev), path_get_card_id(d->path));
- d->accessible = access(cd, W_OK) >= 0;
+ d->accessible = access(cd, R_OK|W_OK) >= 0;
+
pa_log_info("%s is accessible: %s", cd, pa_yes_no(d->accessible));
pa_xfree(cd);
- pa_card_suspend(card, !d->accessible, PA_SUSPEND_SESSION);
+ if (d->module == PA_INVALID_INDEX) {
+
+ /* If we not loaded, try to load */
+
+ if (d->accessible) {
+ pa_module *m;
+
+ pa_log_debug("Loading module-alsa-card with arguments '%s'", d->args);
+ m = pa_module_load(u->core, "module-alsa-card", d->args);
+
+ if (m) {
+ d->module = m->index;
+ pa_log_info("Card %s (%s) module loaded.", d->path, d->card_name);
+ } else
+ pa_log_info("Card %s (%s) failed to load module.", d->path, d->card_name);
+ }
+
+ } else {
+
+ /* If we are already loaded update suspend status with
+ * accessible boolean */
+
+ if ((card = pa_namereg_get(u->core, d->card_name, PA_NAMEREG_CARD)))
+ pa_card_suspend(card, !d->accessible, PA_SUSPEND_SESSION);
+ }
}
static void card_changed(struct userdata *u, struct udev_device *dev) {
struct device *d;
const char *path;
const char *t;
- char *card_name, *args;
- pa_module *m;
char *n;
pa_assert(u);
@@ -135,44 +158,34 @@ static void card_changed(struct userdata *u, struct udev_device *dev) {
return;
}
+ d = pa_xnew0(struct device, 1);
+ d->path = pa_xstrdup(path);
+ d->accessible = TRUE;
+ d->module = PA_INVALID_INDEX;
+
if (!(t = udev_device_get_property_value(dev, "PULSE_NAME")))
if (!(t = udev_device_get_property_value(dev, "ID_ID")))
if (!(t = udev_device_get_property_value(dev, "ID_PATH")))
t = path_get_card_id(path);
n = pa_namereg_make_valid_name(t);
+ d->card_name = pa_sprintf_malloc("alsa_card.%s", n);
+ d->args = pa_sprintf_malloc("device_id=\"%s\" "
+ "name=\"%s\" "
+ "card_name=\"%s\" "
+ "tsched=%s "
+ "ignore_dB=%s "
+ "card_properties=\"module-udev-detect.discovered=1\"",
+ path_get_card_id(path),
+ n,
+ d->card_name,
+ pa_yes_no(u->use_tsched),
+ pa_yes_no(u->ignore_dB));
+ pa_xfree(n);
- card_name = pa_sprintf_malloc("alsa_card.%s", n);
- args = pa_sprintf_malloc("device_id=\"%s\" "
- "name=\"%s\" "
- "card_name=\"%s\" "
- "tsched=%s "
- "ignore_dB=%s "
- "card_properties=\"module-udev-detect.discovered=1\"",
- path_get_card_id(path),
- n,
- card_name,
- pa_yes_no(u->use_tsched),
- pa_yes_no(u->ignore_dB));
-
- pa_log_debug("Loading module-alsa-card with arguments '%s'", args);
- m = pa_module_load(u->core, "module-alsa-card", args);
- pa_xfree(args);
-
- if (m) {
- pa_log_info("Card %s (%s) added.", path, n);
-
- d = pa_xnew(struct device, 1);
- d->path = pa_xstrdup(path);
- d->card_name = card_name;
- d->module = m->index;
- d->accessible = TRUE;
-
- pa_hashmap_put(u->devices, d->path, d);
- } else
- pa_xfree(card_name);
+ pa_hashmap_put(u->devices, d->path, d);
- pa_xfree(n);
+ verify_access(u, d);
}
static void remove_card(struct userdata *u, struct udev_device *dev) {
@@ -185,7 +198,10 @@ static void remove_card(struct userdata *u, struct udev_device *dev) {
return;
pa_log_info("Card %s removed.", d->path);
- pa_module_unload_request_by_index(u->core, d->module, TRUE);
+
+ if (d->module != PA_INVALID_INDEX)
+ pa_module_unload_request_by_index(u->core, d->module, TRUE);
+
device_free(d);
}
@@ -262,6 +278,34 @@ fail:
u->udev_io = NULL;
}
+static pa_bool_t pcm_node_belongs_to_device(
+ struct device *d,
+ const char *node) {
+
+ char *cd;
+ pa_bool_t b;
+
+ cd = pa_sprintf_malloc("pcmC%sD", path_get_card_id(d->path));
+ b = pa_startswith(node, cd);
+ pa_xfree(cd);
+
+ return b;
+}
+
+static pa_bool_t control_node_belongs_to_device(
+ struct device *d,
+ const char *node) {
+
+ char *cd;
+ pa_bool_t b;
+
+ cd = pa_sprintf_malloc("controlC%s", path_get_card_id(d->path));
+ b = pa_streq(node, cd);
+ pa_xfree(cd);
+
+ return b;
+}
+
static void inotify_cb(
pa_mainloop_api*a,
pa_io_event* e,
@@ -275,7 +319,9 @@ static void inotify_cb(
} buf;
struct userdata *u = userdata;
static int type = 0;
- pa_bool_t verify = FALSE, deleted = FALSE;
+ pa_bool_t deleted = FALSE;
+ struct device *d;
+ void *state;
for (;;) {
ssize_t r;
@@ -290,22 +336,30 @@ static void inotify_cb(
goto fail;
}
- if ((buf.e.mask & IN_CLOSE_WRITE) && pa_startswith(buf.e.name, "pcmC"))
- verify = TRUE;
+ /* From udev we get the guarantee that the control
+ * device's ACL is changes last. To avoid races when ACLs
+ * are changed we hence watch only the control device */
+ if (((buf.e.mask & IN_ATTRIB) && pa_startswith(buf.e.name, "controlC")))
+ PA_HASHMAP_FOREACH(d, u->devices, state)
+ if (control_node_belongs_to_device(d, buf.e.name))
+ d->need_verify = TRUE;
+
+ /* ALSA doesn't really give us any guarantee on the closing
+ * order, so let's simply hope */
+ if (((buf.e.mask & IN_CLOSE_WRITE) && pa_startswith(buf.e.name, "pcmC")))
+ PA_HASHMAP_FOREACH(d, u->devices, state)
+ if (pcm_node_belongs_to_device(d, buf.e.name))
+ d->need_verify = TRUE;
if ((buf.e.mask & (IN_DELETE_SELF|IN_MOVE_SELF)))
deleted = TRUE;
}
- if (verify) {
- struct device *d;
- void *state;
-
- pa_log_debug("Verifying access.");
-
- PA_HASHMAP_FOREACH(d, u->devices, state)
+ PA_HASHMAP_FOREACH(d, u->devices, state)
+ if (d->need_verify) {
+ d->need_verify = FALSE;
verify_access(u, d);
- }
+ }
if (!deleted)
return;
@@ -335,7 +389,7 @@ static int setup_inotify(struct userdata *u) {
}
dev_snd = pa_sprintf_malloc("%s/snd", udev_get_dev_path(u->udev));
- r = inotify_add_watch(u->inotify_fd, dev_snd, IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF);
+ r = inotify_add_watch(u->inotify_fd, dev_snd, IN_ATTRIB|IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF);
pa_xfree(dev_snd);
if (r < 0) {
@@ -449,7 +503,7 @@ int pa__init(pa_module *m) {
udev_enumerate_unref(enumerate);
- pa_log_info("Loaded %u modules.", pa_hashmap_size(u->devices));
+ pa_log_info("Found %u cards.", pa_hashmap_size(u->devices));
pa_modargs_free(ma);
diff --git a/src/pulse/glib-mainloop.h b/src/pulse/glib-mainloop.h
index 189513a8..67aba27d 100644
--- a/src/pulse/glib-mainloop.h
+++ b/src/pulse/glib-mainloop.h
@@ -56,7 +56,9 @@ pa_glib_mainloop *pa_glib_mainloop_new(GMainContext *c);
/** Free the GLIB main loop object */
void pa_glib_mainloop_free(pa_glib_mainloop* g);
-/** Return the abstract main loop API vtable for the GLIB main loop object */
+/** Return the abstract main loop API vtable for the GLIB main loop
+ object. No need of freeing the API as it is owned by the loop and
+ it is destroyed when this dies */
pa_mainloop_api* pa_glib_mainloop_get_api(pa_glib_mainloop *g);
PA_C_DECL_END
diff --git a/src/pulse/mainloop.h b/src/pulse/mainloop.h
index 4a83ebe8..63abd588 100644
--- a/src/pulse/mainloop.h
+++ b/src/pulse/mainloop.h
@@ -108,7 +108,9 @@ int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval);
/** Run unlimited iterations of the main loop object until the main loop's quit() routine is called. */
int pa_mainloop_run(pa_mainloop *m, int *retval);
-/** Return the abstract main loop abstraction layer vtable for this main loop. */
+/** Return the abstract main loop abstraction layer vtable for this
+ main loop. No need of freeing the API as it is owned by the loop
+ and it is destroyed when this dies */
pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m);
/** Shutdown the main loop */
diff --git a/src/pulse/thread-mainloop.h b/src/pulse/thread-mainloop.h
index e847070d..2cf496e1 100644
--- a/src/pulse/thread-mainloop.h
+++ b/src/pulse/thread-mainloop.h
@@ -299,7 +299,9 @@ void pa_threaded_mainloop_accept(pa_threaded_mainloop *m);
/** Return the return value as specified with the main loop's quit() routine. */
int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m);
-/** Return the abstract main loop abstraction layer vtable for this main loop. */
+/** Return the abstract main loop abstraction layer vtable for this
+ main loop. No need of freeing the API as it is owned by the loop
+ and it is destroyed when this dies */
pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m);
/** Returns non-zero when called from withing the event loop thread. \since 0.9.7 */
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 6494244e..843c8377 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -975,6 +975,7 @@ static int is_group(gid_t gid, const char *name) {
int r = -1;
#ifdef HAVE_GETGRGID_R
+
#ifdef _SC_GETGR_R_SIZE_MAX
n = sysconf(_SC_GETGR_R_SIZE_MAX);
#else
@@ -985,38 +986,25 @@ static int is_group(gid_t gid, const char *name) {
data = pa_xmalloc((size_t) n);
+ if ((errno = getgrgid_r(gid, &group, data, (size_t) n, &result)) || !result)
+#else
errno = 0;
- if (getgrgid_r(gid, &group, data, (size_t) n, &result) < 0 || !result) {
- pa_log("getgrgid_r(%u): %s", (unsigned) gid, pa_cstrerror(errno));
-
+ if (!(result = getgrgid(gid)))
+#endif
+ {
if (!errno)
errno = ENOENT;
- goto finish;
- }
-
- r = strcmp(name, result->gr_name) == 0;
-
-finish:
- pa_xfree(data);
-#else
- /* XXX Not thread-safe, but needed on OSes (e.g. FreeBSD 4.X) that do not
- * support getgrgid_r. */
-
- errno = 0;
- if (!(result = getgrgid(gid))) {
pa_log("getgrgid(%u): %s", gid, pa_cstrerror(errno));
- if (!errno)
- errno = ENOENT;
-
goto finish;
}
r = strcmp(name, result->gr_name) == 0;
finish:
-#endif
+
+ pa_xfree(data);
return r;
}
@@ -1065,12 +1053,14 @@ finish:
/* Check whether the specifc user id is a member of the specified group */
int pa_uid_in_group(uid_t uid, const char *name) {
- char *g_buf, *p_buf;
+ char *g_buf = NULL, *p_buf = NULL;
long g_n, p_n;
- struct group grbuf, *gr;
+ struct group grbuf, *gr = NULL;
char **i;
int r = -1;
+#ifdef HAVE_GETGRNAM_R
+
#ifdef _SC_GETGR_R_SIZE_MAX
g_n = sysconf(_SC_GETGR_R_SIZE_MAX);
#else
@@ -1081,6 +1071,19 @@ int pa_uid_in_group(uid_t uid, const char *name) {
g_buf = pa_xmalloc((size_t) g_n);
+ if ((errno = getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr)) != 0 || !gr)
+#else
+ errno = 0;
+ if (!(gr = getgrnam(name)))
+#endif
+ {
+ if (!errno)
+ errno = ENOENT;
+ goto finish;
+ }
+
+#ifdef HAVE_GETPWNAM_R
+
#ifdef _SC_GETPW_R_SIZE_MAX
p_n = sysconf(_SC_GETPW_R_SIZE_MAX);
#else
@@ -1090,26 +1093,16 @@ int pa_uid_in_group(uid_t uid, const char *name) {
p_n = 512;
p_buf = pa_xmalloc((size_t) p_n);
-
- errno = 0;
-#ifdef HAVE_GETGRNAM_R
- if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr)
-#else
- if (!(gr = getgrnam(name)))
#endif
- {
- if (!errno)
- errno = ENOENT;
- goto finish;
- }
r = 0;
for (i = gr->gr_mem; *i; i++) {
- struct passwd pwbuf, *pw;
+ struct passwd pwbuf, *pw = NULL;
#ifdef HAVE_GETPWNAM_R
- if (getpwnam_r(*i, &pwbuf, p_buf, (size_t) p_n, &pw) != 0 || !pw)
+ if ((errno = getpwnam_r(*i, &pwbuf, p_buf, (size_t) p_n, &pw)) != 0 || !pw)
#else
+ errno = 0;
if (!(pw = getpwnam(*i)))
#endif
continue;
@@ -1130,9 +1123,11 @@ finish:
/* Get the GID of a gfiven group, return (gid_t) -1 on failure. */
gid_t pa_get_gid_of_group(const char *name) {
gid_t ret = (gid_t) -1;
- char *g_buf;
+ char *g_buf = NULL;
long g_n;
- struct group grbuf, *gr;
+ struct group grbuf, *gr = NULL;
+
+#ifdef HAVE_GETGRNAM_R
#ifdef _SC_GETGR_R_SIZE_MAX
g_n = sysconf(_SC_GETGR_R_SIZE_MAX);
@@ -1144,10 +1139,9 @@ gid_t pa_get_gid_of_group(const char *name) {
g_buf = pa_xmalloc((size_t) g_n);
- errno = 0;
-#ifdef HAVE_GETGRNAM_R
- if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr)
+ if ((errno = getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr)) != 0 || !gr)
#else
+ errno = 0;
if (!(gr = getgrnam(name)))
#endif
{
@@ -2868,3 +2862,22 @@ void pa_reset_personality(void) {
#endif
}
+
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+
+pa_bool_t pa_run_from_build_tree(void) {
+ char *rp;
+ pa_bool_t b = FALSE;
+
+ /* We abuse __OPTIMIZE__ as a check whether we are a debug build
+ * or not. */
+
+ if ((rp = pa_readlink("/proc/self/exe"))) {
+ b = pa_startswith(rp, PA_BUILDDIR);
+ pa_xfree(rp);
+ }
+
+ return b;
+}
+
+#endif
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 3d3aec71..2551f794 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -243,4 +243,8 @@ size_t pa_pipe_buf(int fd);
void pa_reset_personality(void);
+#if defined(__linux__) && !defined(__OPTIMIZE__)
+pa_bool_t pa_run_from_build_tree(void);
+#endif
+
#endif
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index f5eb8352..f0726453 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -47,7 +47,7 @@
#include "core.h"
-static PA_DEFINE_CHECK_TYPE(pa_core, pa_msgobject);
+PA_DEFINE_PUBLIC_CLASS(pa_core, pa_msgobject);
static int core_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk) {
pa_core *c = PA_CORE(o);
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index f6ec7122..c1002f93 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -165,7 +165,7 @@ struct pa_core {
pa_hook hooks[PA_CORE_HOOK_MAX];
};
-PA_DECLARE_CLASS(pa_core);
+PA_DECLARE_PUBLIC_CLASS(pa_core);
#define PA_CORE(o) pa_core_cast(o)
enum {
diff --git a/src/pulsecore/msgobject.c b/src/pulsecore/msgobject.c
index 6a2a612d..075a28c5 100644
--- a/src/pulsecore/msgobject.c
+++ b/src/pulsecore/msgobject.c
@@ -26,22 +26,22 @@
#include "msgobject.h"
-PA_DEFINE_CHECK_TYPE(pa_msgobject, pa_object);
+PA_DEFINE_PUBLIC_CLASS(pa_msgobject, pa_object);
-pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_name, int (*check_type)(const char *type_name)) {
+pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_id, pa_bool_t (*check_type)(const char *type_name)) {
pa_msgobject *o;
pa_assert(size > sizeof(pa_msgobject));
- pa_assert(type_name);
+ pa_assert(type_id);
if (!check_type)
check_type = pa_msgobject_check_type;
- pa_assert(check_type(type_name));
- pa_assert(check_type("pa_object"));
- pa_assert(check_type("pa_msgobject"));
+ pa_assert(check_type(type_id));
+ pa_assert(check_type(pa_object_type_id));
+ pa_assert(check_type(pa_msgobject_type_id));
- o = PA_MSGOBJECT(pa_object_new_internal(size, type_name, check_type));
+ o = PA_MSGOBJECT(pa_object_new_internal(size, type_id, check_type));
o->process_msg = NULL;
return o;
}
diff --git a/src/pulsecore/msgobject.h b/src/pulsecore/msgobject.h
index a35a23b5..ee0ec1ed 100644
--- a/src/pulsecore/msgobject.h
+++ b/src/pulsecore/msgobject.h
@@ -38,15 +38,13 @@ struct pa_msgobject {
int (*process_msg)(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk);
};
-pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_name, int (*check_type)(const char *type_name));
+pa_msgobject *pa_msgobject_new_internal(size_t size, const char *type_id, pa_bool_t (*check_type)(const char *type_name));
-int pa_msgobject_check_type(const char *type);
-
-#define pa_msgobject_new(type) ((type*) pa_msgobject_new_internal(sizeof(type), #type, type##_check_type))
+#define pa_msgobject_new(type) ((type*) pa_msgobject_new_internal(sizeof(type), type##_type_id, type##_check_type))
#define pa_msgobject_free ((void (*) (pa_msgobject* o)) pa_object_free)
#define PA_MSGOBJECT(o) pa_msgobject_cast(o)
-PA_DECLARE_CLASS(pa_msgobject);
+PA_DECLARE_PUBLIC_CLASS(pa_msgobject);
#endif
diff --git a/src/pulsecore/object.c b/src/pulsecore/object.c
index f3ead9c5..099d50d9 100644
--- a/src/pulsecore/object.c
+++ b/src/pulsecore/object.c
@@ -28,21 +28,23 @@
#include "object.h"
-pa_object *pa_object_new_internal(size_t size, const char *type_name, int (*check_type)(const char *type_name)) {
+const char pa_object_type_id[] = "pa_object";
+
+pa_object *pa_object_new_internal(size_t size, const char *type_id, pa_bool_t (*check_type)(const char *type_id)) {
pa_object *o;
pa_assert(size > sizeof(pa_object));
- pa_assert(type_name);
+ pa_assert(type_id);
if (!check_type)
check_type = pa_object_check_type;
- pa_assert(check_type(type_name));
- pa_assert(check_type("pa_object"));
+ pa_assert(check_type(type_id));
+ pa_assert(check_type(pa_object_type_id));
o = pa_xmalloc(size);
PA_REFCNT_INIT(o);
- o->type_name = type_name;
+ o->type_id = type_id;
o->free = pa_object_free;
o->check_type = check_type;
@@ -65,8 +67,8 @@ void pa_object_unref(pa_object *o) {
}
}
-int pa_object_check_type(const char *type_name) {
- pa_assert(type_name);
+pa_bool_t pa_object_check_type(const char *type_id) {
+ pa_assert(type_id);
- return pa_streq(type_name, "pa_object");
+ return type_id == pa_object_type_id;
}
diff --git a/src/pulsecore/object.h b/src/pulsecore/object.h
index 43e79327..4c120cd5 100644
--- a/src/pulsecore/object.h
+++ b/src/pulsecore/object.h
@@ -34,21 +34,23 @@ typedef struct pa_object pa_object;
struct pa_object {
PA_REFCNT_DECLARE;
- const char *type_name;
+ const char *type_id;
void (*free)(pa_object *o);
- int (*check_type)(const char *type_name);
+ pa_bool_t (*check_type)(const char *type_name);
};
-pa_object *pa_object_new_internal(size_t size, const char *type_name, int (*check_type)(const char *type_name));
-#define pa_object_new(type) ((type*) pa_object_new_internal(sizeof(type), #type, type##_check_type)
+pa_object *pa_object_new_internal(size_t size, const char *type_id, pa_bool_t (*check_type)(const char *type_id));
+#define pa_object_new(type) ((type*) pa_object_new_internal(sizeof(type), type##_type_id, type##_check_type)
#define pa_object_free ((void (*) (pa_object* _obj)) pa_xfree)
-int pa_object_check_type(const char *type);
+pa_bool_t pa_object_check_type(const char *type_id);
-static inline int pa_object_isinstance(void *o) {
+extern const char pa_object_type_id[];
+
+static inline pa_bool_t pa_object_isinstance(void *o) {
pa_object *obj = (pa_object*) o;
- return obj ? obj->check_type("pa_object") : 0;
+ return obj ? obj->check_type(pa_object_type_id) : TRUE;
}
pa_object *pa_object_ref(pa_object *o);
@@ -60,7 +62,7 @@ static inline int pa_object_refcnt(pa_object *o) {
static inline pa_object* pa_object_cast(void *o) {
pa_object *obj = (pa_object*) o;
- pa_assert(!obj || obj->check_type("pa_object"));
+ pa_assert(!obj || obj->check_type(pa_object_type_id));
return obj;
}
@@ -68,10 +70,10 @@ static inline pa_object* pa_object_cast(void *o) {
#define PA_OBJECT(o) pa_object_cast(o)
-#define PA_DECLARE_CLASS(c) \
- static inline int c##_isinstance(void *o) { \
+#define PA_DECLARE_CLASS_COMMON(c) \
+ static inline pa_bool_t c##_isinstance(void *o) { \
pa_object *obj = (pa_object*) o; \
- return obj ? obj->check_type(#c) : 1; \
+ return obj ? obj->check_type(c##_type_id) : TRUE; \
} \
static inline c* c##_cast(void *o) { \
pa_assert(c##_isinstance(o)); \
@@ -91,12 +93,27 @@ static inline pa_object* pa_object_cast(void *o) {
} \
struct __stupid_useless_struct_to_allow_trailing_semicolon
-#define PA_DEFINE_CHECK_TYPE(c, parent) \
- int c##_check_type(const char *type) { \
- pa_assert(type); \
- if (strcmp(type, #c) == 0) \
- return 1; \
- return parent##_check_type(type); \
+#define PA_DECLARE_PUBLIC_CLASS(c) \
+ extern const char c##_type_id[]; \
+ PA_DECLARE_CLASS_COMMON(c); \
+ pa_bool_t c##_check_type(const char *type_id)
+
+#define PA_DEFINE_PUBLIC_CLASS(c, parent) \
+ const char c##_type_id[] = #c; \
+ pa_bool_t c##_check_type(const char *type_id) { \
+ if (type_id == c##_type_id) \
+ return TRUE; \
+ return parent##_check_type(type_id); \
+ } \
+ struct __stupid_useless_struct_to_allow_trailing_semicolon
+
+#define PA_DEFINE_PRIVATE_CLASS(c, parent) \
+ static const char c##_type_id[] = #c; \
+ PA_DECLARE_CLASS_COMMON(c); \
+ static pa_bool_t c##_check_type(const char *type_id) { \
+ if (type_id == c##_type_id) \
+ return TRUE; \
+ return parent##_check_type(type_id); \
} \
struct __stupid_useless_struct_to_allow_trailing_semicolon
diff --git a/src/pulsecore/play-memblockq.c b/src/pulsecore/play-memblockq.c
index fceb2ca1..b0d76993 100644
--- a/src/pulsecore/play-memblockq.c
+++ b/src/pulsecore/play-memblockq.c
@@ -47,9 +47,8 @@ enum {
MEMBLOCKQ_STREAM_MESSAGE_UNLINK,
};
-PA_DECLARE_CLASS(memblockq_stream);
+PA_DEFINE_PRIVATE_CLASS(memblockq_stream, pa_msgobject);
#define MEMBLOCKQ_STREAM(o) (memblockq_stream_cast(o))
-static PA_DEFINE_CHECK_TYPE(memblockq_stream, pa_msgobject);
static void memblockq_stream_unlink(memblockq_stream *u) {
pa_assert(u);
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index f64552aa..cfbaee6f 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -120,9 +120,8 @@ typedef struct connection {
pa_time_event *auth_timeout_event;
} connection;
-PA_DECLARE_CLASS(connection);
+PA_DEFINE_PRIVATE_CLASS(connection, pa_msgobject);
#define CONNECTION(o) (connection_cast(o))
-static PA_DEFINE_CHECK_TYPE(connection, pa_msgobject);
struct pa_esound_protocol {
PA_REFCNT_DECLARE;
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index b1285e15..6678d847 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -98,17 +98,15 @@ typedef struct record_stream {
pa_usec_t current_source_latency;
} record_stream;
-PA_DECLARE_CLASS(record_stream);
#define RECORD_STREAM(o) (record_stream_cast(o))
-static PA_DEFINE_CHECK_TYPE(record_stream, pa_msgobject);
+PA_DEFINE_PRIVATE_CLASS(record_stream, pa_msgobject);
typedef struct output_stream {
pa_msgobject parent;
} output_stream;
-PA_DECLARE_CLASS(output_stream);
#define OUTPUT_STREAM(o) (output_stream_cast(o))
-static PA_DEFINE_CHECK_TYPE(output_stream, pa_msgobject);
+PA_DEFINE_PRIVATE_CLASS(output_stream, pa_msgobject);
typedef struct playback_stream {
output_stream parent;
@@ -138,9 +136,8 @@ typedef struct playback_stream {
uint64_t playing_for, underrun_for;
} playback_stream;
-PA_DECLARE_CLASS(playback_stream);
#define PLAYBACK_STREAM(o) (playback_stream_cast(o))
-static PA_DEFINE_CHECK_TYPE(playback_stream, output_stream);
+PA_DEFINE_PRIVATE_CLASS(playback_stream, output_stream);
typedef struct upload_stream {
output_stream parent;
@@ -156,9 +153,8 @@ typedef struct upload_stream {
pa_proplist *proplist;
} upload_stream;
-PA_DECLARE_CLASS(upload_stream);
#define UPLOAD_STREAM(o) (upload_stream_cast(o))
-static PA_DEFINE_CHECK_TYPE(upload_stream, output_stream);
+PA_DEFINE_PRIVATE_CLASS(upload_stream, output_stream);
struct pa_native_connection {
pa_msgobject parent;
@@ -176,9 +172,8 @@ struct pa_native_connection {
pa_time_event *auth_timeout_event;
};
-PA_DECLARE_CLASS(pa_native_connection);
#define PA_NATIVE_CONNECTION(o) (pa_native_connection_cast(o))
-static PA_DEFINE_CHECK_TYPE(pa_native_connection, pa_msgobject);
+PA_DEFINE_PRIVATE_CLASS(pa_native_connection, pa_msgobject);
struct pa_native_protocol {
PA_REFCNT_DECLARE;
diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c
index 776d74b6..95ec6ac8 100644
--- a/src/pulsecore/protocol-simple.c
+++ b/src/pulsecore/protocol-simple.c
@@ -69,9 +69,8 @@ typedef struct connection {
} playback;
} connection;
-PA_DECLARE_CLASS(connection);
+PA_DEFINE_PRIVATE_CLASS(connection, pa_msgobject);
#define CONNECTION(o) (connection_cast(o))
-static PA_DEFINE_CHECK_TYPE(connection, pa_msgobject);
struct pa_simple_protocol {
PA_REFCNT_DECLARE;
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index a29334f9..4137a425 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -44,7 +44,7 @@
#define MEMBLOCKQ_MAXLENGTH (32*1024*1024)
#define CONVERT_BUFFER_LENGTH (PA_PAGE_SIZE)
-static PA_DEFINE_CHECK_TYPE(pa_sink_input, pa_msgobject);
+PA_DEFINE_PUBLIC_CLASS(pa_sink_input, pa_msgobject);
static void sink_input_free(pa_object *o);
static void set_real_ratio(pa_sink_input *i, const pa_cvolume *v);
@@ -126,6 +126,8 @@ static void reset_callbacks(pa_sink_input *i) {
i->state_change = NULL;
i->may_move_to = NULL;
i->send_event = NULL;
+ i->volume_changed = NULL;
+ i->mute_changed = NULL;
}
/* Called from main context */
@@ -968,7 +970,10 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_boo
pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME, NULL, 0, NULL) == 0);
}
- /* The virtual volume changed, let's tell people so */
+ /* The volume changed, let's tell people so */
+ if (i->volume_changed)
+ i->volume_changed(i);
+
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
}
@@ -999,6 +1004,11 @@ void pa_sink_input_set_mute(pa_sink_input *i, pa_bool_t mute, pa_bool_t save) {
i->save_muted = save;
pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_SOFT_MUTE, NULL, 0, NULL) == 0);
+
+ /* The mute status changed, let's tell people so */
+ if (i->mute_changed)
+ i->mute_changed(i);
+
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
}
@@ -1263,6 +1273,10 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
/* Notify everyone */
pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], i);
+
+ if (i->volume_changed)
+ i->volume_changed(i);
+
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
return 0;
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index ea0f8c0e..fe6cf75c 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -192,8 +192,16 @@ struct pa_sink_input {
pa_bool_t (*may_move_to) (pa_sink_input *i, pa_sink *s); /* may be NULL */
/* If non-NULL this function is used to dispatch asynchronous
- * control events. */
- void (*send_event)(pa_sink_input *i, const char *event, pa_proplist* data);
+ * control events. Called from main context. */
+ void (*send_event)(pa_sink_input *i, const char *event, pa_proplist* data); /* may be NULL */
+
+ /* If non-NULL this function is called whenever the sink input
+ * volume changes. Called from main context */
+ void (*volume_changed)(pa_sink_input *i); /* may be NULL */
+
+ /* If non-NULL this function is called whenever the sink input
+ * mute status changes. Called from main context */
+ void (*mute_changed)(pa_sink_input *i); /* may be NULL */
struct {
pa_sink_input_state_t state;
@@ -227,7 +235,7 @@ struct pa_sink_input {
void *userdata;
};
-PA_DECLARE_CLASS(pa_sink_input);
+PA_DECLARE_PUBLIC_CLASS(pa_sink_input);
#define PA_SINK_INPUT(o) pa_sink_input_cast(o)
enum {
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 1cce8e6b..5cec7747 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -52,7 +52,7 @@
#define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC)
#define DEFAULT_FIXED_LATENCY (250*PA_USEC_PER_MSEC)
-static PA_DEFINE_CHECK_TYPE(pa_sink, pa_msgobject);
+PA_DEFINE_PUBLIC_CLASS(pa_sink, pa_msgobject);
static void sink_free(pa_object *s);
@@ -1380,9 +1380,14 @@ static void propagate_reference_volume(pa_sink *s) {
pa_cvolume_remap(&remapped, &s->channel_map, &i->channel_map);
pa_sw_cvolume_multiply(&i->volume, &remapped, &i->reference_ratio);
- /* The reference volume changed, let's tell people so */
- if (!pa_cvolume_equal(&old_volume, &i->volume))
+ /* The volume changed, let's tell people so */
+ if (!pa_cvolume_equal(&old_volume, &i->volume)) {
+
+ if (i->volume_changed)
+ i->volume_changed(i);
+
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+ }
}
}
@@ -1522,8 +1527,13 @@ static void propagate_real_volume(pa_sink *s, const pa_cvolume *old_real_volume)
pa_sw_cvolume_multiply(&i->volume, &remapped, &i->reference_ratio);
/* Notify if something changed */
- if (!pa_cvolume_equal(&old_volume, &i->volume))
+ if (!pa_cvolume_equal(&old_volume, &i->volume)) {
+
+ if (i->volume_changed)
+ i->volume_changed(i);
+
pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+ }
}
}
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 936d1c2a..b5284b71 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -191,7 +191,7 @@ struct pa_sink {
void *userdata;
};
-PA_DECLARE_CLASS(pa_sink);
+PA_DECLARE_PUBLIC_CLASS(pa_sink);
#define PA_SINK(s) (pa_sink_cast(s))
typedef enum pa_sink_message {
diff --git a/src/pulsecore/sound-file-stream.c b/src/pulsecore/sound-file-stream.c
index 502e5c69..f41c53f3 100644
--- a/src/pulsecore/sound-file-stream.c
+++ b/src/pulsecore/sound-file-stream.c
@@ -64,9 +64,8 @@ enum {
FILE_STREAM_MESSAGE_UNLINK
};
-PA_DECLARE_CLASS(file_stream);
+PA_DEFINE_PRIVATE_CLASS(file_stream, pa_msgobject);
#define FILE_STREAM(o) (file_stream_cast(o))
-static PA_DEFINE_CHECK_TYPE(file_stream, pa_msgobject);
/* Called from main context */
static void file_stream_unlink(file_stream *u) {
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 3803a6cc..b0298616 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -41,7 +41,7 @@
#define MEMBLOCKQ_MAXLENGTH (32*1024*1024)
-static PA_DEFINE_CHECK_TYPE(pa_source_output, pa_msgobject);
+PA_DEFINE_PUBLIC_CLASS(pa_source_output, pa_msgobject);
static void source_output_free(pa_object* mo);
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index a70a3fdb..aca9ddf2 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -182,7 +182,7 @@ struct pa_source_output {
void *userdata;
};
-PA_DECLARE_CLASS(pa_source_output);
+PA_DECLARE_PUBLIC_CLASS(pa_source_output);
#define PA_SOURCE_OUTPUT(o) pa_source_output_cast(o)
enum {
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 8aa07f5e..3026654e 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -46,7 +46,7 @@
#define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC)
#define DEFAULT_FIXED_LATENCY (250*PA_USEC_PER_MSEC)
-static PA_DEFINE_CHECK_TYPE(pa_source, pa_msgobject);
+PA_DEFINE_PUBLIC_CLASS(pa_source, pa_msgobject);
static void source_free(pa_object *o);
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 7b3e4953..df3f99df 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -158,7 +158,7 @@ struct pa_source {
void *userdata;
};
-PA_DECLARE_CLASS(pa_source);
+PA_DECLARE_PUBLIC_CLASS(pa_source);
#define PA_SOURCE(s) pa_source_cast(s)
typedef enum pa_source_message {