diff options
-rw-r--r-- | po/.gitignore | 1 | ||||
-rw-r--r-- | po/POTFILES.in | 2 | ||||
-rw-r--r-- | src/.gitignore | 1 | ||||
-rw-r--r-- | src/Makefile.am | 17 | ||||
-rw-r--r-- | src/daemon/.gitignore | 2 | ||||
-rw-r--r-- | src/daemon/org.pulseaudio.policy.in (renamed from src/daemon/org.pulseaudio.policy) | 8 | ||||
-rw-r--r-- | src/daemon/pulseaudio.desktop.in (renamed from src/daemon/pulseaudio.desktop) | 4 | ||||
-rw-r--r-- | src/modules/alsa/alsa-sink.c | 20 | ||||
-rw-r--r-- | src/modules/alsa/alsa-source.c | 20 | ||||
-rw-r--r-- | src/modules/alsa/alsa-util.c | 72 | ||||
-rw-r--r-- | src/modules/alsa/alsa-util.h | 3 | ||||
-rw-r--r-- | src/pulsecore/client.c | 7 | ||||
-rw-r--r-- | src/pulsecore/namereg.c | 6 | ||||
-rw-r--r-- | src/pulsecore/protocol-esound.c | 154 | ||||
-rw-r--r-- | src/pulsecore/sink-input.c | 4 | ||||
-rw-r--r-- | src/pulsecore/source-output.c | 4 |
16 files changed, 254 insertions, 71 deletions
diff --git a/po/.gitignore b/po/.gitignore index 26919828..9a0243ad 100644 --- a/po/.gitignore +++ b/po/.gitignore @@ -1,3 +1,4 @@ +.intltool-merge-cache Makefile.in.in Makevars.template POTFILES diff --git a/po/POTFILES.in b/po/POTFILES.in index 324b9460..0d5b42fb 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -155,6 +155,8 @@ src/daemon/cmdline.c src/daemon/dumpmodules.c src/daemon/daemon-conf.c src/daemon/caps.c +src/daemon/pulseaudio.desktop.in +src/daemon/org.pulseaudio.policy.in src/pulse/channelmap.c src/pulse/error.c src/pulse/proplist.c diff --git a/src/.gitignore b/src/.gitignore index 4da445ba..80d33d36 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,3 +1,4 @@ +alsa-time-test gtk-test prioq-test lock-autospawn-test diff --git a/src/Makefile.am b/src/Makefile.am index 46c3d2ee..4b467f8f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -105,9 +105,9 @@ EXTRA_DIST = \ daemon/start-pulseaudio-x11.in \ utils/padsp \ modules/module-defs.h.m4 \ - daemon/pulseaudio.desktop \ + daemon/pulseaudio.desktop.in \ map-file \ - daemon/org.pulseaudio.policy + daemon/org.pulseaudio.policy.in pulseconf_DATA = \ default.pa \ @@ -116,9 +116,12 @@ pulseconf_DATA = \ client.conf if HAVE_X11 -xdgautostart_DATA = \ - daemon/pulseaudio.desktop +xdgautostart_in_files = \ + daemon/pulseaudio.desktop.in endif +xdgautostart_DATA = $(xdgautostart_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + BUILT_SOURCES = \ pulse/version.h @@ -156,7 +159,9 @@ pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) -dlopen force $(foreach f,$(PRE endif if HAVE_POLKIT -policy_DATA = daemon/org.pulseaudio.policy +policy_in_files = daemon/org.pulseaudio.policy.in +policy_DATA = $(policy_in_files:.policy.in=.policy) +@INTLTOOL_POLICY_RULE@ pulseaudio_SOURCES += daemon/polkit.c daemon/polkit.h pulseaudio_CFLAGS += $(POLKIT_CFLAGS) @@ -1543,7 +1548,7 @@ suid: pulseaudio .libs/lt-pulseaudio chown root $^ chmod u+s $^ -CLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11 +CLEANFILES = esdcompat client.conf default.pa system.pa daemon.conf start-pulseaudio-x11 daemon/pulseaudio.desktop daemon/org.pulseaudio.policy esdcompat: daemon/esdcompat.in Makefile sed -e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \ diff --git a/src/daemon/.gitignore b/src/daemon/.gitignore new file mode 100644 index 00000000..0efa55ba --- /dev/null +++ b/src/daemon/.gitignore @@ -0,0 +1,2 @@ +org.pulseaudio.policy +pulseaudio.desktop diff --git a/src/daemon/org.pulseaudio.policy b/src/daemon/org.pulseaudio.policy.in index 6cdeec68..1d0b6a7d 100644 --- a/src/daemon/org.pulseaudio.policy +++ b/src/daemon/org.pulseaudio.policy.in @@ -28,8 +28,8 @@ USA. <icon_name>audio-card</icon_name> <action id="org.pulseaudio.acquire-real-time"> - <description>Real-time scheduling for the PulseAudio daemon</description> - <message>System policy prevents PulseAudio from acquiring real-time scheduling.</message> + <_description>Real-time scheduling for the PulseAudio daemon</_description> + <_message>System policy prevents PulseAudio from acquiring real-time scheduling.</_message> <defaults> <allow_any>no</allow_any> <allow_inactive>no</allow_inactive> @@ -38,8 +38,8 @@ USA. </action> <action id="org.pulseaudio.acquire-high-priority"> - <description>High-priority scheduling (negative Unix nice level) for the PulseAudio daemon</description> - <message>System policy prevents PulseAudio from acquiring high-priority scheduling.</message> + <_description>High-priority scheduling (negative Unix nice level) for the PulseAudio daemon</_description> + <_message>System policy prevents PulseAudio from acquiring high-priority scheduling.</_message> <defaults> <allow_any>no</allow_any> <allow_inactive>no</allow_inactive> diff --git a/src/daemon/pulseaudio.desktop b/src/daemon/pulseaudio.desktop.in index 57a7a6e4..99bdbd00 100644 --- a/src/daemon/pulseaudio.desktop +++ b/src/daemon/pulseaudio.desktop.in @@ -1,8 +1,8 @@ [Desktop Entry] Version=1.0 Encoding=UTF-8 -Name=PulseAudio Sound System -Comment=Start the PulseAudio Sound System +_Name=PulseAudio Sound System +_Comment=Start the PulseAudio Sound System Exec=start-pulseaudio-x11 Terminal=false Type=Application diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index ef51f1db..d4a54fe6 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -306,9 +306,12 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle if (polled) PA_ONCE_BEGIN { - pa_log(_("ALSA woke us up to write new data to the device, but there was actually nothing to write! " - "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers. " - "We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail_update() returned 0.")); + char *dn = pa_alsa_get_driver_name_by_pcm(u->pcm_handle); + pa_log(_("ALSA woke us up to write new data to the device, but there was actually nothing to write!\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers.\n" + "We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail."), + pa_strnull(dn)); + pa_xfree(dn); } PA_ONCE_END; #ifdef DEBUG_TIMING @@ -435,9 +438,12 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle if (polled) PA_ONCE_BEGIN { - pa_log(_("ALSA woke us up to write new data to the device, but there was actually nothing to write! " - "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers. " - "We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail_update() returned 0.")); + char *dn = pa_alsa_get_driver_name_by_pcm(u->pcm_handle); + pa_log(_("ALSA woke us up to write new data to the device, but there was actually nothing to write!\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers.\n" + "We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail."), + pa_strnull(dn)); + pa_xfree(dn); } PA_ONCE_END; break; @@ -516,7 +522,7 @@ static void update_smoother(struct userdata *u) { /* Let's update the time smoother */ - if (PA_UNLIKELY((err = snd_pcm_delay(u->pcm_handle, &delay)) < 0)) { + if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, &delay, u->hwbuf_size, &u->sink->sample_spec)) < 0)) { pa_log_warn("Failed to query DSP status data: %s", snd_strerror(err)); return; } diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index fbc21f74..f2dad4c5 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -289,9 +289,12 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled if (polled) PA_ONCE_BEGIN { - pa_log(_("ALSA woke us up to read new data from the device, but there was actually nothing to read! " - "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers. " - "We were woken up with POLLIN set -- however a subsequent snd_pcm_avail_update() returned 0.")); + char *dn = pa_alsa_get_driver_name_by_pcm(u->pcm_handle); + pa_log(_("ALSA woke us up to read new data from the device, but there was actually nothing to read!\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers.\n" + "We were woken up with POLLIN set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail."), + pa_strnull(dn)); + pa_xfree(dn); } PA_ONCE_END; #ifdef DEBUG_TIMING @@ -410,9 +413,12 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled if (polled) PA_ONCE_BEGIN { - pa_log(_("ALSA woke us up to read new data from the device, but there was actually nothing to read! " - "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers. " - "We were woken up with POLLIN set -- however a subsequent snd_pcm_avail_update() returned 0.")); + char *dn = pa_alsa_get_driver_name_by_pcm(u->pcm_handle); + pa_log(_("ALSA woke us up to read new data from the device, but there was actually nothing to read!\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers.\n" + "We were woken up with POLLIN set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail."), + pa_strnull(dn)); + pa_xfree(dn); } PA_ONCE_END; break; @@ -486,7 +492,7 @@ static void update_smoother(struct userdata *u) { /* Let's update the time smoother */ - if (PA_UNLIKELY((err = snd_pcm_delay(u->pcm_handle, &delay)) < 0)) { + if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, &delay, u->hwbuf_size, &u->source->sample_spec)) < 0)) { pa_log_warn("Failed to get delay: %s", snd_strerror(err)); return; } diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index 016e52ab..8eedeeb5 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -1578,14 +1578,55 @@ snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa k >= pa_bytes_per_second(ss)*10) PA_ONCE_BEGIN { - pa_log(_("snd_pcm_avail_update() returned a value that is exceptionally large: %lu bytes (%lu ms). " - "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers."), - (unsigned long) k, (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC)); + char *dn = pa_alsa_get_driver_name_by_pcm(pcm); + pa_log(_("snd_pcm_avail() returned a value that is exceptionally large: %lu bytes (%lu ms).\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers."), + (unsigned long) k, + (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC), + pa_strnull(dn)); + pa_xfree(dn); } PA_ONCE_END; return n; } +int pa_alsa_safe_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delay, size_t hwbuf_size, const pa_sample_spec *ss) { + ssize_t k; + size_t abs_k; + int r; + + pa_assert(pcm); + pa_assert(delay); + pa_assert(hwbuf_size > 0); + pa_assert(ss); + + /* Some ALSA driver expose weird bugs, let's inform the user about + * what is going on */ + + if ((r = snd_pcm_delay(pcm, delay)) < 0) + return r; + + k = (ssize_t) *delay * (ssize_t) pa_frame_size(ss); + + abs_k = k >= 0 ? (size_t) k : (size_t) -k; + + if (abs_k >= hwbuf_size * 3 || + abs_k >= pa_bytes_per_second(ss)*10) + + PA_ONCE_BEGIN { + char *dn = pa_alsa_get_driver_name_by_pcm(pcm); + pa_log(_("snd_pcm_delay() returned a value that is exceptionally large: %li bytes (%s%lu ms).\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers."), + (signed long) k, + k < 0 ? "-" : "", + (unsigned long) (pa_bytes_to_usec(abs_k, ss) / PA_USEC_PER_MSEC), + pa_strnull(dn)); + pa_xfree(dn); + } PA_ONCE_END; + + return 0; +} + int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss) { int r; snd_pcm_uframes_t before; @@ -1612,9 +1653,13 @@ int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas k >= pa_bytes_per_second(ss)*10) PA_ONCE_BEGIN { - pa_log(_("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms). " - "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers."), - (unsigned long) k, (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC)); + char *dn = pa_alsa_get_driver_name_by_pcm(pcm); + pa_log(_("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms).\n" + "Most likely this is a bug in the ALSA driver '%s'. Please report this issue to the ALSA developers."), + (unsigned long) k, + (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC), + pa_strnull(dn)); + pa_xfree(dn); } PA_ONCE_END; return r; @@ -1637,3 +1682,18 @@ char *pa_alsa_get_driver_name(int card) { return n; } + +char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm) { + int card; + + snd_pcm_info_t* info; + snd_pcm_info_alloca(&info); + + if (snd_pcm_info(pcm, info) < 0) + return NULL; + + if ((card = snd_pcm_info_get_card(info)) < 0) + return NULL; + + return pa_alsa_get_driver_name(card); +} diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h index 2d0f407e..eddc41b8 100644 --- a/src/modules/alsa/alsa-util.h +++ b/src/modules/alsa/alsa-util.h @@ -129,8 +129,11 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents); pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll); snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss); +int pa_alsa_safe_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delay, size_t hwbuf_size, const pa_sample_spec *ss); int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss); char *pa_alsa_get_driver_name(int card); +char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm); + #endif diff --git a/src/pulsecore/client.c b/src/pulsecore/client.c index 7ca7b97c..e6e8b528 100644 --- a/src/pulsecore/client.c +++ b/src/pulsecore/client.c @@ -132,15 +132,14 @@ void pa_client_set_name(pa_client *c, const char *name) { pa_log_info("Client %u changed name from \"%s\" to \"%s\"", c->index, pa_strnull(pa_proplist_gets(c->proplist, PA_PROP_APPLICATION_NAME)), name); pa_proplist_sets(c->proplist, PA_PROP_APPLICATION_NAME, name); - pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED], c); - pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_CHANGE, c->index); + pa_client_update_proplist(c, 0, NULL); } void pa_client_update_proplist(pa_client *c, pa_update_mode_t mode, pa_proplist *p) { pa_assert(c); - pa_assert(p); - pa_proplist_update(c->proplist, mode, p); + if (p) + pa_proplist_update(c->proplist, mode, p); pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED], c); pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_CHANGE, c->index); diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c index 86bcef74..5ab3036e 100644 --- a/src/pulsecore/namereg.c +++ b/src/pulsecore/namereg.c @@ -194,7 +194,11 @@ void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type) { } - if (!name || *name == '@' || !pa_namereg_is_valid_name(name)) + if (!name) + return NULL; + + if ((type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE || type == PA_NAMEREG_CARD) && + !pa_namereg_is_valid_name(name)) return NULL; if ((e = pa_hashmap_get(c->namereg, name))) diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c index 840f4581..2d4e62fa 100644 --- a/src/pulsecore/protocol-esound.c +++ b/src/pulsecore/protocol-esound.c @@ -34,6 +34,7 @@ #include <pulse/timeval.h> #include <pulse/utf8.h> #include <pulse/xmalloc.h> +#include <pulse/proplist.h> #include <pulsecore/esound.h> #include <pulsecore/memblock.h> @@ -164,10 +165,12 @@ static int esd_proto_get_latency(connection *c, esd_proto_t request, const void static int esd_proto_server_info(connection *c, esd_proto_t request, const void *data, size_t length); static int esd_proto_all_info(connection *c, esd_proto_t request, const void *data, size_t length); static int esd_proto_stream_pan(connection *c, esd_proto_t request, const void *data, size_t length); +static int esd_proto_sample_pan(connection *c, esd_proto_t request, const void *data, size_t length); static int esd_proto_sample_cache(connection *c, esd_proto_t request, const void *data, size_t length); static int esd_proto_sample_free_or_play(connection *c, esd_proto_t request, const void *data, size_t length); static int esd_proto_sample_get_id(connection *c, esd_proto_t request, const void *data, size_t length); static int esd_proto_standby_or_resume(connection *c, esd_proto_t request, const void *data, size_t length); +static int esd_proto_standby_mode(connection *c, esd_proto_t request, const void *data, size_t length); /* the big map of protocol handler info */ static struct proto_handler proto_map[ESD_PROTO_MAX] = { @@ -186,8 +189,8 @@ static struct proto_handler proto_map[ESD_PROTO_MAX] = { { sizeof(int), NULL, "sample stop" }, { (size_t) -1, NULL, "TODO: sample kill" }, - { ESD_KEY_LEN + sizeof(int), esd_proto_standby_or_resume, "standby" }, /* NOOP! */ - { ESD_KEY_LEN + sizeof(int), esd_proto_standby_or_resume, "resume" }, /* NOOP! */ /* 13 */ + { ESD_KEY_LEN + sizeof(int), esd_proto_standby_or_resume, "standby" }, + { ESD_KEY_LEN + sizeof(int), esd_proto_standby_or_resume, "resume" }, /* 13 */ { ESD_NAME_MAX, esd_proto_sample_get_id, "sample getid" }, /* 14 */ { ESD_NAME_MAX + 2 * sizeof(int), NULL, "stream filter" }, @@ -198,9 +201,9 @@ static struct proto_handler proto_map[ESD_PROTO_MAX] = { { (size_t) -1, NULL, "TODO: unsubscribe" }, { 3 * sizeof(int), esd_proto_stream_pan, "stream pan"}, - { 3 * sizeof(int), NULL, "sample pan" }, + { 3 * sizeof(int), esd_proto_sample_pan, "sample pan" }, - { sizeof(int), NULL, "standby mode" }, + { sizeof(int), esd_proto_standby_mode, "standby mode" }, { 0, esd_proto_get_latency, "get latency" } }; @@ -372,6 +375,8 @@ static int esd_proto_connect(connection *c, esd_proto_t request, const void *dat return -1; } + pa_proplist_sets(c->client->proplist, "esound.byte_order", c->swap_byte_order ? "reverse" : "native"); + ok = 1; connection_write(c, &ok, sizeof(int)); return 0; @@ -404,7 +409,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void if (c->options->default_sink) { sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK); - CHECK_VALIDITY(sink, "No such sink: %s", c->options->default_sink); + CHECK_VALIDITY(sink, "No such sink: %s", pa_strnull(c->options->default_sink)); } pa_strlcpy(name, data, sizeof(name)); @@ -489,23 +494,17 @@ static int esd_proto_stream_record(connection *c, esd_proto_t request, const voi if (request == ESD_PROTO_STREAM_MON) { pa_sink* sink; - if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) { - pa_log("no such sink."); - return -1; - } + sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK); + CHECK_VALIDITY(sink, "No such sink: %s", pa_strnull(c->options->default_sink)); - if (!(source = sink->monitor_source)) { - pa_log("no such monitor source."); - return -1; - } + source = sink->monitor_source; + CHECK_VALIDITY(source, "No such source."); } else { pa_assert(request == ESD_PROTO_STREAM_REC); if (c->options->default_source) { - if (!(source = pa_namereg_get(c->protocol->core, c->options->default_source, PA_NAMEREG_SOURCE))) { - pa_log("no such source."); - return -1; - } + source = pa_namereg_get(c->protocol->core, c->options->default_source, PA_NAMEREG_SOURCE); + CHECK_VALIDITY(source, "No such source: %s", pa_strnull(c->options->default_source)); } } @@ -570,7 +569,7 @@ static int esd_proto_get_latency(connection *c, esd_proto_t request, const void if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) latency = 0; else { - double usec = (double) pa_sink_get_latency(sink); + double usec = (double) pa_sink_get_requested_latency(sink); latency = (int) ((usec*44100)/1000000); } @@ -621,7 +620,7 @@ static int esd_proto_all_info(connection *c, esd_proto_t request, const void *da k = sizeof(int32_t)*5+ESD_NAME_MAX; s = sizeof(int32_t)*6+ESD_NAME_MAX; - nsamples = c->protocol->core->scache ? pa_idxset_size(c->protocol->core->scache) : 0; + nsamples = pa_idxset_size(c->protocol->core->scache); t = s*(nsamples+1) + k*(c->protocol->n_player+1); connection_write_prepare(c, t); @@ -641,7 +640,7 @@ static int esd_proto_all_info(connection *c, esd_proto_t request, const void *da pa_cvolume volume = *pa_sink_input_get_volume(conn->sink_input); rate = (int32_t) conn->sink_input->sample_spec.rate; lvolume = (int32_t) ((volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM); - rvolume = (int32_t) ((volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM); + rvolume = (int32_t) ((volume.values[volume.channels == 2 ? 1 : 0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM); format = format_native2esd(&conn->sink_input->sample_spec); } @@ -688,9 +687,26 @@ static int esd_proto_all_info(connection *c, esd_proto_t request, const void *da for (ce = pa_idxset_first(c->protocol->core->scache, &idx); ce; ce = pa_idxset_next(c->protocol->core->scache, &idx)) { int32_t id, rate, lvolume, rvolume, format, len; char name[ESD_NAME_MAX]; + pa_channel_map stereo = { .channels = 2, .map = { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT } }; + pa_cvolume volume; + pa_sample_spec ss; pa_assert(t >= s*2); + if (ce->volume_is_set) { + volume = ce->volume; + pa_cvolume_remap(&volume, &ce->channel_map, &stereo); + } else + pa_cvolume_reset(&volume, 2); + + if (ce->memchunk.memblock) + ss = ce->sample_spec; + else { + ss.format = PA_SAMPLE_S16NE; + ss.rate = 44100; + ss.channels = 2; + } + /* id */ id = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int) (ce->index+1)); connection_write(c, &id, sizeof(int32_t)); @@ -704,19 +720,19 @@ static int esd_proto_all_info(connection *c, esd_proto_t request, const void *da connection_write(c, name, ESD_NAME_MAX); /* rate */ - rate = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ce->sample_spec.rate); + rate = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ss.rate); connection_write(c, &rate, sizeof(int32_t)); /* left */ - lvolume = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ((ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM)); + lvolume = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ((volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM)); connection_write(c, &lvolume, sizeof(int32_t)); /*right*/ - rvolume = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ((ce->volume.values[0]*ESD_VOLUME_BASE)/PA_VOLUME_NORM)); + rvolume = PA_MAYBE_INT32_SWAP(c->swap_byte_order, (int32_t) ((volume.values[1]*ESD_VOLUME_BASE)/PA_VOLUME_NORM)); connection_write(c, &rvolume, sizeof(int32_t)); /*format*/ - format = PA_MAYBE_INT32_SWAP(c->swap_byte_order, format_native2esd(&ce->sample_spec)); + format = PA_MAYBE_INT32_SWAP(c->swap_byte_order, format_native2esd(&ss)); connection_write(c, &format, sizeof(int32_t)); /*length*/ @@ -759,7 +775,8 @@ static int esd_proto_stream_pan(connection *c, esd_proto_t request, const void * pa_cvolume volume; volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; - volume.channels = 2; + volume.channels = conn->sink_input->sample_spec.channels; + pa_sink_input_set_volume(conn->sink_input, &volume, TRUE); ok = 1; } else @@ -770,6 +787,46 @@ static int esd_proto_stream_pan(connection *c, esd_proto_t request, const void * return 0; } +static int esd_proto_sample_pan(connection *c, esd_proto_t request, const void *data, size_t length) { + int32_t ok = 0; + uint32_t idx, lvolume, rvolume; + pa_cvolume volume; + pa_scache_entry *ce; + + connection_assert_ref(c); + pa_assert(data); + pa_assert(length == sizeof(int32_t)*3); + + memcpy(&idx, data, sizeof(uint32_t)); + idx = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, idx) - 1; + data = (const char*)data + sizeof(uint32_t); + + memcpy(&lvolume, data, sizeof(uint32_t)); + lvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, lvolume); + data = (const char*)data + sizeof(uint32_t); + + memcpy(&rvolume, data, sizeof(uint32_t)); + rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume); + data = (const char*)data + sizeof(uint32_t); + + volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; + volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; + volume.channels = 2; + + if ((ce = pa_idxset_get_by_index(c->protocol->core->scache, idx))) { + pa_channel_map stereo = { .channels = 2, .map = { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT } }; + + pa_cvolume_remap(&volume, &stereo, &ce->channel_map); + ce->volume = volume; + ce->volume_is_set = TRUE; + ok = 1; + } + + connection_write(c, &ok, sizeof(int32_t)); + + return 0; +} + static int esd_proto_sample_cache(connection *c, esd_proto_t request, const void *data, size_t length) { pa_sample_spec ss; int32_t format, rate, sc_length; @@ -880,19 +937,47 @@ static int esd_proto_sample_free_or_play(connection *c, esd_proto_t request, con } static int esd_proto_standby_or_resume(connection *c, esd_proto_t request, const void *data, size_t length) { - int32_t ok; + int32_t ok = 1; connection_assert_ref(c); connection_write_prepare(c, sizeof(int32_t) * 2); - - ok = 1; connection_write(c, &ok, sizeof(int32_t)); + + if (request == ESD_PROTO_STANDBY) + ok = pa_sink_suspend_all(c->protocol->core, TRUE) >= 0; + else { + pa_assert(request == ESD_PROTO_RESUME); + ok = pa_sink_suspend_all(c->protocol->core, FALSE) >= 0; + } + connection_write(c, &ok, sizeof(int32_t)); return 0; } +static int esd_proto_standby_mode(connection *c, esd_proto_t request, const void *data, size_t length) { + int32_t mode; + pa_sink *sink, *source; + + connection_assert_ref(c); + + mode = ESM_RUNNING; + + if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) + if (pa_sink_get_state(sink) == PA_SINK_SUSPENDED) + mode = ESM_ON_STANDBY; + + if ((source = pa_namereg_get(c->protocol->core, c->options->default_source, PA_NAMEREG_SOURCE))) + if (pa_source_get_state(source) == PA_SOURCE_SUSPENDED) + mode = ESM_ON_STANDBY; + + mode = PA_MAYBE_INT32_SWAP(c->swap_byte_order, mode); + + connection_write(c, &mode, sizeof(mode)); + return 0; +} + /*** client callbacks ***/ static void client_kill_cb(pa_client *c) { @@ -912,7 +997,13 @@ static int do_read(connection *c) { ssize_t r; pa_assert(c->read_data_length < sizeof(c->request)); - if ((r = pa_iochannel_read(c->io, ((uint8_t*) &c->request) + c->read_data_length, sizeof(c->request) - c->read_data_length)) <= 0) { + if ((r = pa_iochannel_read(c->io, + ((uint8_t*) &c->request) + c->read_data_length, + sizeof(c->request) - c->read_data_length)) <= 0) { + + if (r < 0 && (errno == EINTR || errno == EAGAIN)) + return 0; + pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF"); return -1; } @@ -962,7 +1053,10 @@ static int do_read(connection *c) { pa_assert(c->read_data && c->read_data_length < handler->data_length); - if ((r = pa_iochannel_read(c->io, (uint8_t*) c->read_data + c->read_data_length, handler->data_length - c->read_data_length)) <= 0) { + if ((r = pa_iochannel_read(c->io, + (uint8_t*) c->read_data + c->read_data_length, + handler->data_length - c->read_data_length)) <= 0) { + if (r < 0 && (errno == EINTR || errno == EAGAIN)) return 0; diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 22419ee5..34217c86 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -943,9 +943,9 @@ pa_bool_t pa_sink_input_get_mute(pa_sink_input *i) { /* Called from main thread */ void pa_sink_input_update_proplist(pa_sink_input *i, pa_update_mode_t mode, pa_proplist *p) { pa_sink_input_assert_ref(i); - pa_assert(p); - pa_proplist_update(i->proplist, mode, p); + if (p) + pa_proplist_update(i->proplist, mode, p); if (PA_SINK_IS_LINKED(i->state)) { pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED], i); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 382fb88c..d63aca15 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -618,9 +618,9 @@ void pa_source_output_set_name(pa_source_output *o, const char *name) { /* Called from main thread */ void pa_source_output_update_proplist(pa_source_output *o, pa_update_mode_t mode, pa_proplist *p) { pa_source_output_assert_ref(o); - pa_assert(p); - pa_proplist_update(o->proplist, mode, p); + if (p) + pa_proplist_update(o->proplist, mode, p); if (PA_SINK_IS_LINKED(o->state)) { pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED], o); |