mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
fix default device naming and fix api selection code
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1632 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
a7a5f43f67
commit
793f750429
1 changed files with 15 additions and 12 deletions
|
|
@ -155,7 +155,7 @@ static int hal_alsa_device_is_modem(LibHalContext *context, const char *udi, DBu
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi, char **sink_name, char **source_name) {
|
static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi, char **sink_name, char **source_name) {
|
||||||
char args[128];
|
char *args;
|
||||||
alsa_type_t type;
|
alsa_type_t type;
|
||||||
int device, card;
|
int device, card;
|
||||||
const char *module_name;
|
const char *module_name;
|
||||||
|
|
@ -189,18 +189,20 @@ static pa_module* hal_device_load_alsa(struct userdata *u, const char *udi, char
|
||||||
*sink_name = pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
|
*sink_name = pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
|
||||||
|
|
||||||
module_name = "module-alsa-sink";
|
module_name = "module-alsa-sink";
|
||||||
pa_snprintf(args, sizeof(args), "device=hw:%u sink_name=%s", card, *sink_name);
|
args = pa_sprintf_malloc("device=hw:%u sink_name=%s", card, *sink_name);
|
||||||
} else {
|
} else {
|
||||||
*source_name = pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
|
*source_name = pa_sprintf_malloc("alsa_input.%s", strip_udi(udi));
|
||||||
|
|
||||||
module_name = "module-alsa-source";
|
module_name = "module-alsa-source";
|
||||||
pa_snprintf(args, sizeof(args), "device=hw:%u source_name=%s", card, *source_name);
|
args = pa_sprintf_malloc("device=hw:%u source_name=%s", card, *source_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_log_debug("Loading %s with arguments '%s'", module_name, args);
|
pa_log_debug("Loading %s with arguments '%s'", module_name, args);
|
||||||
|
|
||||||
m = pa_module_load(u->core, module_name, args);
|
m = pa_module_load(u->core, module_name, args);
|
||||||
|
|
||||||
|
pa_xfree(args);
|
||||||
|
|
||||||
if (!m) {
|
if (!m) {
|
||||||
pa_xfree(*sink_name);
|
pa_xfree(*sink_name);
|
||||||
pa_xfree(*source_name);
|
pa_xfree(*source_name);
|
||||||
|
|
@ -257,7 +259,7 @@ finish:
|
||||||
}
|
}
|
||||||
|
|
||||||
static pa_module* hal_device_load_oss(struct userdata *u, const char *udi, char **sink_name, char **source_name) {
|
static pa_module* hal_device_load_oss(struct userdata *u, const char *udi, char **sink_name, char **source_name) {
|
||||||
char args[256];
|
char* args;
|
||||||
char* device;
|
char* device;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
pa_module *m;
|
pa_module *m;
|
||||||
|
|
@ -277,15 +279,15 @@ static pa_module* hal_device_load_oss(struct userdata *u, const char *udi, char
|
||||||
if (!device || dbus_error_is_set(&error))
|
if (!device || dbus_error_is_set(&error))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
*sink_name = pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
|
*sink_name = pa_sprintf_malloc("oss_output.%s", strip_udi(udi));
|
||||||
*source_name = pa_sprintf_malloc("alsa_output.%s", strip_udi(udi));
|
*source_name = pa_sprintf_malloc("oss_input.%s", strip_udi(udi));
|
||||||
|
|
||||||
pa_snprintf(args, sizeof(args), "device=%s sink_name=%s source_name=%s", device, sink_name, source_name);
|
args = pa_sprintf_malloc("device=%s sink_name=%s source_name=%s", device, *sink_name, *source_name);
|
||||||
libhal_free_string(device);
|
libhal_free_string(device);
|
||||||
|
|
||||||
pa_log_debug("Loading module-oss with arguments '%s'", args);
|
pa_log_debug("Loading module-oss with arguments '%s'", args);
|
||||||
|
|
||||||
m = pa_module_load(u->core, "module-oss", args);
|
m = pa_module_load(u->core, "module-oss", args);
|
||||||
|
pa_xfree(args);
|
||||||
|
|
||||||
if (!m) {
|
if (!m) {
|
||||||
pa_xfree(*sink_name);
|
pa_xfree(*sink_name);
|
||||||
|
|
@ -342,10 +344,12 @@ static int hal_device_add_all(struct userdata *u, const char *capability) {
|
||||||
char** udis;
|
char** udis;
|
||||||
|
|
||||||
pa_assert(u);
|
pa_assert(u);
|
||||||
pa_assert(!u->capability);
|
|
||||||
|
|
||||||
dbus_error_init(&error);
|
dbus_error_init(&error);
|
||||||
|
|
||||||
|
if (u->capability && strcmp(u->capability, capability) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
pa_log_info("Trying capability %s", capability);
|
pa_log_info("Trying capability %s", capability);
|
||||||
|
|
||||||
udis = libhal_find_device_by_capability(u->context, capability, &n, &error);
|
udis = libhal_find_device_by_capability(u->context, capability, &n, &error);
|
||||||
|
|
@ -356,7 +360,6 @@ static int hal_device_add_all(struct userdata *u, const char *capability) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
u->capability = capability;
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
struct device *d;
|
struct device *d;
|
||||||
|
|
@ -741,7 +744,7 @@ int pa__init(pa_module*m) {
|
||||||
n = hal_device_add_all(u, CAPABILITY_ALSA);
|
n = hal_device_add_all(u, CAPABILITY_ALSA);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_ALSA) && defined(HAVE_OSS)
|
#if defined(HAVE_ALSA) && defined(HAVE_OSS)
|
||||||
if (!u->capability)
|
if (n <= 0)
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OSS
|
#ifdef HAVE_OSS
|
||||||
n += hal_device_add_all(u, CAPABILITY_OSS);
|
n += hal_device_add_all(u, CAPABILITY_OSS);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue