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

Lennart Poettering gitmailer-noreply at 0pointer.de
Tue Jan 20 11:35:30 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  a65c2c73369e6b2ce9350dfb542f5d529de38334 (commit)

- Log -----------------------------------------------------------------
7368a6e... add priority logic to find best default profile
b3a043f... always add 'disabled' profile
e0f8c13... remove unused variable
86f3fb8... show active profile
-----------------------------------------------------------------------

Summary of changes:
 src/modules/alsa/alsa-util.c        |   35 +++++++++++++++++++++++------------
 src/modules/alsa/alsa-util.h        |    1 +
 src/modules/alsa/module-alsa-card.c |   22 +++++++++++++++++++++-
 src/pulsecore/card.c                |   17 +++++++++++++++--
 src/pulsecore/card.h                |    2 ++
 src/pulsecore/cli-text.c            |    2 +-
 src/pulsecore/protocol-native.c     |    1 -
 src/utils/pactl.c                   |    4 ++++
 8 files changed, 67 insertions(+), 17 deletions(-)

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

commit 86f3fb8b12790ba1b7d160d83d0b62ac7abddc78
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 20 20:33:28 2009 +0100

    show active profile

diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index 75b46d2..ba91f50 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -426,6 +426,10 @@ static void get_card_info_callback(pa_context *c, const pa_card_info *i, int is_
             printf("\t\t%s: %s\n", p->name, p->description);
     }
 
+    if (i->active_profile)
+        printf(_("\tActive Profile: %s\n"),
+               i->active_profile->name);
+
     pa_xfree(pl);
 }
 

commit e0f8c1301240e4c49e22032e4edf8dcbe1844ccb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 20 20:33:47 2009 +0100

    remove unused variable

diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 87cf583..aa541a8 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2867,7 +2867,6 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
     pa_source *source = NULL;
     pa_client *client = NULL;
     pa_card *card = NULL;
-    pa_core *core = NULL;
     pa_module *module = NULL;
     pa_sink_input *si = NULL;
     pa_source_output *so = NULL;

commit b3a043fd3179fcb60730466ae43f16ffe14a9b4c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 20 20:34:46 2009 +0100

    always add 'disabled' profile

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 1e3c0c1..ac6083d 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -97,7 +97,6 @@ static void enumerate_cb(
         t = pa_sprintf_malloc("Output %s", sink->description);
     } else {
         pa_assert(source);
-        n = pa_xstrdup(source->name);
         n = pa_sprintf_malloc("input-%s", source->name);
         t = pa_sprintf_malloc("Input %s", source->description);
     }
@@ -125,6 +124,18 @@ static void enumerate_cb(
     pa_hashmap_put(profiles, p->name, p);
 }
 
