[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test2-116-g998aa40

Lennart Poettering gitmailer-noreply at 0pointer.de
Mon Feb 23 14:55:26 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  e335b3d6cacf5ae961848e28021eb8713865839f (commit)

- Log -----------------------------------------------------------------
998aa40... fix handling of stereo
e0b5507... it's probably more appropriate to return the configured latency instead of the actual latency
385a560... complete esd suspend/resume implementation
2e9479b... implement esd sample panning. closes #428
73c763c... set esound.byte_order property
5fa3f0c... allow scache entries to have arbitrary names
023ba89... use pa_alsa_safe_delay() where appropriate
33601af... print driver name when we encounter driver bugs
557a90c...  add new wrapper pa_alsa_safe_delay() around snd_pcm_delay()
5cc9d97... add new function pa_alsa_get_driver_name_by_pcm()
3bc60ca... a couple of boring updates
3bccb70... Allow passing a NULL proplist to pa_xxxx_update_proplist() to just fire a notification
-----------------------------------------------------------------------

Summary of changes:
 src/modules/alsa/alsa-sink.c    |   20 +++--
 src/modules/alsa/alsa-source.c  |   20 +++--
 src/modules/alsa/alsa-util.c    |   72 +++++++++++++++++--
 src/modules/alsa/alsa-util.h    |    3 +
 src/pulsecore/client.c          |    7 +-
 src/pulsecore/namereg.c         |    6 +-
 src/pulsecore/protocol-esound.c |  154 +++++++++++++++++++++++++++++++--------
 src/pulsecore/sink-input.c      |    4 +-
 src/pulsecore/source-output.c   |    4 +-
 9 files changed, 231 insertions(+), 59 deletions(-)

-----------------------------------------------------------------------

commit 3bccb704b6cc9c1ba0ef2cd3ffb33a49bec039d5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Feb 22 05:01:32 2009 +0100

    Allow passing a NULL proplist to pa_xxxx_update_proplist() to just fire a notification

diff --git a/src/pulsecore/client.c b/src/pulsecore/client.c
index 7ca7b97..e6e8b52 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/sink-input.c b/src/pulsecore/sink-input.c
index 22419ee..34217c8 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 382fb88..d63aca1 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);

commit 3bc60ca78571b2b2b965748997b2019db222405e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Feb 22 05:04:43 2009 +0100

    a couple of boring updates

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 840f458..e8659e6 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -404,7 +404,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 +489,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));
         }
     }
 
@@ -621,7 +615,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);
@@ -912,7 +906,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 +962,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;
 

commit 5cc9d970c83791f5b71b558c438587d5872449f0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 22:54:28 2009 +0100

    add new function pa_alsa_get_driver_name_by_pcm()

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 016e52a..274fef4 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1637,3 +1637,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 2d0f407..92f6797 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -133,4 +133,6 @@ int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas
 
 char *pa_alsa_get_driver_name(int card);
 
+char *pa_alsa_get_driver_name_by_pcm(snd_pcm_t *pcm);
+
 #endif

commit 557a90c487a5b681af6c01309fee89bd203b09c6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 22:55:33 2009 +0100

     add new wrapper pa_alsa_safe_delay() around snd_pcm_delay()

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 274fef4..9be8153 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1586,6 +1586,43 @@ snd_pcm_sframes_t pa_alsa_safe_avail(snd_pcm_t *pcm, size_t hwbuf_size, const pa
     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;
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index 92f6797..eddc41b 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -129,6 +129,7 @@ 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);

commit 33601afbb11b6caba8c2f057839bd234e094175a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 22:56:09 2009 +0100

    print driver name when we encounter driver bugs

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index ef51f1d..6157549 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;
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index fbc21f7..b0b9d9f 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;
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 9be8153..8eedeeb 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1578,9 +1578,13 @@ 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;
@@ -1649,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;

commit 023ba8975be6e3a592ed0e7cd5723b8152dec4a6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 22:56:34 2009 +0100

    use pa_alsa_safe_delay() where appropriate

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 6157549..d4a54fe 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -522,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 b0b9d9f..f2dad4c 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -492,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;
     }

commit 5fa3f0c497363f84294c0faf9945481634415a3b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 22:57:09 2009 +0100

    allow scache entries to have arbitrary names

diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c
index 86bcef7..5ab3036 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)))

commit 73c763cb0820bd9671a291c0a7469332ffe6a380
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 23:49:08 2009 +0100

    set esound.byte_order property

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index e8659e6..3d90306 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>
@@ -372,6 +373,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;

commit 2e9479b1f32517aa1449d35aee135cb791b0f451
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 23:51:29 2009 +0100

    implement esd sample panning. closes #428

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 3d90306..ddecb8f 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -165,6 +165,7 @@ 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);
@@ -199,7 +200,7 @@ 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" },
     { 0,                              esd_proto_get_latency, "get latency" }
@@ -685,9 +686,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));
@@ -701,19 +719,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*/
@@ -767,6 +785,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;

commit 385a560c823c022c9755915e857f079c217f8ee9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 23:51:53 2009 +0100

    complete esd suspend/resume implementation

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index ddecb8f..0e3f564 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -170,6 +170,7 @@ static int esd_proto_sample_cache(connection *c, esd_proto_t request, const void
 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] = {
@@ -188,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" },
@@ -202,7 +203,7 @@ static struct proto_handler proto_map[ESD_PROTO_MAX] = {
     { 3 * sizeof(int),                esd_proto_stream_pan, "stream 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" }
 };
 
@@ -935,19 +936,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) {

commit e0b550710a6d8f5af5209d319de3694243f87b8f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 23:55:05 2009 +0100

    it's probably more appropriate to return the configured latency instead of the actual latency

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 0e3f564..7101aae 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -569,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);
     }
 

commit 998aa40875472c41b74fcecb0eb40c31b690cba7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Feb 23 23:55:16 2009 +0100

    fix handling of stereo

diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 7101aae..2d4e62f 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -640,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);
         }
 
@@ -775,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

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list