diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/modules/alsa/alsa-sink.c | 2 | ||||
-rw-r--r-- | src/modules/alsa/alsa-source.c | 2 | ||||
-rw-r--r-- | src/modules/alsa/alsa-util.c | 14 | ||||
-rw-r--r-- | src/modules/alsa/alsa-util.h | 5 | ||||
-rw-r--r-- | src/modules/alsa/module-alsa-card.c | 2 | ||||
-rw-r--r-- | src/modules/dbus-util.h | 2 | ||||
-rw-r--r-- | src/modules/hal-util.c | 127 | ||||
-rw-r--r-- | src/modules/hal-util.h | 30 | ||||
-rw-r--r-- | src/modules/module-hal-detect.c | 1 |
10 files changed, 182 insertions, 9 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index e27bfbad..d82d8a6e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1268,6 +1268,12 @@ libalsa_util_la_LDFLAGS = -avoid-version libalsa_util_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la libalsa_util_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS) +if HAVE_HAL +libalsa_util_la_SOURCES += modules/hal-util.h modules/hal-util.c +libalsa_util_la_LIBADD += $(HAL_LIBS) libdbus-util.la +libalsa_util_la_CFLAGS += $(HAL_CFLAGS) +endif + module_alsa_sink_la_SOURCES = modules/alsa/module-alsa-sink.c module_alsa_sink_la_LDFLAGS = $(MODULE_LDFLAGS) module_alsa_sink_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 94b289ff..5020eac1 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1436,7 +1436,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca pa_sink_new_data_set_sample_spec(&data, &ss); pa_sink_new_data_set_channel_map(&data, &map); - pa_alsa_init_proplist_pcm(data.proplist, pcm_info); + pa_alsa_init_proplist_pcm(m->core, data.proplist, pcm_info); pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_name); pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (period_frames * frame_size * nfrags)); pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size)); diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index b8ad2e25..96e0d89e 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -1261,7 +1261,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p pa_source_new_data_set_sample_spec(&data, &ss); pa_source_new_data_set_channel_map(&data, &map); - pa_alsa_init_proplist_pcm(data.proplist, pcm_info); + pa_alsa_init_proplist_pcm(m->core, data.proplist, pcm_info); pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_name); pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (period_frames * frame_size * nfrags)); pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size)); diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index 599079ca..7e5a3503 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -39,6 +39,10 @@ #include "alsa-util.h" +#ifdef HAVE_HAL +#include "hal-util.h" +#endif + struct pa_alsa_fdlist { unsigned num_fds; struct pollfd *fds; @@ -1248,7 +1252,7 @@ void pa_alsa_redirect_errors_dec(void) { snd_lib_error_set_handler(NULL); } -void pa_alsa_init_proplist_card(pa_proplist *p, int card) { +void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card) { char *cn, *lcn; pa_assert(p); @@ -1265,9 +1269,13 @@ void pa_alsa_init_proplist_card(pa_proplist *p, int card) { pa_proplist_sets(p, "alsa.long_card_name", lcn); free(lcn); } + +#ifdef HAVE_HAL + pa_hal_get_info(c, p, card); +#endif } -void pa_alsa_init_proplist_pcm(pa_proplist *p, snd_pcm_info_t *pcm_info) { +void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info) { static const char * const alsa_class_table[SND_PCM_CLASS_LAST+1] = { [SND_PCM_CLASS_GENERIC] = "generic", @@ -1321,7 +1329,7 @@ void pa_alsa_init_proplist_pcm(pa_proplist *p, snd_pcm_info_t *pcm_info) { pa_proplist_setf(p, "alsa.device", "%u", snd_pcm_info_get_device(pcm_info)); if ((card = snd_pcm_info_get_card(pcm_info)) >= 0) { - pa_alsa_init_proplist_card(p, card); + pa_alsa_init_proplist_card(c, p, card); cn = pa_proplist_gets(p, "alsa.card_name"); } diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h index 18b04028..f2d3278b 100644 --- a/src/modules/alsa/alsa-util.h +++ b/src/modules/alsa/alsa-util.h @@ -32,6 +32,7 @@ #include <pulse/proplist.h> #include <pulsecore/rtpoll.h> +#include <pulsecore/core.h> typedef struct pa_alsa_fdlist pa_alsa_fdlist; @@ -118,8 +119,8 @@ void pa_alsa_dump_status(snd_pcm_t *pcm); void pa_alsa_redirect_errors_inc(void); void pa_alsa_redirect_errors_dec(void); -void pa_alsa_init_proplist_pcm(pa_proplist *p, snd_pcm_info_t *pcm_info); -void pa_alsa_init_proplist_card(pa_proplist *p, int card); +void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info); +void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card); int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents); diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index d8a37fe6..891195c3 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -281,7 +281,7 @@ int pa__init(pa_module*m) { pa_card_new_data_init(&data); data.driver = __FILE__; data.module = m; - pa_alsa_init_proplist_card(data.proplist, alsa_card_index); + pa_alsa_init_proplist_card(m->core, data.proplist, alsa_card_index); pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id); set_card_name(&data, ma, u->device_id); diff --git a/src/modules/dbus-util.h b/src/modules/dbus-util.h index 2b24ac63..c4794dac 100644 --- a/src/modules/dbus-util.h +++ b/src/modules/dbus-util.h @@ -24,6 +24,8 @@ #include <dbus/dbus.h> +#include <pulsecore/core.h> + typedef struct pa_dbus_connection pa_dbus_connection; /* return the DBusConnection of the specified type for the given core, diff --git a/src/modules/hal-util.c b/src/modules/hal-util.c new file mode 100644 index 00000000..82bbc57e --- /dev/null +++ b/src/modules/hal-util.c @@ -0,0 +1,127 @@ +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <pulsecore/log.h> + +#include <hal/libhal.h> + +#include "dbus-util.h" +#include "hal-util.h" + +int pa_hal_get_info(pa_core *core, pa_proplist *p, int card) { + pa_dbus_connection *c = NULL; + LibHalContext *hal = NULL; + DBusError error; + int r = -1; + char **udis = NULL, *t; + int n, i; + + pa_assert(core); + pa_assert(p); + pa_assert(card >= 0); + + dbus_error_init(&error); + + if (!(c = pa_dbus_bus_get(core, DBUS_BUS_SYSTEM, &error)) || dbus_error_is_set(&error)) { + pa_log_error("Unable to contact DBUS system bus: %s: %s", error.name, error.message); + goto finish; + } + + + if (!(hal = libhal_ctx_new())) { + pa_log_error("libhal_ctx_new() finished"); + goto finish; + } + + if (!libhal_ctx_set_dbus_connection(hal, pa_dbus_connection_get(c))) { + pa_log_error("Error establishing DBUS connection: %s: %s", error.name, error.message); + goto finish; + } + + if (!libhal_ctx_init(hal, &error)) { + pa_log_error("Couldn't connect to hald: %s: %s", error.name, error.message); + goto finish; + } + + if (!(udis = libhal_find_device_by_capability(hal, "sound", &n, &error)) < 0) { + pa_log_error("Couldn't find devices: %s: %s", error.name, error.message); + goto finish; + } + + for (i = 0; i < n; i++) { + dbus_int32_t this_card; + + this_card = libhal_device_get_property_int(hal, udis[i], "sound.card", &error); + if (dbus_error_is_set(&error)) { + dbus_error_free(&error); + continue; + } + + if (this_card == card) + break; + + } + + if (i >= n) + goto finish; + + pa_proplist_sets(p, "hal.udi", udis[i]); + + t = libhal_device_get_property_string(hal, udis[i], "info.product", &error); + if (dbus_error_is_set(&error)) + dbus_error_free(&error); + if (t) { + pa_proplist_sets(p, "hal.product", t); + libhal_free_string(t); + } + + t = libhal_device_get_property_string(hal, udis[i], "sound.card_id", &error); + if (dbus_error_is_set(&error)) + dbus_error_free(&error); + if (t) { + pa_proplist_sets(p, "hal.card_id", t); + libhal_free_string(t); + } + + r = 0; + +finish: + + if (udis) + libhal_free_string_array(udis); + + dbus_error_free(&error); + + if (hal) { + libhal_ctx_shutdown(hal, &error); + libhal_ctx_free(hal); + dbus_error_free(&error); + } + + if (c) + pa_dbus_connection_unref(c); + + return r; +} diff --git a/src/modules/hal-util.h b/src/modules/hal-util.h new file mode 100644 index 00000000..3c0e0943 --- /dev/null +++ b/src/modules/hal-util.h @@ -0,0 +1,30 @@ +#ifndef foohalutilhfoo +#define foohalutilhfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + PulseAudio is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + + +#include <pulsecore/core.h> + +int pa_hal_get_info(pa_core *core, pa_proplist *p, int card); + +#endif diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c index 309b0060..d3b351a4 100644 --- a/src/modules/module-hal-detect.c +++ b/src/modules/module-hal-detect.c @@ -801,7 +801,6 @@ fail: return -1; } - void pa__done(pa_module *m) { struct userdata *u; |