+static void add_disabled_profile(pa_hashmap *profiles) {
+    pa_card_profile *p;
+    struct profile_data *d;
+
+    p = pa_card_profile_new("off", "Off", sizeof(struct profile_data));
+
+    d = PA_CARD_PROFILE_DATA(p);
+    d->sink = d->source = NULL;
+
+    pa_hashmap_put(profiles, p->name, p);
+}
+
 int pa__init(pa_module*m) {
     pa_card_new_data data;
     pa_modargs *ma;
@@ -163,6 +174,14 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if (pa_hashmap_isempty(data.profiles)) {
+        pa_log("Failed to find a working profile.");
+        pa_card_new_data_done(&data);
+        goto fail;
+    }
+
+    add_disabled_profile(data.profiles);
+
     u->card = pa_card_new(m->core, &data);
     pa_card_new_data_done(&data);
 

commit 7368a6e6be5dbbdc8e13003ef6841fe3fe1840bc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jan 20 20:35:18 2009 +0100

    add priority logic to find best default profile

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 6522176..eb7042b 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -495,62 +495,72 @@ static const struct pa_alsa_profile_info device_table[] = {
     {{ 1, { PA_CHANNEL_POSITION_MONO }},
      "hw",
      "Analog Mono",
-     "analog-mono" },
+     "analog-mono",
+     1 },
 
     {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
      "front",
      "Analog Stereo",
-     "analog-stereo" },
+     "analog-stereo",
+     10 },
 
     {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
      "iec958",
      "IEC958 Digital Stereo",
-     "iec958-stereo" },
+     "iec958-stereo",
+     5 },
 
     {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
      "hdmi",
      "HDMI Digital Stereo",
-     "hdmi-stereo"},
+     "hdmi-stereo",
+     4 },
 
     {{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
             PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
      "surround40",
      "Analog Surround 4.0",
-     "analog-surround-40" },
+     "analog-surround-40",
+     7 },
 
     {{ 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" },
+     "iec958-ac3-surround-40",
+     2 },
 
     {{ 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",
      "Analog Surround 4.1",
-     "analog-surround-41"},
+     "analog-surround-41",
+     7 },
 
     {{ 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",
      "Analog Surround 5.0",
-     "analog-surround-50" },
+     "analog-surround-50",
+     7 },
 
     {{ 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",
      "Analog Surround 5.1",
-     "analog-surround-51" },
+     "analog-surround-51",
+     8 },
 
     {{ 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" },
+     "iec958-ac3-surround-51",
+     3 },
 
     {{ 8, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
             PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
@@ -558,9 +568,10 @@ static const struct pa_alsa_profile_info device_table[] = {
             PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT }},
      "surround71",
      "Analog Surround 7.1",
-     "analog-surround-71" },
+     "analog-surround-71",
+     7 },
 
-    {{ 0, { 0 }}, NULL, NULL, NULL }
+    {{ 0, { 0 }}, NULL, NULL, NULL, 0 }
 };
 
 static pa_bool_t channel_map_superset(const pa_channel_map *a, const pa_channel_map *b) {
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index f58ec8e..5965625 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -86,6 +86,7 @@ typedef struct pa_alsa_profile_info {
     const char *alsa_name;
     const char *description;
     const char *name;
+    unsigned priority;
 } pa_alsa_profile_info;
 
 int pa_alsa_probe_profiles(
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index ac6083d..6c947c0 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -108,6 +108,7 @@ static void enumerate_cb(
     pa_xfree(t);
     pa_xfree(n);
 
+    p->priority = (sink ? sink->priority : 0)*100 + (source ? source->priority : 0);
     p->n_sinks = !!sink;
     p->n_sources = !!source;
 
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 8e29f0a..cb77553 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -45,6 +45,10 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
     c->name = pa_xstrdup(name);
     c->description = pa_xstrdup(description);
 
+    c->priority = 0;
+    c->n_sinks = c->n_sources = 0;
+    c->max_sink_channels = c->max_source_channels = 0;
+
     return c;
 }
 
@@ -125,8 +129,17 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
     c->profiles = data->profiles;
     data->profiles = NULL;
     if (!(c->active_profile = data->active_profile))
-        if (c->profiles)
-            c->active_profile = pa_hashmap_first(c->profiles);
+        if (c->profiles) {
+            void *state = NULL;
+            pa_card_profile *p;
+
+            while ((p = pa_hashmap_iterate(c->profiles, &state, NULL))) {
+                if (!c->active_profile ||
+                    p->priority > c->active_profile->priority)
+
+                    c->active_profile = p;
+            }
+        }
     data->active_profile = NULL;
 
     c->userdata = NULL;
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index b4e68b0..17733c5 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -33,6 +33,8 @@ typedef struct pa_card_profile {
     char *name;
     char *description;
 
+    unsigned priority;
+
     /* We probably want to have different properties later on here */
     unsigned n_sinks;
     unsigned n_sources;
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index f52968d..947598b 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -142,7 +142,7 @@ char *pa_card_list_to_string(pa_core *c) {
                     "\tprofiles:\n");
 
             while ((p = pa_hashmap_iterate(card->profiles, &state, NULL)))
-                pa_strbuf_printf(s, "\t\t%s: %s\n", p->name, p->description);
+                pa_strbuf_printf(s, "\t\t%s: %s (priority %u)\n", p->name, p->description, p->priority);
         }
 
         if (card->active_profile)

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list