mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
include a few HAL properties in our card/sink/source properties for ALSA devices
This commit is contained in:
parent
54dad91f07
commit
a365c8212d
11 changed files with 186 additions and 10 deletions
|
|
@ -916,7 +916,10 @@ AC_ARG_ENABLE([hal],
|
|||
[hal=auto])
|
||||
if test "x${hal}" != xno -a \( "x$HAVE_OSS" = "x1" -o "x$HAVE_ALSA" = "x1" \) ; then
|
||||
PKG_CHECK_MODULES(HAL, [ hal >= 0.5.11 ],
|
||||
HAVE_HAL=1,
|
||||
[
|
||||
HAVE_HAL=1
|
||||
AC_DEFINE([HAVE_HAL], 1, [Have HAL.])
|
||||
],
|
||||
[
|
||||
HAVE_HAL=0
|
||||
if test "x$hal" = xyes ; then
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
127
src/modules/hal-util.c
Normal file
127
src/modules/hal-util.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
30
src/modules/hal-util.h
Normal file
30
src/modules/hal-util.h
Normal file
|
|
@ -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
|
||||
|
|
@ -801,7 +801,6 @@ fail:
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void pa__done(pa_module *m) {
|
||||
struct userdata *u;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue