summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/alsa/alsa-sink.c180
-rw-r--r--src/modules/alsa/alsa-source.c180
-rw-r--r--src/modules/alsa/alsa-util.c60
-rw-r--r--src/modules/alsa/alsa-util.h3
-rw-r--r--src/modules/dbus-util.c3
-rw-r--r--src/modules/module-card-restore.c2
-rw-r--r--src/modules/module-hal-detect.c1
-rw-r--r--src/modules/module-stream-restore.c2
-rw-r--r--src/modules/rtp/module-rtp-recv.c2
-rw-r--r--src/modules/rtp/sdp.c6
10 files changed, 236 insertions, 203 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 1474cfee..eeac5e76 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1227,6 +1227,91 @@ static void set_sink_name(pa_sink_new_data *data, pa_modargs *ma, const char *de
pa_xfree(t);
}
+static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
+ pa_assert(u);
+
+ if (!u->mixer_handle)
+ return 0;
+
+ pa_assert(u->mixer_elem);
+
+ if (snd_mixer_selem_has_playback_volume(u->mixer_elem)) {
+ pa_bool_t suitable = FALSE;
+
+ if (snd_mixer_selem_get_playback_volume_range(u->mixer_elem, &u->hw_volume_min, &u->hw_volume_max) < 0)
+ pa_log_info("Failed to get volume range. Falling back to software volume control.");
+ else if (u->hw_volume_min >= u->hw_volume_max)
+ pa_log_warn("Your kernel driver is broken: it reports a volume range from %li to %li which makes no sense.", u->hw_volume_min, u->hw_volume_max);
+ else {
+ pa_log_info("Volume ranges from %li to %li.", u->hw_volume_min, u->hw_volume_max);
+ suitable = TRUE;
+ }
+
+ if (suitable) {
+ if (ignore_dB || snd_mixer_selem_get_playback_dB_range(u->mixer_elem, &u->hw_dB_min, &u->hw_dB_max) < 0)
+ pa_log_info("Mixer doesn't support dB information or data is ignored.");
+ else {
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_min, sizeof(u->hw_dB_min));
+ VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
+#endif
+
+ if (u->hw_dB_min >= u->hw_dB_max)
+ pa_log_warn("Your kernel driver is broken: it reports a volume range from %0.2f dB to %0.2f dB which makes no sense.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
+ else {
+ pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
+ u->hw_dB_supported = TRUE;
+
+ if (u->hw_dB_max > 0) {
+ u->sink->base_volume = pa_sw_volume_from_dB(- (double) u->hw_dB_max/100.0);
+ pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->sink->base_volume));
+ } else
+ pa_log_info("No particular base volume set, fixing to 0 dB");
+ }
+ }
+
+ if (!u->hw_dB_supported &&
+ u->hw_volume_max - u->hw_volume_min < 3) {
+
+ pa_log_info("Device doesn't do dB volume and has less than 4 volume levels. Falling back to software volume control.");
+ suitable = FALSE;
+ }
+ }
+
+ if (suitable) {
+ u->mixer_seperate_channels = pa_alsa_calc_mixer_map(u->mixer_elem, &u->sink->channel_map, u->mixer_map, TRUE) >= 0;
+
+ u->sink->get_volume = sink_get_volume_cb;
+ u->sink->set_volume = sink_set_volume_cb;
+ u->sink->flags |= PA_SINK_HW_VOLUME_CTRL | (u->hw_dB_supported ? PA_SINK_DECIBEL_VOLUME : 0);
+ pa_log_info("Using hardware volume control. Hardware dB scale %s.", u->hw_dB_supported ? "supported" : "not supported");
+
+ if (!u->hw_dB_supported)
+ u->sink->n_volume_steps = u->hw_volume_max - u->hw_volume_min + 1;
+ } else
+ pa_log_info("Using software volume control.");
+ }
+
+ if (snd_mixer_selem_has_playback_switch(u->mixer_elem)) {
+ u->sink->get_mute = sink_get_mute_cb;
+ u->sink->set_mute = sink_set_mute_cb;
+ u->sink->flags |= PA_SINK_HW_MUTE_CTRL;
+ } else
+ pa_log_info("Using software mute control.");
+
+ u->mixer_fdl = pa_alsa_fdlist_new();
+
+ if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) {
+ pa_log("Failed to initialize file descriptor monitoring");
+ return -1;
+ }
+
+ snd_mixer_elem_set_callback(u->mixer_elem, mixer_callback);
+ snd_mixer_elem_set_callback_private(u->mixer_elem, u);
+
+ return 0;
+}
+
pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_card *card, const pa_alsa_profile_info *profile) {
struct userdata *u = NULL;
@@ -1236,14 +1321,10 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
uint32_t nfrags, hwbuf_size, frag_size, tsched_size, tsched_watermark;
snd_pcm_uframes_t period_frames, tsched_frames;
size_t frame_size;
- snd_pcm_info_t *pcm_info = NULL;
- int err;
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE;
pa_usec_t usec;
pa_sink_new_data data;
- snd_pcm_info_alloca(&pcm_info);
-
pa_assert(m);
pa_assert(ma);
@@ -1368,7 +1449,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
}
if (use_tsched && (!b || !d)) {
- pa_log_info("Cannot enabled timer-based scheduling, falling back to sound IRQ scheduling.");
+ pa_log_info("Cannot enable timer-based scheduling, falling back to sound IRQ scheduling.");
u->use_tsched = use_tsched = FALSE;
}
@@ -1378,11 +1459,6 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
if (u->use_tsched)
pa_log_info("Successfully enabled timer-based scheduling mode.");
- if ((err = snd_pcm_info(u->pcm_handle, pcm_info)) < 0) {
- pa_log("Error fetching PCM info: %s", snd_strerror(err));
- goto fail;
- }
-
/* ALSA might tweak the sample spec, so recalculate the frame size */
frame_size = pa_frame_size(&ss);
@@ -1396,7 +1472,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(m->core, data.proplist, pcm_info);
+ pa_alsa_init_proplist_pcm(m->core, data.proplist, u->pcm_handle);
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));
@@ -1456,86 +1532,8 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
if (update_sw_params(u) < 0)
goto fail;
- pa_memchunk_reset(&u->memchunk);
-
- if (u->mixer_handle) {
- pa_assert(u->mixer_elem);
-
- if (snd_mixer_selem_has_playback_volume(u->mixer_elem)) {
- pa_bool_t suitable = FALSE;
-
- if (snd_mixer_selem_get_playback_volume_range(u->mixer_elem, &u->hw_volume_min, &u->hw_volume_max) < 0)
- pa_log_info("Failed to get volume range. Falling back to software volume control.");
- else if (u->hw_volume_min >= u->hw_volume_max)
- pa_log_warn("Your kernel driver is broken: it reports a volume range from %li to %li which makes no sense.", u->hw_volume_min, u->hw_volume_max);
- else {
- pa_log_info("Volume ranges from %li to %li.", u->hw_volume_min, u->hw_volume_max);
- suitable = TRUE;
- }
-
- if (suitable) {
- if (ignore_dB || snd_mixer_selem_get_playback_dB_range(u->mixer_elem, &u->hw_dB_min, &u->hw_dB_max) < 0)
- pa_log_info("Mixer doesn't support dB information or data is ignored.");
- else {
-#ifdef HAVE_VALGRIND_MEMCHECK_H
- VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_min, sizeof(u->hw_dB_min));
- VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
-#endif
-
- if (u->hw_dB_min >= u->hw_dB_max)
- pa_log_warn("Your kernel driver is broken: it reports a volume range from %0.2f dB to %0.2f dB which makes no sense.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
- else {
- pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
- u->hw_dB_supported = TRUE;
-
- if (u->hw_dB_max > 0) {
- u->sink->base_volume = pa_sw_volume_from_dB(- (double) u->hw_dB_max/100.0);
- pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->sink->base_volume));
- } else
- pa_log_info("No particular base volume set, fixing to 0 dB");
- }
- }
-
- if (!u->hw_dB_supported &&
- u->hw_volume_max - u->hw_volume_min < 3) {
-
- pa_log_info("Device doesn't do dB volume and has less than 4 volume levels. Falling back to software volume control.");
- suitable = FALSE;
- }
- }
-
- if (suitable) {
- u->mixer_seperate_channels = pa_alsa_calc_mixer_map(u->mixer_elem, &map, u->mixer_map, TRUE) >= 0;
-
- u->sink->get_volume = sink_get_volume_cb;
- u->sink->set_volume = sink_set_volume_cb;
- u->sink->flags |= PA_SINK_HW_VOLUME_CTRL | (u->hw_dB_supported ? PA_SINK_DECIBEL_VOLUME : 0);
- pa_log_info("Using hardware volume control. Hardware dB scale %s.", u->hw_dB_supported ? "supported" : "not supported");
-
- if (!u->hw_dB_supported)
- u->sink->n_volume_steps = u->hw_volume_max - u->hw_volume_min + 1;
- } else
- pa_log_info("Using software volume control.");
- }
-
- if (snd_mixer_selem_has_playback_switch(u->mixer_elem)) {
- u->sink->get_mute = sink_get_mute_cb;
- u->sink->set_mute = sink_set_mute_cb;
- u->sink->flags |= PA_SINK_HW_MUTE_CTRL;
- } else
- pa_log_info("Using software mute control.");
-
- u->mixer_fdl = pa_alsa_fdlist_new();
-
- if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, m->core->mainloop) < 0) {
- pa_log("Failed to initialize file descriptor monitoring");
- goto fail;
- }
-
- snd_mixer_elem_set_callback(u->mixer_elem, mixer_callback);
- snd_mixer_elem_set_callback_private(u->mixer_elem, u);
- } else
- u->mixer_fdl = NULL;
+ if (setup_mixer(u, ignore_dB) < 0)
+ goto fail;
pa_alsa_dump(u->pcm_handle);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 192645d0..81d7c0bb 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1062,6 +1062,91 @@ static void set_source_name(pa_source_new_data *data, pa_modargs *ma, const char
pa_xfree(t);
}
+static int setup_mixer(struct userdata *u, pa_bool_t ignore_dB) {
+ pa_assert(u);
+
+ if (!u->mixer_handle)
+ return 0;
+
+ pa_assert(u->mixer_elem);
+
+ if (snd_mixer_selem_has_capture_volume(u->mixer_elem)) {
+ pa_bool_t suitable = FALSE;
+
+ if (snd_mixer_selem_get_capture_volume_range(u->mixer_elem, &u->hw_volume_min, &u->hw_volume_max) < 0)
+ pa_log_info("Failed to get volume range. Falling back to software volume control.");
+ else if (u->hw_volume_min >= u->hw_volume_max)
+ pa_log_warn("Your kernel driver is broken: it reports a volume range from %li to %li which makes no sense.", u->hw_volume_min, u->hw_volume_max);
+ else {
+ pa_log_info("Volume ranges from %li to %li.", u->hw_volume_min, u->hw_volume_max);
+ suitable = TRUE;
+ }
+
+ if (suitable) {
+ if (ignore_dB || snd_mixer_selem_get_capture_dB_range(u->mixer_elem, &u->hw_dB_min, &u->hw_dB_max) < 0)
+ pa_log_info("Mixer doesn't support dB information or data is ignored.");
+ else {
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_min, sizeof(u->hw_dB_min));
+ VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
+#endif
+
+ if (u->hw_dB_min >= u->hw_dB_max)
+ pa_log_warn("Your kernel driver is broken: it reports a volume range from %0.2f dB to %0.2f dB which makes no sense.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
+ else {
+ pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
+ u->hw_dB_supported = TRUE;
+
+ if (u->hw_dB_max > 0) {
+ u->source->base_volume = pa_sw_volume_from_dB(- (double) u->hw_dB_max/100.0);
+ pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->source->base_volume));
+ } else
+ pa_log_info("No particular base volume set, fixing to 0 dB");
+ }
+ }
+
+ if (!u->hw_dB_supported &&
+ u->hw_volume_max - u->hw_volume_min < 3) {
+
+ pa_log_info("Device has less than 4 volume levels. Falling back to software volume control.");
+ suitable = FALSE;
+ }
+ }
+
+ if (suitable) {
+ u->mixer_seperate_channels = pa_alsa_calc_mixer_map(u->mixer_elem, &u->source->channel_map, u->mixer_map, FALSE) >= 0;
+
+ u->source->get_volume = source_get_volume_cb;
+ u->source->set_volume = source_set_volume_cb;
+ u->source->flags |= PA_SOURCE_HW_VOLUME_CTRL | (u->hw_dB_supported ? PA_SOURCE_DECIBEL_VOLUME : 0);
+ pa_log_info("Using hardware volume control. Hardware dB scale %s.", u->hw_dB_supported ? "supported" : "not supported");
+
+ if (!u->hw_dB_supported)
+ u->source->n_volume_steps = u->hw_volume_max - u->hw_volume_min + 1;
+ } else
+ pa_log_info("Using software volume control.");
+ }
+
+ if (snd_mixer_selem_has_capture_switch(u->mixer_elem)) {
+ u->source->get_mute = source_get_mute_cb;
+ u->source->set_mute = source_set_mute_cb;
+ u->source->flags |= PA_SOURCE_HW_MUTE_CTRL;
+ } else
+ pa_log_info("Using software mute control.");
+
+ u->mixer_fdl = pa_alsa_fdlist_new();
+
+ if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) {
+ pa_log("Failed to initialize file descriptor monitoring");
+ return -1;
+ }
+
+ snd_mixer_elem_set_callback(u->mixer_elem, mixer_callback);
+ snd_mixer_elem_set_callback_private(u->mixer_elem, u);
+
+ return 0;
+}
+
pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, pa_card *card, const pa_alsa_profile_info *profile) {
struct userdata *u = NULL;
@@ -1071,14 +1156,11 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
uint32_t nfrags, hwbuf_size, frag_size, tsched_size, tsched_watermark;
snd_pcm_uframes_t period_frames, tsched_frames;
size_t frame_size;
- snd_pcm_info_t *pcm_info = NULL;
- int err;
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE;
pa_source_new_data data;
- snd_pcm_info_alloca(&pcm_info);
-
pa_assert(m);
+ pa_assert(ma);
ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) {
@@ -1193,7 +1275,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
}
if (use_tsched && (!b || !d)) {
- pa_log_info("Cannot enabled timer-based scheduling, falling back to sound IRQ scheduling.");
+ pa_log_info("Cannot enable timer-based scheduling, falling back to sound IRQ scheduling.");
u->use_tsched = use_tsched = FALSE;
}
@@ -1203,11 +1285,6 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
if (u->use_tsched)
pa_log_info("Successfully enabled timer-based scheduling mode.");
- if ((err = snd_pcm_info(u->pcm_handle, pcm_info)) < 0) {
- pa_log("Error fetching PCM info: %s", snd_strerror(err));
- goto fail;
- }
-
/* ALSA might tweak the sample spec, so recalculate the frame size */
frame_size = pa_frame_size(&ss);
@@ -1221,7 +1298,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(m->core, data.proplist, pcm_info);
+ pa_alsa_init_proplist_pcm(m->core, data.proplist, u->pcm_handle);
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));
@@ -1278,85 +1355,8 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
if (update_sw_params(u) < 0)
goto fail;
- if (u->mixer_handle) {
- pa_assert(u->mixer_elem);
-
- if (snd_mixer_selem_has_capture_volume(u->mixer_elem)) {
- pa_bool_t suitable = FALSE;
-
- if (snd_mixer_selem_get_capture_volume_range(u->mixer_elem, &u->hw_volume_min, &u->hw_volume_max) < 0)
- pa_log_info("Failed to get volume range. Falling back to software volume control.");
- else if (u->hw_volume_min >= u->hw_volume_max)
- pa_log_warn("Your kernel driver is broken: it reports a volume range from %li to %li which makes no sense.", u->hw_volume_min, u->hw_volume_max);
- else {
- pa_log_info("Volume ranges from %li to %li.", u->hw_volume_min, u->hw_volume_max);
- suitable = TRUE;
- }
-
- if (suitable) {
- if (ignore_dB || snd_mixer_selem_get_capture_dB_range(u->mixer_elem, &u->hw_dB_min, &u->hw_dB_max) < 0)
- pa_log_info("Mixer doesn't support dB information or data is ignored.");
- else {
-#ifdef HAVE_VALGRIND_MEMCHECK_H
- VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_min, sizeof(u->hw_dB_min));
- VALGRIND_MAKE_MEM_DEFINED(&u->hw_dB_max, sizeof(u->hw_dB_max));
-#endif
-
- if (u->hw_dB_min >= u->hw_dB_max)
- pa_log_warn("Your kernel driver is broken: it reports a volume range from %0.2f dB to %0.2f dB which makes no sense.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
- else {
- pa_log_info("Volume ranges from %0.2f dB to %0.2f dB.", (double) u->hw_dB_min/100.0, (double) u->hw_dB_max/100.0);
- u->hw_dB_supported = TRUE;
-
- if (u->hw_dB_max > 0) {
- u->source->base_volume = pa_sw_volume_from_dB(- (double) u->hw_dB_max/100.0);
- pa_log_info("Fixing base volume to %0.2f dB", pa_sw_volume_to_dB(u->source->base_volume));
- } else
- pa_log_info("No particular base volume set, fixing to 0 dB");
-
- }
- }
-
- if (!u->hw_dB_supported &&
- u->hw_volume_max - u->hw_volume_min < 3) {
-
- pa_log_info("Device has less than 4 volume levels. Falling back to software volume control.");
- suitable = FALSE;
- }
- }
-
- if (suitable) {
- u->mixer_seperate_channels = pa_alsa_calc_mixer_map(u->mixer_elem, &map, u->mixer_map, FALSE) >= 0;
-
- u->source->get_volume = source_get_volume_cb;
- u->source->set_volume = source_set_volume_cb;
- u->source->flags |= PA_SOURCE_HW_VOLUME_CTRL | (u->hw_dB_supported ? PA_SOURCE_DECIBEL_VOLUME : 0);
- pa_log_info("Using hardware volume control. Hardware dB scale %s.", u->hw_dB_supported ? "supported" : "not supported");
-
- if (!u->hw_dB_supported)
- u->source->n_volume_steps = u->hw_volume_max - u->hw_volume_min + 1;
- } else
- pa_log_info("Using software volume control.");
- }
-
- if (snd_mixer_selem_has_capture_switch(u->mixer_elem)) {
- u->source->get_mute = source_get_mute_cb;
- u->source->set_mute = source_set_mute_cb;
- u->source->flags |= PA_SOURCE_HW_MUTE_CTRL;
- } else
- pa_log_info("Using software mute control.");
-
- u->mixer_fdl = pa_alsa_fdlist_new();
-
- if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, m->core->mainloop) < 0) {
- pa_log("Failed to initialize file descriptor monitoring");
- goto fail;
- }
-
- snd_mixer_elem_set_callback(u->mixer_elem, mixer_callback);
- snd_mixer_elem_set_callback_private(u->mixer_elem, u);
- } else
- u->mixer_fdl = NULL;
+ if (setup_mixer(u, ignore_dB) < 0)
+ goto fail;
pa_alsa_dump(u->pcm_handle);
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index d7caa0f0..a0907c4d 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1,7 +1,7 @@
/***
This file is part of PulseAudio.
- Copyright 2004-2006 Lennart Poettering
+ Copyright 2004-2009 Lennart Poettering
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
@@ -37,6 +37,7 @@
#include <pulsecore/macro.h>
#include <pulsecore/core-util.h>
#include <pulsecore/atomic.h>
+#include <pulsecore/core-error.h>
#include "alsa-util.h"
@@ -112,7 +113,7 @@ static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t
static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
struct pa_alsa_fdlist *fdl = userdata;
unsigned num_fds, i;
- int err;
+ int err, n;
struct pollfd *temp;
pa_assert(a);
@@ -121,7 +122,11 @@ static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) {
a->defer_enable(fdl->defer, 0);
- num_fds = (unsigned) snd_mixer_poll_descriptors_count(fdl->mixer);
+ if ((n = snd_mixer_poll_descriptors_count(fdl->mixer)) < 0) {
+ pa_log("snd_mixer_poll_descriptors_count() failed: %s", snd_strerror(n));
+ return;
+ }
+ num_fds = (unsigned) n;
if (num_fds != fdl->num_fds) {
if (fdl->fds)
@@ -342,7 +347,8 @@ int pa_alsa_set_hw_params(
goto finish;
if (_use_mmap) {
- if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED)) < 0) {
+
+ if (snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) {
/* mmap() didn't work, fall back to interleaved */
@@ -805,8 +811,7 @@ snd_pcm_t *pa_alsa_open_by_device_string(
SND_PCM_NO_AUTO_CHANNELS|
(reformat ? 0 : SND_PCM_NO_AUTO_FORMAT))) < 0) {
pa_log_info("Error opening PCM device %s: %s", d, snd_strerror(err));
- pa_xfree(d);
- return NULL;
+ goto fail;
}
if ((err = pa_alsa_set_hw_params(pcm_handle, ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, require_exact_channel_number)) < 0) {
@@ -834,9 +839,9 @@ snd_pcm_t *pa_alsa_open_by_device_string(
}
pa_log_info("Failed to set hardware parameters on %s: %s", d, snd_strerror(err));
- pa_xfree(d);
snd_pcm_close(pcm_handle);
- return NULL;
+
+ goto fail;
}
if (dev)
@@ -849,6 +854,11 @@ snd_pcm_t *pa_alsa_open_by_device_string(
return pcm_handle;
}
+
+fail:
+ pa_xfree(d);
+
+ return NULL;
}
int pa_alsa_probe_profiles(
@@ -1361,7 +1371,7 @@ void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card) {
#endif
}
-void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info) {
+void pa_alsa_init_proplist_pcm_info(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",
@@ -1382,7 +1392,7 @@ void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_i
snd_pcm_class_t class;
snd_pcm_subclass_t subclass;
- const char *n, *id, *sdn, *cn;
+ const char *n, *id, *sdn, *cn = NULL;
int card;
pa_assert(p);
@@ -1427,6 +1437,28 @@ void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_i
pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, n);
}
+void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm) {
+ snd_pcm_hw_params_t *hwparams;
+ snd_pcm_info_t *info;
+ int bits, err;
+
+ snd_pcm_hw_params_alloca(&hwparams);
+ snd_pcm_info_alloca(&info);
+
+ if ((err = snd_pcm_hw_params_current(pcm, hwparams)) < 0)
+ pa_log_warn("Error fetching hardware parameter info: %s", snd_strerror(err));
+ else {
+
+ if ((bits = snd_pcm_hw_params_get_sbits(hwparams)) >= 0)
+ pa_proplist_setf(p, "alsa.resolution_bits", "%i", bits);
+ }
+
+ if ((err = snd_pcm_info(pcm, info)) < 0)
+ pa_log_warn("Error fetching PCM info: %s", snd_strerror(err));
+ else
+ pa_alsa_init_proplist_pcm_info(c, p, info);
+}
+
int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
snd_pcm_state_t state;
int err;
@@ -1525,8 +1557,8 @@ snd_pcm_sframes_t pa_alsa_safe_avail_update(snd_pcm_t *pcm, size_t hwbuf_size, c
if (k >= hwbuf_size * 3 ||
k >= pa_bytes_per_second(ss)*10)
- pa_log("snd_pcm_avail_update() returned a value that is exceptionally large: %lu bytes (%lu ms) "
- "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
+ pa_log("snd_pcm_avail_update() returned a value that is exceptionally large: %lu bytes (%lu ms). "
+ "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers.",
(unsigned long) k, (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC));
return n;
@@ -1557,8 +1589,8 @@ int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas
k >= hwbuf_size * 3 ||
k >= pa_bytes_per_second(ss)*10)
- pa_log("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms) "
- "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
+ pa_log("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms). "
+ "Most likely this is an ALSA driver bug. Please report this issue to the ALSA developers.",
(unsigned long) k, (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC));
return r;
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index 8b083392..9eab6449 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -120,8 +120,9 @@ 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_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
+void pa_alsa_init_proplist_pcm_info(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);
+void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
diff --git a/src/modules/dbus-util.c b/src/modules/dbus-util.c
index f6a986a5..4218bca5 100644
--- a/src/modules/dbus-util.c
+++ b/src/modules/dbus-util.c
@@ -403,8 +403,7 @@ void pa_dbus_pending_free(pa_dbus_pending *p) {
pa_assert(p);
if (p->pending) {
- dbus_pending_call_cancel(p->pending);
- dbus_pending_call_unref(p->pending);
+ dbus_pending_call_cancel(p->pending); /* p->pending is freed by cancel() */
}
if (p->message)
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 909c0957..c7696058 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -191,7 +191,7 @@ static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card_new_data *new
pa_assert(new_data);
- if ((e = read_entry(u, new_data->name)) && e->profile) {
+ if ((e = read_entry(u, new_data->name)) && e->profile[0]) {
if (!new_data->active_profile) {
pa_card_new_data_set_profile(new_data, e->profile);
diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c
index e6037381..ce04f367 100644
--- a/src/modules/module-hal-detect.c
+++ b/src/modules/module-hal-detect.c
@@ -370,6 +370,7 @@ static struct device* hal_device_add(struct userdata *u, const char *udi) {
d->originating_udi = NULL;
d->module = PA_INVALID_INDEX;
d->sink_name = d->source_name = d->card_name = NULL;
+ r = -1;
#ifdef HAVE_ALSA
if (pa_streq(u->capability, CAPABILITY_ALSA))
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 434dc7a0..d935caf6 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -532,6 +532,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
pa_xfree(n);
continue;
}
+ pa_xfree(n);
if (u->restore_volume) {
pa_cvolume v;
@@ -581,6 +582,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
pa_xfree(n);
continue;
}
+ pa_xfree(n);
if (u->restore_device &&
e->device_valid &&
diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c
index 063ba725..0d86459e 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -562,7 +562,7 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event
} else {
if (!(s = pa_hashmap_get(u->by_origin, info.origin))) {
- if (!(s = session_new(u, &info)))
+ if (!session_new(u, &info))
pa_sdp_info_destroy(&info);
} else {
diff --git a/src/modules/rtp/sdp.c b/src/modules/rtp/sdp.c
index 643361f2..7c547430 100644
--- a/src/modules/rtp/sdp.c
+++ b/src/modules/rtp/sdp.c
@@ -44,7 +44,7 @@
char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, uint16_t port, uint8_t payload, const pa_sample_spec *ss) {
uint32_t ntp;
char buf_src[64], buf_dst[64], un[64];
- const char *u, *f, *a;
+ const char *u, *f;
pa_assert(src);
pa_assert(dst);
@@ -62,8 +62,8 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u
ntp = (uint32_t) time(NULL) + 2208988800U;
- pa_assert_se(a = inet_ntop(af, src, buf_src, sizeof(buf_src)));
- pa_assert_se(a = inet_ntop(af, dst, buf_dst, sizeof(buf_dst)));
+ pa_assert_se(inet_ntop(af, src, buf_src, sizeof(buf_src)));
+ pa_assert_se(inet_ntop(af, dst, buf_dst, sizeof(buf_dst)));
return pa_sprintf_malloc(
PA_SDP_HEADER