[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-270-g4d4956e

Lennart Poettering gitmailer-noreply at 0pointer.de
Thu Jan 15 14:47:37 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  d4bda31ba12e66ebd246daf0d928f7a6d259022d (commit)

- Log -----------------------------------------------------------------
4d4956e... Add SPDIF/HDMI ALSA devices and device descriptions to device search table
33c22b0... rename card config to card profile
-----------------------------------------------------------------------

Summary of changes:
 src/modules/alsa/alsa-util.c          |  223 +++++++++++++++++++++++----------
 src/modules/alsa/alsa-util.h          |    4 +-
 src/modules/alsa/module-alsa-sink.c   |   11 ++-
 src/modules/alsa/module-alsa-source.c |   11 ++-
 src/pulse/proplist.h                  |    8 +-
 src/pulsecore/card.c                  |   50 ++++----
 src/pulsecore/card.h                  |   20 ++--
 7 files changed, 219 insertions(+), 108 deletions(-)

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

commit 33c22b01022b0450aee011ddd9d6d2b19da74191
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 15 23:44:46 2009 +0100

    rename card config to card profile

diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 03b9ebd..99c0cc5 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -36,18 +36,18 @@
 
 #include "card.h"
 
-pa_card_config *pa_card_config_new(const char *name) {
-    pa_card_config *c;
+pa_card_profile *pa_card_profile_new(const char *name) {
+    pa_card_profile *c;
 
     pa_assert(name);
 
-    c = pa_xnew0(pa_card_config, 1);
+    c = pa_xnew0(pa_card_profile, 1);
     c->name = pa_xstrdup(name);
 
     return c;
 }
 
-void pa_card_config_free(pa_card_config *c) {
+void pa_card_profile_free(pa_card_profile *c) {
     pa_assert(c);
 
     pa_xfree(c->name);
@@ -76,13 +76,13 @@ void pa_card_new_data_done(pa_card_new_data *data) {
 
     pa_proplist_free(data->proplist);
 
-    if (data->configs) {
-        pa_card_config *c;
+    if (data->profiles) {
+        pa_card_profile *c;
 
-        while ((c = pa_hashmap_steal_first(data->configs)))
-            pa_card_config_free(c);
+        while ((c = pa_hashmap_steal_first(data->profiles)))
+            pa_card_profile_free(c);
 
-        pa_hashmap_free(data->configs, NULL, NULL);
+        pa_hashmap_free(data->profiles, NULL, NULL);
     }
 
     pa_xfree(data->name);
@@ -120,13 +120,13 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
     c->sinks = pa_idxset_new(NULL, NULL);
     c->sources = pa_idxset_new(NULL, NULL);
 
-    c->configs = data->configs;
-    data->configs = NULL;
-    c->active_config = data->active_config;
-    data->active_config = NULL;
+    c->profiles = data->profiles;
+    data->profiles = NULL;
+    c->active_profile = data->active_profile;
+    data->active_profile = NULL;
 
     c->userdata = NULL;
-    c->set_config = NULL;
+    c->set_profile = NULL;
 
     pa_assert_se(pa_idxset_put(core->cards, c, &c->index) >= 0);
 
@@ -139,7 +139,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
 
 void pa_card_free(pa_card *c) {
     pa_core *core;
-    pa_card_config *config;
+    pa_card_profile *profile;
 
     pa_assert(c);
     pa_assert(c->core);
@@ -161,10 +161,10 @@ void pa_card_free(pa_card *c) {
     pa_assert(pa_idxset_isempty(c->sources));
     pa_idxset_free(c->sources, NULL, NULL);
 
-    while ((config = pa_hashmap_steal_first(c->configs)))
-        pa_card_config_free(config);
+    while ((profile = pa_hashmap_steal_first(c->profiles)))
+        pa_card_profile_free(profile);
 
-    pa_hashmap_free(c->configs, NULL, NULL);
+    pa_hashmap_free(c->profiles, NULL, NULL);
 
     pa_proplist_free(c->proplist);
     pa_xfree(c->driver);
@@ -174,22 +174,22 @@ void pa_card_free(pa_card *c) {
     pa_core_check_idle(core);
 }
 
-int pa_card_set_config(pa_card *c, const char *name) {
-    pa_card_config *config;
+int pa_card_set_profile(pa_card *c, const char *name) {
+    pa_card_profile *profile;
     pa_assert(c);
 
-    if (!c->set_config) {
-        pa_log_warn("set_config() operation not implemented for card %u", c->index);
+    if (!c->set_profile) {
+        pa_log_warn("set_profile() operation not implemented for card %u", c->index);
         return -1;
     }
 
-    if (!c->configs)
+    if (!c->profiles)
         return -1;
 
-    if (!(config = pa_hashmap_get(c->configs, name)))
+    if (!(profile = pa_hashmap_get(c->profiles, name)))
         return -1;
 
-    if (c->set_config(c, config) < 0)
+    if (c->set_profile(c, profile) < 0)
         return -1;
 
     pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index 40e4a3e..e32e880 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -29,7 +29,7 @@ typedef struct pa_card pa_card;
 #include <pulsecore/module.h>
 #include <pulsecore/idxset.h>
 
-typedef struct pa_card_config {
+typedef struct pa_card_profile {
     char *name;
 
     pa_bool_t optical_sink:1;
@@ -40,7 +40,7 @@ typedef struct pa_card_config {
 
     unsigned max_sink_channels;
     unsigned max_source_channels;
-} pa_card_config;
+} pa_card_profile;
 
 struct pa_card {
     uint32_t index;
@@ -55,12 +55,12 @@ struct pa_card {
     pa_idxset *sinks;
     pa_idxset *sources;
 
-    pa_hashmap *configs;
-    pa_card_config *active_config;
+    pa_hashmap *profiles;
+    pa_card_profile *active_profile;
 
     void *userdata;
 
-    int (*set_config)(pa_card *c, pa_card_config *config);
+    int (*set_profile)(pa_card *c, pa_card_profile *profile);
 };
 
 typedef struct pa_card_new_data {
@@ -70,14 +70,14 @@ typedef struct pa_card_new_data {
     const char *driver;
     pa_module *module;
 
-    pa_hashmap *configs;
-    pa_card_config *active_config;
+    pa_hashmap *profiles;
+    pa_card_profile *active_profile;
 
     pa_bool_t namereg_fail:1;
 } pa_card_new_data;
 
-pa_card_config *pa_card_config_new(const char *name);
-void pa_card_config_free(pa_card_config *c);
+pa_card_profile *pa_card_profile_new(const char *name);
+void pa_card_profile_free(pa_card_profile *c);
 
 pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data);
 void pa_card_new_data_set_name(pa_card_new_data *data, const char *name);
@@ -86,6 +86,6 @@ void pa_card_new_data_done(pa_card_new_data *data);
 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
 void pa_card_free(pa_card *c);
 
-int pa_card_set_config(pa_card *c, const char *name);
+int pa_card_set_profile(pa_card *c, const char *name);
 
 #endif

commit 4d4956ea2f8df5f770f2137d8576afc6e5f161dd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 15 23:46:42 2009 +0100

    Add SPDIF/HDMI ALSA devices and device descriptions to device search table

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index ff3af19..871471f 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -474,33 +474,81 @@ int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min) {
 
 struct device_info {
     pa_channel_map map;
+    const char *alsa_name;
+    const char *description;
     const char *name;
 };
 
 static const struct device_info device_table[] = {
-    {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT } }, "front" },
+    {{ 1, { PA_CHANNEL_POSITION_MONO }},
+     "hw",
+     "Analog Mono",
+     "analog-mono" },
+
+    {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
+     "front",
+     "Analog Stereo",
+     "analog-stereo" },
+
+    {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
+     "iec958",
+     "IEC958 Digital Stereo",
+     "iec958-stereo" },
+
+    {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
+     "hdmi",
+     "HDMI Digital Stereo",
+     "hdmi-stereo"},
 
     {{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
-            PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }}, "surround40" },
+            PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
+     "surround40",
+     "Analog Surround 4.0",
+     "analog-surround-40" },
+
+    {{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
+            PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
+     "a52",
+     "IEC958/AC3 Digital Surround 4.0",
+     "iec958-ac3-surround-40" },
 
     {{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
             PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
-            PA_CHANNEL_POSITION_LFE }}, "surround41" },
+            PA_CHANNEL_POSITION_LFE }},
+     "surround41",
+     "Analog Surround 4.1",
+     "analog-surround-41"},
 
     {{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
             PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
-            PA_CHANNEL_POSITION_CENTER }}, "surround50" },
+            PA_CHANNEL_POSITION_CENTER }},
+     "surround50",
+     "Analog Surround 5.0",
+     "analog-surround-50" },
 
     {{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
             PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
-            PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE }}, "surround51" },
+            PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE }},
+     "surround51",
+     "Analog Surround 5.1",
+     "analog-surround-51" },
+
+    {{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_CENTER,
+            PA_CHANNEL_POSITION_FRONT_RIGHT, PA_CHANNEL_POSITION_REAR_LEFT,
+            PA_CHANNEL_POSITION_REAR_RIGHT, PA_CHANNEL_POSITION_LFE}},
+     "a52",
+     "IEC958/AC3 Digital Surround 5.1",
+     "iec958-ac3-surround-51" },
 
     {{ 8, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
             PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
             PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE,
-            PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT }} , "surround71" },
+            PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT }},
+     "surround71",
+     "Analog Surround 7.1",
+     "analog-surround-71" },
 
