From 8fc9b19cb314329487a62a15c523e9778298f1d5 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 28 Feb 2009 23:45:02 +0000 Subject: Don't assume that device reservation is enabled. In the case when the alsa 'device' is not a physical card, it wont have an index and thus the reservation name will be NULL and therefore we will not initialise the reservation system. Fixes #498 --- src/modules/alsa/alsa-sink.c | 2 +- src/modules/alsa/alsa-source.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules/alsa') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 0aef1bd5..708e020c 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -148,7 +148,7 @@ static void reserve_update(struct userdata *u) { const char *description; pa_assert(u); - if (!u->sink) + if (!u->sink || !u->reserve) return; if ((description = pa_proplist_gets(u->sink->proplist, PA_PROP_DEVICE_DESCRIPTION))) diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 671df3fe..4321c7ff 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -146,7 +146,7 @@ static void reserve_update(struct userdata *u) { const char *description; pa_assert(u); - if (!u->source) + if (!u->source || !u->reserve) return; if ((description = pa_proplist_gets(u->source->proplist, PA_PROP_DEVICE_DESCRIPTION))) -- cgit From 86dee05aec330a0c2886c0327712153793ca46c4 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Tue, 3 Mar 2009 20:23:02 +0000 Subject: Use LGPL 2.1 on all files previously using LGPL 2 --- src/modules/alsa/alsa-sink.c | 2 +- src/modules/alsa/alsa-sink.h | 2 +- src/modules/alsa/alsa-source.c | 2 +- src/modules/alsa/alsa-source.h | 2 +- src/modules/alsa/alsa-util.c | 2 +- src/modules/alsa/alsa-util.h | 2 +- src/modules/alsa/module-alsa-card.c | 2 +- src/modules/alsa/module-alsa-sink.c | 2 +- src/modules/alsa/module-alsa-source.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/modules/alsa') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index d4325881..c8e12f9c 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -6,7 +6,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/alsa-sink.h b/src/modules/alsa/alsa-sink.h index 47ece9e0..bbf64234 100644 --- a/src/modules/alsa/alsa-sink.h +++ b/src/modules/alsa/alsa-sink.h @@ -9,7 +9,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 7a1b0f8d..ed9388ec 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -6,7 +6,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/alsa-source.h b/src/modules/alsa/alsa-source.h index 5fed6cc8..9cbb0e17 100644 --- a/src/modules/alsa/alsa-source.h +++ b/src/modules/alsa/alsa-source.h @@ -9,7 +9,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index 7d833ff7..454cfd4e 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -6,7 +6,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h index a8397ae9..fe0f71e0 100644 --- a/src/modules/alsa/alsa-util.h +++ b/src/modules/alsa/alsa-util.h @@ -9,7 +9,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index 9e149a48..22f0ae0a 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -5,7 +5,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/module-alsa-sink.c b/src/modules/alsa/module-alsa-sink.c index 4f844e08..c728a446 100644 --- a/src/modules/alsa/module-alsa-sink.c +++ b/src/modules/alsa/module-alsa-sink.c @@ -6,7 +6,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but diff --git a/src/modules/alsa/module-alsa-source.c b/src/modules/alsa/module-alsa-source.c index c35936df..6188019f 100644 --- a/src/modules/alsa/module-alsa-source.c +++ b/src/modules/alsa/module-alsa-source.c @@ -6,7 +6,7 @@ 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, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but -- cgit From f3de61edf68c039abf3499463333ad920019f430 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 3 Mar 2009 22:26:15 +0100 Subject: fix device reservation for system mode --- src/modules/alsa/alsa-sink.c | 3 +++ src/modules/alsa/alsa-source.c | 3 +++ src/modules/alsa/module-alsa-card.c | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/modules/alsa') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index c8e12f9c..bfe4f3bc 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -164,6 +164,9 @@ static int reserve_init(struct userdata *u, const char *dname) { if (u->reserve) return 0; + if (pa_in_system_mode()) + return 0; + /* We are resuming, try to lock the device */ if (!(rname = pa_alsa_get_reserve_name(dname))) return 0; diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index ed9388ec..04cb2621 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -162,6 +162,9 @@ static int reserve_init(struct userdata *u, const char *dname) { if (u->reserve) return 0; + if (pa_in_system_mode()) + return 0; + /* We are resuming, try to lock the device */ if (!(rname = pa_alsa_get_reserve_name(dname))) return 0; diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c index 22f0ae0a..d5e2cdc2 100644 --- a/src/modules/alsa/module-alsa-card.c +++ b/src/modules/alsa/module-alsa-card.c @@ -310,8 +310,9 @@ int pa__init(pa_module *m) { pa_snprintf(rname, sizeof(rname), "Audio%i", alsa_card_index); - if (!(reserve = pa_reserve_wrapper_get(m->core, rname))) - goto fail; + if (!pa_in_system_mode()) + if (!(reserve = pa_reserve_wrapper_get(m->core, rname))) + goto fail; pa_card_new_data_init(&data); data.driver = __FILE__; -- cgit From 869341729f088f3ec19c39aae5565cfae7f7ea33 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 4 Mar 2009 02:55:34 +0100 Subject: various smaller cleanups --- src/modules/alsa/alsa-sink.c | 23 ++++++----------------- src/modules/alsa/alsa-source.c | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'src/modules/alsa') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index bfe4f3bc..7bf16c3c 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1190,17 +1190,11 @@ static int process_rewind(struct userdata *u) { /* Figure out how much we shall rewind and reset the counter */ rewind_nbytes = u->sink->thread_info.rewind_nbytes; - u->sink->thread_info.rewind_nbytes = 0; - if (rewind_nbytes <= 0) - goto finish; - - pa_assert(rewind_nbytes > 0); pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes); - snd_pcm_hwsync(u->pcm_handle); - if ((unused = snd_pcm_avail_update(u->pcm_handle)) < 0) { - pa_log("snd_pcm_avail_update() failed: %s", snd_strerror((int) unused)); + if (PA_UNLIKELY((unused = pa_alsa_safe_avail(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) { + pa_log("snd_pcm_avail() failed: %s", snd_strerror((int) unused)); return -1; } @@ -1242,12 +1236,8 @@ static int process_rewind(struct userdata *u) { } else pa_log_debug("Mhmm, actually there is nothing to rewind."); -finish: - pa_sink_process_rewind(u->sink, 0); - return 0; - } static void thread_func(void *userdata) { @@ -1276,7 +1266,7 @@ static void thread_func(void *userdata) { int work_done; pa_usec_t sleep_usec = 0; - if (u->sink->thread_info.rewind_requested) + if (PA_UNLIKELY(u->sink->thread_info.rewind_requested)) if (process_rewind(u) < 0) goto fail; @@ -1702,11 +1692,10 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca u->watermark_step = pa_usec_to_bytes(TSCHED_WATERMARK_STEP_USEC, &u->sink->sample_spec); } - u->sink->thread_info.max_rewind = use_tsched ? u->hwbuf_size : 0; - u->sink->thread_info.max_request = u->hwbuf_size; - + pa_sink_set_max_rewind(u->sink, use_tsched ? u->hwbuf_size : 0); + pa_sink_set_max_request(u->sink, u->hwbuf_size); pa_sink_set_latency_range(u->sink, - !use_tsched ? pa_bytes_to_usec(u->hwbuf_size, &ss) : (pa_usec_t) -1, + use_tsched ? (pa_usec_t) -1 : pa_bytes_to_usec(u->hwbuf_size, &ss), pa_bytes_to_usec(u->hwbuf_size, &ss)); pa_log_info("Using %u fragments of size %lu bytes, buffer time is %0.2fms", diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 04cb2621..f4acad8c 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -1545,7 +1545,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p } pa_source_set_latency_range(u->source, - !use_tsched ? pa_bytes_to_usec(u->hwbuf_size, &ss) : (pa_usec_t) -1, + use_tsched ? (pa_usec_t) -1 : pa_bytes_to_usec(u->hwbuf_size, &ss), pa_bytes_to_usec(u->hwbuf_size, &ss)); pa_log_info("Using %u fragments of size %lu bytes, buffer time is %0.2fms", -- cgit