[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test2-38-g205b0ba
Lennart Poettering
gitmailer-noreply at 0pointer.de
Wed Feb 18 19:05:25 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 6db307360b7ef95211aff13548206464e8909882 (commit)
- Log -----------------------------------------------------------------
205b0ba... split out mixer setup into seperate functions to make things more readable
e1608d5... modernize pa_msleep() a bit
9cbdd3a... add pa_timespec_load
45218aa... make interpol-test useful for recording as well
5f5396b... additional validity check
928920c... additional validity check
7f8ccf9... handle both positive and negative errno's
-----------------------------------------------------------------------
Summary of changes:
src/modules/alsa/alsa-sink.c | 170 +++++++++++++++++++++-------------------
src/modules/alsa/alsa-source.c | 170 +++++++++++++++++++++-------------------
src/pulse/util.c | 6 +-
src/pulsecore/core-error.c | 3 +
src/pulsecore/rtclock.c | 8 ++
src/pulsecore/rtclock.h | 2 +
src/pulsecore/sink.c | 3 +
src/pulsecore/source.c | 3 +
src/tests/interpol-test.c | 35 +++++++-
9 files changed, 231 insertions(+), 169 deletions(-)
-----------------------------------------------------------------------
commit 7f8ccf9e7cf2d0e4042cd5fa85bc49a2982e6807
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 03:56:31 2009 +0100
handle both positive and negative errno's
diff --git a/src/pulsecore/core-error.c b/src/pulsecore/core-error.c
index 3d6c2c3..d9caa94 100644
--- a/src/pulsecore/core-error.c
+++ b/src/pulsecore/core-error.c
@@ -47,6 +47,9 @@ const char* pa_cstrerror(int errnum) {
char *translated, *t;
char errbuf[128];
+ if (errnum < 0)
+ errnum = -errnum;
+
if ((t = PA_STATIC_TLS_GET(cstrerror)))
pa_xfree(t);
commit 928920c8b81b20ff1a8257231904cd0f06804988
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 03:58:52 2009 +0100
additional validity check
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 4f39d67..7441e97 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1846,6 +1846,9 @@ void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t m
pa_sink_assert_ref(s);
+ pa_assert(!min_latency || !max_latency ||
+ min_latency <= max_latency);
+
s->thread_info.min_latency = min_latency;
s->thread_info.max_latency = max_latency;
commit 5f5396bb15c6b939ac6a71efa36950817f9e18bf
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 03:59:04 2009 +0100
additional validity check
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 0009d85..c0d6d9e 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1120,6 +1120,9 @@ void pa_source_update_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec
pa_source_assert_ref(s);
+ pa_assert(!min_latency || !max_latency ||
+ min_latency <= max_latency);
+
s->thread_info.min_latency = min_latency;
s->thread_info.max_latency = max_latency;
commit 45218aa2268e9fc231d42d1479adf7685eb3b507
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 03:59:56 2009 +0100
make interpol-test useful for recording as well
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c
index 9d93077..20d2c23 100644
--- a/src/tests/interpol-test.c
+++ b/src/tests/interpol-test.c
@@ -39,10 +39,23 @@
static pa_context *context = NULL;
static pa_stream *stream = NULL;
static pa_mainloop_api *mainloop_api = NULL;
+static pa_bool_t playback = TRUE;
static void stream_write_cb(pa_stream *p, size_t nbytes, void *userdata) {
/* Just some silence */
- pa_stream_write(p, pa_xmalloc0(nbytes), nbytes, pa_xfree, 0, PA_SEEK_RELATIVE);
+ pa_assert_se(pa_stream_write(p, pa_xmalloc0(nbytes), nbytes, pa_xfree, 0, PA_SEEK_RELATIVE) == 0);
+}
+
+static void stream_read_cb(pa_stream *p, size_t nbytes, void *userdata) {
+ /* We don't care, just drop the data */
+
+ while (pa_stream_readable_size(p) > 0) {
+ const void *d;
+ size_t b;
+
+ pa_assert_se(pa_stream_peek(p, &d, &b) == 0);
+ pa_assert_se(pa_stream_drop(p) == 0);
+ }
}
/* This is called whenever the context status changes */
@@ -68,8 +81,13 @@ static void context_state_callback(pa_context *c, void *userdata) {
stream = pa_stream_new(c, "interpol-test", &ss, NULL);
assert(stream);
- pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL);
- pa_stream_set_write_callback(stream, stream_write_cb, NULL);
+ if (playback) {
+ pa_assert_se(pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) == 0);
+ pa_stream_set_write_callback(stream, stream_write_cb, NULL);
+ } else {
+ pa_assert_se(pa_stream_connect_record(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE) == 0);
+ pa_stream_set_read_callback(stream, stream_read_cb, NULL);
+ }
break;
}
@@ -90,6 +108,8 @@ int main(int argc, char *argv[]) {
struct timeval start, last_info = { 0, 0 };
pa_usec_t old_t = 0, old_rtc = 0;
+ playback = argc <= 1 || !pa_streq(argv[1], "-r");
+
/* Set up a new main loop */
m = pa_threaded_mainloop_new();
assert(m);
@@ -138,7 +158,14 @@ int main(int argc, char *argv[]) {
if (success) {
rtc = pa_timeval_diff(&now, &start);
- printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\t%u\n", k, (unsigned long long) rtc, (unsigned long long) t, (unsigned long long) (rtc-old_rtc), (unsigned long long) (t-old_t), changed, playing);
+ printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\t%u\n", k,
+ (unsigned long long) rtc,
+ (unsigned long long) t,
+ (unsigned long long) (rtc-old_rtc),
+ (unsigned long long) (t-old_t),
+ changed,
+ playing);
+
fflush(stdout);
old_t = t;
old_rtc = rtc;
commit 9cbdd3a968cc167ca7f0060089efc69c4c2c1f13
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 04:00:29 2009 +0100
add pa_timespec_load
diff --git a/src/pulsecore/rtclock.c b/src/pulsecore/rtclock.c
index 5fc6da2..dcbd118 100644
--- a/src/pulsecore/rtclock.c
+++ b/src/pulsecore/rtclock.c
@@ -141,3 +141,11 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) {
return tv;
}
+
+pa_usec_t pa_timespec_load(const struct timespec *ts) {
+ pa_assert(ts);
+
+ return
+ (pa_usec_t) ts->tv_sec * PA_USEC_PER_SEC +
+ (pa_usec_t) ts->tv_nsec / PA_NSEC_PER_USEC;
+}
diff --git a/src/pulsecore/rtclock.h b/src/pulsecore/rtclock.h
index 281461d..03cc1c7 100644
--- a/src/pulsecore/rtclock.h
+++ b/src/pulsecore/rtclock.h
@@ -42,4 +42,6 @@ void pa_rtclock_hrtimer_enable(void);
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
+pa_usec_t pa_timespec_load(const struct timespec *ts);
+
#endif
commit e1608d5db2c270965b8143f93e1b8b9a1c301e26
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 04:01:12 2009 +0100
modernize pa_msleep() a bit
diff --git a/src/pulse/util.c b/src/pulse/util.c
index b20ea46..54a188d 100644
--- a/src/pulse/util.c
+++ b/src/pulse/util.c
@@ -54,6 +54,8 @@
#endif
#include <pulse/xmalloc.h>
+#include <pulse/timeval.h>
+
#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h>
#include <pulsecore/log.h>
@@ -260,8 +262,8 @@ int pa_msleep(unsigned long t) {
#elif defined(HAVE_NANOSLEEP)
struct timespec ts;
- ts.tv_sec = (time_t) (t/1000UL);
- ts.tv_nsec = (long) ((t % 1000UL) * 1000000UL);
+ ts.tv_sec = (time_t) (t / PA_MSEC_PER_SEC);
+ ts.tv_nsec = (long) ((t % PA_MSEC_PER_SEC) * PA_NSEC_PER_MSEC);
return nanosleep(&ts, NULL);
#else
commit 205b0ba08e1f796481e0bba11c0813266af3947f
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Feb 19 04:04:42 2009 +0100
split out mixer setup into seperate functions to make things more readable
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 5fc3468..eeac5e7 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,7 +1321,6 @@ 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;
- 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;
@@ -1365,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;
}
@@ -1448,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 1909cae..81d7c0b 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,11 +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;
- int err;
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE;
pa_source_new_data data;
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) {
@@ -1190,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;
}
@@ -1270,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);
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list