-    {{ 0, { 0 }}, NULL }
+    {{ 0, { 0 }}, NULL, NULL, NULL }
 };
 
 static pa_bool_t channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) {
@@ -532,7 +580,9 @@ snd_pcm_t *pa_alsa_open_by_device_id(
         snd_pcm_uframes_t *period_size,
         snd_pcm_uframes_t tsched_size,
         pa_bool_t *use_mmap,
-        pa_bool_t *use_tsched) {
+        pa_bool_t *use_tsched,
+        const char**config_description,
+        const char **config_name) {
 
     int i;
     int direction = 1;
@@ -554,90 +604,122 @@ snd_pcm_t *pa_alsa_open_by_device_id(
      * way, we iterate backwards, and check all devices that do not
      * provide a superset of the requested channel map.*/
 
-    for (i = 0;; i += direction) {
+    i = 0;
+    for (;;) {
         pa_sample_spec try_ss;
         pa_bool_t reformat;
 
-        if (i < 0) {
-            pa_assert(direction == -1);
-
-            /* OK, so we iterated backwards, and now are at the
-             * beginning of our list. */
+        if ((direction > 0) == channel_map_superset(&device_table[i].map, map)) {
+            pa_log_debug("Checking for %s (%s)", device_table[i].name, device_table[i].alsa_name);
 
-            break;
+            d = pa_sprintf_malloc("%s:%s", device_table[i].alsa_name, dev_id);
 
-        } else if (!device_table[i].name) {
-            pa_assert(direction == 1);
+            reformat = FALSE;
+            for (;;) {
+                pa_log_debug("Trying %s %s SND_PCM_NO_AUTO_FORMAT ...", d, reformat ? "without" : "with");
 
-            /* OK, so we are at the end of our list. at iterated
-             * forwards. */
+                /* We don't pass SND_PCM_NONBLOCK here, since alsa-lib <=
+                 * 1.0.17a would then ignore the SND_PCM_NO_xxx
+                 * flags. Instead we enable nonblock mode afterwards via
+                 * snd_pcm_nonblock(). Also see
+                 * http://mailman.alsa-project.org/pipermail/alsa-devel/2008-August/010258.html */
 
-            i--;
-            direction = -1;
-        }
+                if ((err = snd_pcm_open(&pcm_handle, d, mode,
+                                        /* SND_PCM_NONBLOCK| */
+                                        SND_PCM_NO_AUTO_RESAMPLE|
+                                        SND_PCM_NO_AUTO_CHANNELS|
+                                        (reformat ? 0 : SND_PCM_NO_AUTO_FORMAT))) < 0) {
+                    pa_log_info("Couldn't open PCM device %s: %s", d, snd_strerror(err));
+                    break;
+                }
 
-        if ((direction > 0) == !channel_map_superset(&device_table[i].map, map))
-            continue;
+                try_ss.channels = device_table[i].map.channels;
+                try_ss.rate = ss->rate;
+                try_ss.format = ss->format;
 
-        d = pa_sprintf_malloc("%s:%s", device_table[i].name, dev_id);
+                if ((err = pa_alsa_set_hw_params(pcm_handle, &try_ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, TRUE)) < 0) {
 
-        reformat = FALSE;
-        for (;;) {
-            pa_log_debug("Trying %s %s SND_PCM_NO_AUTO_FORMAT ...", d, reformat ? "without" : "with");
+                    if (!reformat) {
+                        reformat = TRUE;
+                        snd_pcm_close(pcm_handle);
+                        continue;
+                    }
 
-            /* We don't pass SND_PCM_NONBLOCK here, since alsa-lib <=
-             * 1.0.17a would then ignore the SND_PCM_NO_xxx
-             * flags. Instead we enable nonblock mode afterwards via
-             * snd_pcm_nonblock(). Also see
-             * http://mailman.alsa-project.org/pipermail/alsa-devel/2008-August/010258.html */
+                    if (!pa_startswith(d, "plug:") && !pa_startswith(d, "plughw:")) {
+                        char *t;
 
-            if ((err = snd_pcm_open(&pcm_handle, d, mode,
-                                    /* SND_PCM_NONBLOCK| */
-                                    SND_PCM_NO_AUTO_RESAMPLE|
-                                    SND_PCM_NO_AUTO_CHANNELS|
-                                    (reformat ? 0 : SND_PCM_NO_AUTO_FORMAT))) < 0) {
-                pa_log_info("Couldn't open PCM device %s: %s", d, snd_strerror(err));
-                break;
-            }
+                        t = pa_sprintf_malloc("plug:%s", d);
+                        pa_xfree(d);
+                        d = t;
 
-            try_ss.channels = device_table[i].map.channels;
-            try_ss.rate = ss->rate;
-            try_ss.format = ss->format;
+                        reformat = FALSE;
 
-            if ((err = pa_alsa_set_hw_params(pcm_handle, &try_ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, TRUE)) < 0) {
+                        snd_pcm_close(pcm_handle);
+                        continue;
+                    }
 
-                if (!reformat) {
-                    reformat = TRUE;
+                    pa_log_info("PCM device %s refused our hw parameters: %s", d, snd_strerror(err));
                     snd_pcm_close(pcm_handle);
-                    continue;
+                    break;
                 }
 
-                if (!pa_startswith(d, "plug:") && !pa_startswith(d, "plughw:")) {
-                    char *t;
-
-                    t = pa_sprintf_malloc("plug:%s", d);
-                    pa_xfree(d);
-                    d = t;
+                *ss = try_ss;
+                *map = device_table[i].map;
+                pa_assert(map->channels == ss->channels);
+                *dev = d;
+                if (config_description)
+                    *config_description = device_table[i].description;
+                if (config_name)
+                    *config_name = device_table[i].name;
 
-                    reformat = FALSE;
+                return pcm_handle;
+            }
 
-                    snd_pcm_close(pcm_handle);
-                    continue;
-                }
+            pa_xfree(d);
+        }
 
-                pa_log_info("PCM device %s refused our hw parameters: %s", d, snd_strerror(err));
-                snd_pcm_close(pcm_handle);
-                break;
+        if (direction > 0) {
+            if (!device_table[i+1].alsa_name) {
+                /* OK, so we are at the end of our list. Let's turn
+                 * back. */
+                direction = -1;
+            } else {
+                /* We are not at the end of the list, so let's simply
+                 * try the next entry */
+                i++;
             }
-
-            *ss = try_ss;
-            *map = device_table[i].map;
-            pa_assert(map->channels == ss->channels);
-            *dev = d;
-            return pcm_handle;
         }
 
-        pa_xfree(d);
+        if (direction < 0) {
+
+            if (device_table[i+1].alsa_name &&
+                device_table[i].map.channels == device_table[i+1].map.channels) {
+
+                /* OK, the next entry has the same number of channels,
+                 * let's try it */
+                i++;
+
+            } else {
+                /* Hmm, so the next entry does not have the same
+                 * number of channels, so let's go backwards until we
+                 * find the next entry with a differnt number of
+                 * channels */
+
+                for (i--; i >= 0; i--)
+                    if (device_table[i].map.channels != device_table[i+1].map.channels)
+                        break;
+
+                /* Hmm, there is no entry with a different number of
+                 * entries, then we're done */
+                if (i < 0)
+                    break;
+
+                /* OK, now lets find go back as long as we have the same number of channels */
+                for (; i > 0; i--)
+                    if (device_table[i].map.channels != device_table[i-1].map.channels)
+                        break;
+            }
+        }
     }
 
     /* OK, we didn't find any good device, so let's try the raw plughw: stuff */
@@ -647,6 +729,11 @@ snd_pcm_t *pa_alsa_open_by_device_id(
     pcm_handle = pa_alsa_open_by_device_string(d, dev, ss, map, mode, nfrags, period_size, tsched_size, use_mmap, use_tsched);
     pa_xfree(d);
 
+    if (pcm_handle) {
+        *config_description = NULL;
+        *config_name = NULL;
+    }
+
     return pcm_handle;
 }
 
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index 95bb983..ce5f0eb 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -64,7 +64,9 @@ snd_pcm_t *pa_alsa_open_by_device_id(
         snd_pcm_uframes_t *period_size,
         snd_pcm_uframes_t tsched_size,
         pa_bool_t *use_mmap,
-        pa_bool_t *use_tsched);
+        pa_bool_t *use_tsched,
+        const char **config_name,
+        const char **config_description);
 
 snd_pcm_t *pa_alsa_open_by_device_string(
         const char *device,
diff --git a/src/modules/alsa/module-alsa-sink.c b/src/modules/alsa/module-alsa-sink.c
index a3e818d..dfa2055 100644
--- a/src/modules/alsa/module-alsa-sink.c
+++ b/src/modules/alsa/module-alsa-sink.c
@@ -1253,6 +1253,7 @@ int pa__init(pa_module*m) {
     pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d;
     pa_usec_t usec;
     pa_sink_new_data data;
+    const char *profile_description = NULL, *profile_name = NULL;
 
     snd_pcm_info_alloca(&pcm_info);
 
@@ -1338,7 +1339,7 @@ int pa__init(pa_module*m) {
                       &ss, &map,
                       SND_PCM_STREAM_PLAYBACK,
                       &nfrags, &period_frames, tsched_frames,
-                      &b, &d)))
+                      &b, &d, &profile_description, &profile_name)))
 
             goto fail;
 
@@ -1358,6 +1359,9 @@ int pa__init(pa_module*m) {
     pa_assert(u->device_name);
     pa_log_info("Successfully opened device %s.", u->device_name);
 
+    if (profile_description)
+        pa_log_info("Selected configuration '%s' (%s).", profile_description, profile_name);
+
     if (use_mmap && !b) {
         pa_log_info("Device doesn't support mmap(), falling back to UNIX read/write mode.");
         u->use_mmap = use_mmap = FALSE;
@@ -1441,6 +1445,11 @@ int pa__init(pa_module*m) {
     pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size));
     pa_proplist_sets(data.proplist, PA_PROP_DEVICE_ACCESS_MODE, u->use_tsched ? "mmap+timer" : (u->use_mmap ? "mmap" : "serial"));
 
+    if (profile_name)
+        pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_NAME, profile_name);
+    if (profile_description)
+        pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_DESCRIPTION, profile_description);
+
     u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE|PA_SINK_LATENCY);
     pa_sink_new_data_done(&data);
     pa_xfree(name_buf);
diff --git a/src/modules/alsa/module-alsa-source.c b/src/modules/alsa/module-alsa-source.c
index 901db01..f89b6e2 100644
--- a/src/modules/alsa/module-alsa-source.c
+++ b/src/modules/alsa/module-alsa-source.c
@@ -1087,6 +1087,7 @@ int pa__init(pa_module*m) {
     pa_bool_t namereg_fail;
     pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d;
     pa_source_new_data data;
+    const char *profile_description = NULL, *profile_name = NULL;
 
     snd_pcm_info_alloca(&pcm_info);
 
@@ -1167,7 +1168,7 @@ int pa__init(pa_module*m) {
                       &ss, &map,
                       SND_PCM_STREAM_CAPTURE,
                       &nfrags, &period_frames, tsched_frames,
-                      &b, &d)))
+                      &b, &d, &profile_description, &profile_name)))
             goto fail;
 
     } else {
@@ -1185,6 +1186,9 @@ int pa__init(pa_module*m) {
     pa_assert(u->device_name);
     pa_log_info("Successfully opened device %s.", u->device_name);
 
+    if (profile_description)
+        pa_log_info("Selected configuration '%s' (%s).", profile_description, profile_name);
+
     if (use_mmap && !b) {
         pa_log_info("Device doesn't support mmap(), falling back to UNIX read/write mode.");
         u->use_mmap = use_mmap = FALSE;
@@ -1268,6 +1272,11 @@ int pa__init(pa_module*m) {
     pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size));
     pa_proplist_sets(data.proplist, PA_PROP_DEVICE_ACCESS_MODE, u->use_tsched ? "mmap+timer" : (u->use_mmap ? "mmap" : "serial"));
 
+    if (profile_name)
+        pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_NAME, profile_name);
+    if (profile_description)
+        pa_proplist_sets(data.proplist, PA_PROP_DEVICE_PROFILE_DESCRIPTION, profile_description);
+
     u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
     pa_source_new_data_done(&data);
     pa_xfree(name_buf);
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 5d65ff3..77f0399 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -75,8 +75,10 @@ PA_C_DECL_BEGIN
  *    device.connector              isa, pci, usb, firewire, bluetooth
  *    device.access_mode            mmap, mmap_rewrite, serial
  *    device.master_device
- *    device.bufferin.buffer_size
- *    device.bufferin.fragment_size
+ *    device.buffering.buffer_size
+ *    device.buffering.fragment_size
+ *    device.profile.name           analog-stereo, analog-surround-40, iec958-stereo, ...
+ *    device.profile.description    "Analog Stereo", ...
  */
 #define PA_PROP_MEDIA_NAME                     "media.name"
 #define PA_PROP_MEDIA_TITLE                    "media.title"
@@ -124,6 +126,8 @@ PA_C_DECL_BEGIN
 #define PA_PROP_DEVICE_MASTER_DEVICE           "device.master_device"
 #define PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE   "device.buffering.buffer_size"
 #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size"
+#define PA_PROP_DEVICE_PROFILE_NAME            "device.profile.name"
+#define PA_PROP_DEVICE_PROFILE_DESCRIPTION     "device.profile.description"
 
 /** A property list object. Basically a dictionary with UTF-8 strings
  * as keys and arbitrary data as values. \since 0.9.11 */

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list