From befe9f9247ce1b10a2c2e563c0c264a30bbd3cc0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Jun 08 2009 16:10:27 +0000 Subject: Fix a couple of issues, including #497742, #494851 --- diff --git a/0001-alsa-allow-configuration-of-fallback-device-strings.patch b/0001-alsa-allow-configuration-of-fallback-device-strings.patch new file mode 100644 index 0000000..34562d2 --- /dev/null +++ b/0001-alsa-allow-configuration-of-fallback-device-strings.patch @@ -0,0 +1,342 @@ +From d8710711fb0c74b4ad83ac99c2501218155b502b Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 29 Apr 2009 01:58:18 +0200 +Subject: [PATCH] alsa: allow configuration of fallback device strings in profiles + +This has the benefit that we can properly support ALSA devices where +only the raw 'hw' device exists but no 'front' although it's a proper +2ch stereo device. +--- + src/modules/alsa/alsa-util.c | 126 +++++++++++++++++++++++++++++------------ + src/modules/alsa/alsa-util.h | 1 + + 2 files changed, 90 insertions(+), 37 deletions(-) + +diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c +index 18d6880..a3a0450 100644 +--- a/src/modules/alsa/alsa-util.c ++++ b/src/modules/alsa/alsa-util.c +@@ -528,7 +528,7 @@ int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min) { + + static const struct pa_alsa_profile_info device_table[] = { + {{ 1, { PA_CHANNEL_POSITION_MONO }}, +- "hw", ++ "hw", NULL, + N_("Analog Mono"), + "analog-mono", + 1, +@@ -536,7 +536,7 @@ static const struct pa_alsa_profile_info device_table[] = { + "Capture", "Mic" }, + + {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }}, +- "front", ++ "front", "hw", + N_("Analog Stereo"), + "analog-stereo", + 10, +@@ -544,7 +544,7 @@ static const struct pa_alsa_profile_info device_table[] = { + "Capture", "Mic" }, + + {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }}, +- "iec958", ++ "iec958", NULL, + N_("Digital Stereo (IEC958)"), + "iec958-stereo", + 5, +@@ -552,7 +552,7 @@ static const struct pa_alsa_profile_info device_table[] = { + "IEC958 In", NULL }, + + {{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }}, +- "hdmi", ++ "hdmi", NULL, + N_("Digital Stereo (HDMI)"), + "hdmi-stereo", + 4, +@@ -561,7 +561,7 @@ static const struct pa_alsa_profile_info device_table[] = { + + {{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }}, +- "surround40", ++ "surround40", NULL, + N_("Analog Surround 4.0"), + "analog-surround-40", + 7, +@@ -570,7 +570,7 @@ static const struct pa_alsa_profile_info device_table[] = { + + {{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }}, +- "a52", ++ "a52", NULL, + N_("Digital Surround 4.0 (IEC958/AC3)"), + "iec958-ac3-surround-40", + 2, +@@ -580,7 +580,7 @@ static const struct pa_alsa_profile_info device_table[] = { + {{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, + PA_CHANNEL_POSITION_LFE }}, +- "surround41", ++ "surround41", NULL, + N_("Analog Surround 4.1"), + "analog-surround-41", + 7, +@@ -590,7 +590,7 @@ static const struct pa_alsa_profile_info device_table[] = { + {{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, + PA_CHANNEL_POSITION_CENTER }}, +- "surround50", ++ "surround50", NULL, + N_("Analog Surround 5.0"), + "analog-surround-50", + 7, +@@ -600,7 +600,7 @@ static const struct pa_alsa_profile_info device_table[] = { + {{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, + PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE }}, +- "surround51", ++ "surround51", NULL, + N_("Analog Surround 5.1"), + "analog-surround-51", + 8, +@@ -610,7 +610,7 @@ static const struct pa_alsa_profile_info device_table[] = { + {{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT, + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, + PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE}}, +- "a52", ++ "a52", NULL, + N_("Digital Surround 5.1 (IEC958/AC3)"), + "iec958-ac3-surround-51", + 3, +@@ -621,16 +621,72 @@ static const struct pa_alsa_profile_info device_table[] = { + PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT, + PA_CHANNEL_POSITION_CENTER, PA_CHANNEL_POSITION_LFE, + PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT }}, +- "surround71", ++ "surround71", NULL, + N_("Analog Surround 7.1"), + "analog-surround-71", + 7, + "Master", "PCM", + "Capture", "Mic" }, + +- {{ 0, { 0 }}, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL } ++ {{ 0, { 0 }}, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL } + }; + ++static snd_pcm_t *open_by_device_string_with_fallback( ++ const char *prefix, ++ const char *prefix_fallback, ++ const char *dev_id, ++ char **dev, ++ pa_sample_spec *ss, ++ pa_channel_map* map, ++ int mode, ++ uint32_t *nfrags, ++ snd_pcm_uframes_t *period_size, ++ snd_pcm_uframes_t tsched_size, ++ pa_bool_t *use_mmap, ++ pa_bool_t *use_tsched, ++ pa_bool_t require_exact_channel_number) { ++ ++ snd_pcm_t *pcm_handle; ++ char *d; ++ ++ d = pa_sprintf_malloc("%s:%s", prefix, dev_id); ++ ++ pcm_handle = pa_alsa_open_by_device_string( ++ d, ++ dev, ++ ss, ++ map, ++ mode, ++ nfrags, ++ period_size, ++ tsched_size, ++ use_mmap, ++ use_tsched, ++ require_exact_channel_number); ++ pa_xfree(d); ++ ++ if (!pcm_handle && prefix_fallback) { ++ ++ d = pa_sprintf_malloc("%s:%s", prefix_fallback, dev_id); ++ ++ pcm_handle = pa_alsa_open_by_device_string( ++ d, ++ dev, ++ ss, ++ map, ++ mode, ++ nfrags, ++ period_size, ++ tsched_size, ++ use_mmap, ++ use_tsched, ++ require_exact_channel_number); ++ pa_xfree(d); ++ } ++ ++ return pcm_handle; ++} ++ + snd_pcm_t *pa_alsa_open_by_device_id_auto( + const char *dev_id, + char **dev, +@@ -671,14 +727,14 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto( + + pa_log_debug("Checking for %s (%s)", device_table[i].name, device_table[i].alsa_name); + +- d = pa_sprintf_malloc("%s:%s", device_table[i].alsa_name, dev_id); +- + try_ss.channels = device_table[i].map.channels; + try_ss.rate = ss->rate; + try_ss.format = ss->format; + +- pcm_handle = pa_alsa_open_by_device_string( +- d, ++ pcm_handle = open_by_device_string_with_fallback( ++ device_table[i].alsa_name, ++ device_table[i].alsa_name_fallback, ++ dev_id, + dev, + &try_ss, + map, +@@ -690,8 +746,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto( + use_tsched, + TRUE); + +- pa_xfree(d); +- + if (pcm_handle) { + + *ss = try_ss; +@@ -703,6 +757,7 @@ snd_pcm_t *pa_alsa_open_by_device_id_auto( + + return pcm_handle; + } ++ + } + + if (direction > 0) { +@@ -775,7 +830,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_profile( + pa_bool_t *use_tsched, + const pa_alsa_profile_info *profile) { + +- char *d; + snd_pcm_t *pcm_handle; + pa_sample_spec try_ss; + +@@ -787,14 +841,14 @@ snd_pcm_t *pa_alsa_open_by_device_id_profile( + pa_assert(period_size); + pa_assert(profile); + +- d = pa_sprintf_malloc("%s:%s", profile->alsa_name, dev_id); +- + try_ss.channels = profile->map.channels; + try_ss.rate = ss->rate; + try_ss.format = ss->format; + +- pcm_handle = pa_alsa_open_by_device_string( +- d, ++ pcm_handle = open_by_device_string_with_fallback( ++ profile->alsa_name, ++ profile->alsa_name_fallback, ++ dev_id, + dev, + &try_ss, + map, +@@ -806,8 +860,6 @@ snd_pcm_t *pa_alsa_open_by_device_id_profile( + use_tsched, + TRUE); + +- pa_xfree(d); +- + if (!pcm_handle) + return NULL; + +@@ -860,6 +912,8 @@ snd_pcm_t *pa_alsa_open_by_device_string( + goto fail; + } + ++ pa_log_debug("Managed to open %s", d); ++ + if ((err = pa_alsa_set_hw_params(pcm_handle, ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, require_exact_channel_number)) < 0) { + + if (!reformat) { +@@ -928,26 +982,25 @@ int pa_alsa_probe_profiles( + snd_pcm_t *pcm_i = NULL; + + if (i->alsa_name) { +- char *id; + pa_sample_spec try_ss; + pa_channel_map try_map; + + pa_log_debug("Checking for playback on %s (%s)", i->name, i->alsa_name); +- id = pa_sprintf_malloc("%s:%s", i->alsa_name, dev_id); + + try_ss = *ss; + try_ss.channels = i->map.channels; + try_map = i->map; + +- pcm_i = pa_alsa_open_by_device_string( +- id, NULL, ++ pcm_i = open_by_device_string_with_fallback( ++ i->alsa_name, ++ i->alsa_name_fallback, ++ dev_id, ++ NULL, + &try_ss, &try_map, + SND_PCM_STREAM_PLAYBACK, + NULL, NULL, 0, NULL, NULL, + TRUE); + +- pa_xfree(id); +- + if (!pcm_i) + continue; + } +@@ -956,26 +1009,25 @@ int pa_alsa_probe_profiles( + snd_pcm_t *pcm_j = NULL; + + if (j->alsa_name) { +- char *jd; + pa_sample_spec try_ss; + pa_channel_map try_map; + + pa_log_debug("Checking for capture on %s (%s)", j->name, j->alsa_name); +- jd = pa_sprintf_malloc("%s:%s", j->alsa_name, dev_id); + + try_ss = *ss; + try_ss.channels = j->map.channels; + try_map = j->map; + +- pcm_j = pa_alsa_open_by_device_string( +- jd, NULL, ++ pcm_j = open_by_device_string_with_fallback( ++ j->alsa_name, ++ j->alsa_name_fallback, ++ dev_id, ++ NULL, + &try_ss, &try_map, + SND_PCM_STREAM_CAPTURE, + NULL, NULL, 0, NULL, NULL, + TRUE); + +- pa_xfree(jd); +- + if (!pcm_j) + continue; + } +diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h +index 77ac8a7..4c5d336 100644 +--- a/src/modules/alsa/alsa-util.h ++++ b/src/modules/alsa/alsa-util.h +@@ -56,6 +56,7 @@ int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min); + typedef struct pa_alsa_profile_info { + pa_channel_map map; + const char *alsa_name; ++ const char *alsa_name_fallback; + const char *description; /* internationalized */ + const char *name; + unsigned priority; +-- +1.6.2.2 + diff --git a/0001-alsa-be-a-bit-more-verbose-when-a-hwparam-call-fail.patch b/0001-alsa-be-a-bit-more-verbose-when-a-hwparam-call-fail.patch new file mode 100644 index 0000000..c674876 --- /dev/null +++ b/0001-alsa-be-a-bit-more-verbose-when-a-hwparam-call-fail.patch @@ -0,0 +1,121 @@ +From 0cb383717e1e65847f3ede7f3c904caff9129c93 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 14 May 2009 01:25:07 +0200 +Subject: [PATCH] alsa: be a bit more verbose when a hwparam call fails + +--- + src/modules/alsa/alsa-util.c | 45 ++++++++++++++++++++++++++++++++++------- + 1 files changed, 37 insertions(+), 8 deletions(-) + +diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c +index 17c7c80..c03866c 100644 +--- a/src/modules/alsa/alsa-util.c ++++ b/src/modules/alsa/alsa-util.c +@@ -272,6 +272,11 @@ static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_s + if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0) + return ret; + ++ pa_log_debug("snd_pcm_hw_params_set_format(%s) failed: %s", ++ snd_pcm_format_description(format_trans[*f]), ++ pa_alsa_strerror(ret)); ++ ++ + if (*f == PA_SAMPLE_FLOAT32BE) + *f = PA_SAMPLE_FLOAT32LE; + else if (*f == PA_SAMPLE_FLOAT32LE) +@@ -298,6 +303,10 @@ static int set_format(snd_pcm_t *pcm_handle, snd_pcm_hw_params_t *hwparams, pa_s + if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0) + return ret; + ++ pa_log_debug("snd_pcm_hw_params_set_format(%s) failed: %s", ++ snd_pcm_format_description(format_trans[*f]), ++ pa_alsa_strerror(ret)); ++ + try_auto: + + for (i = 0; try_order[i] != PA_SAMPLE_INVALID; i++) { +@@ -305,6 +314,10 @@ try_auto: + + if ((ret = snd_pcm_hw_params_set_format(pcm_handle, hwparams, format_trans[*f])) >= 0) + return ret; ++ ++ pa_log_debug("snd_pcm_hw_params_set_format(%s) failed: %s", ++ snd_pcm_format_description(format_trans[*f]), ++ pa_alsa_strerror(ret)); + } + + return -1; +@@ -338,11 +351,15 @@ int pa_alsa_set_hw_params( + + snd_pcm_hw_params_alloca(&hwparams); + +- if ((ret = snd_pcm_hw_params_any(pcm_handle, hwparams)) < 0) ++ if ((ret = snd_pcm_hw_params_any(pcm_handle, hwparams)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_any() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + +- if ((ret = snd_pcm_hw_params_set_rate_resample(pcm_handle, hwparams, 0)) < 0) ++ if ((ret = snd_pcm_hw_params_set_rate_resample(pcm_handle, hwparams, 0)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_rate_resample() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + + if (_use_mmap) { + +@@ -350,14 +367,18 @@ int pa_alsa_set_hw_params( + + /* mmap() didn't work, fall back to interleaved */ + +- if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) ++ if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_access() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + + _use_mmap = FALSE; + } + +- } else if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) ++ } else if ((ret = snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_access() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + + if (!_use_mmap) + _use_tsched = FALSE; +@@ -365,19 +386,27 @@ int pa_alsa_set_hw_params( + if ((ret = set_format(pcm_handle, hwparams, &f)) < 0) + goto finish; + +- if ((ret = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &r, NULL)) < 0) ++ if ((ret = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &r, NULL)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_rate_near() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + + if (require_exact_channel_number) { +- if ((ret = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, c)) < 0) ++ if ((ret = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, c)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_channels() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + } else { +- if ((ret = snd_pcm_hw_params_set_channels_near(pcm_handle, hwparams, &c)) < 0) ++ if ((ret = snd_pcm_hw_params_set_channels_near(pcm_handle, hwparams, &c)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_channels_near() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + } + +- if ((ret = snd_pcm_hw_params_set_periods_integer(pcm_handle, hwparams)) < 0) ++ if ((ret = snd_pcm_hw_params_set_periods_integer(pcm_handle, hwparams)) < 0) { ++ pa_log_debug("snd_pcm_hw_params_set_periods_integer() failed: %s", pa_alsa_strerror(ret)); + goto finish; ++ } + + if (_period_size && tsched_size && _periods) { + +-- +1.6.2.2 + diff --git a/0001-alsa-don-t-hit-an-assert-when-invalid-module-argume.patch b/0001-alsa-don-t-hit-an-assert-when-invalid-module-argume.patch new file mode 100644 index 0000000..69af9d4 --- /dev/null +++ b/0001-alsa-don-t-hit-an-assert-when-invalid-module-argume.patch @@ -0,0 +1,41 @@ +From 4129f5119407da54708d1504c0ffa2d0888fa804 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 1 May 2009 04:11:30 +0200 +Subject: [PATCH] alsa: don't hit an assert when invalid module arguments are passed + +--- + src/modules/alsa/alsa-sink.c | 3 ++- + src/modules/alsa/alsa-source.c | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c +index 41e8b47..4d8dade 100644 +--- a/src/modules/alsa/alsa-sink.c ++++ b/src/modules/alsa/alsa-sink.c +@@ -1770,7 +1770,8 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca + + fail: + +- userdata_free(u); ++ if (u) ++ userdata_free(u); + + return NULL; + } +diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c +index 843f70b..d49035c 100644 +--- a/src/modules/alsa/alsa-source.c ++++ b/src/modules/alsa/alsa-source.c +@@ -1621,7 +1621,8 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p + + fail: + +- userdata_free(u); ++ if (u) ++ userdata_free(u); + + return NULL; + } +-- +1.6.2.2 + diff --git a/0001-alsa-fix-wording-we-are-speaking-of-card-profiles.patch b/0001-alsa-fix-wording-we-are-speaking-of-card-profiles.patch new file mode 100644 index 0000000..4fd86b7 --- /dev/null +++ b/0001-alsa-fix-wording-we-are-speaking-of-card-profiles.patch @@ -0,0 +1,25 @@ +From d2198c9ba1acb070b14747c49afaff87e85daa81 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 26 May 2009 22:29:33 +0200 +Subject: [PATCH] alsa: fix wording, we are speaking of card profiles, not output profiles + +--- + src/modules/alsa/module-alsa-card.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c +index 51d466e..d894b9c 100644 +--- a/src/modules/alsa/module-alsa-card.c ++++ b/src/modules/alsa/module-alsa-card.c +@@ -135,7 +135,7 @@ static void enumerate_cb( + bonus += 20000; + } + +- pa_log_info("Found output profile '%s'", t); ++ pa_log_info("Found profile '%s'", t); + + p = pa_card_profile_new(n, t, sizeof(struct profile_data)); + +-- +1.6.2.2 + diff --git a/0001-alsa-initialize-buffer-size-before-number-of-period.patch b/0001-alsa-initialize-buffer-size-before-number-of-period.patch new file mode 100644 index 0000000..1284850 --- /dev/null +++ b/0001-alsa-initialize-buffer-size-before-number-of-period.patch @@ -0,0 +1,84 @@ +From 4bffc7849f7898fa85dd6ac8e735db86b57814b3 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 1 May 2009 04:16:17 +0200 +Subject: [PATCH] alsa: initialize buffer size before number of periods to improve compat with some backends + +--- + src/modules/alsa/alsa-util.c | 33 ++++++++++++++++++++------------- + 1 files changed, 20 insertions(+), 13 deletions(-) + +diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c +index a3a0450..107bec3 100644 +--- a/src/modules/alsa/alsa-util.c ++++ b/src/modules/alsa/alsa-util.c +@@ -334,7 +334,6 @@ int pa_alsa_set_hw_params( + int ret = -1; + snd_pcm_uframes_t _period_size = period_size ? *period_size : 0; + unsigned int _periods = periods ? *periods : 0; +- snd_pcm_uframes_t buffer_size; + unsigned int r = ss->rate; + unsigned int c = ss->channels; + pa_sample_format_t f = ss->format; +@@ -390,39 +389,47 @@ int pa_alsa_set_hw_params( + goto finish; + + if (_period_size && tsched_size && _periods) { ++ + /* Adjust the buffer sizes, if we didn't get the rate we were asking for */ + _period_size = (snd_pcm_uframes_t) (((uint64_t) _period_size * r) / ss->rate); + tsched_size = (snd_pcm_uframes_t) (((uint64_t) tsched_size * r) / ss->rate); + + if (_use_tsched) { +- _period_size = tsched_size; +- _periods = 1; ++ snd_pcm_uframes_t buffer_size; + + pa_assert_se(snd_pcm_hw_params_get_buffer_size_max(hwparams, &buffer_size) == 0); + pa_log_debug("Maximum hw buffer size is %u ms", (unsigned) buffer_size * 1000 / r); ++ ++ _period_size = tsched_size; ++ _periods = 1; + } + +- buffer_size = _periods * _period_size; ++ if (_period_size > 0 && _periods > 0) { ++ snd_pcm_uframes_t buffer_size; ++ ++ buffer_size = _periods * _period_size; ++ ++ if ((ret = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &buffer_size)) < 0) ++ pa_log_info("snd_pcm_hw_params_set_buffer_size_near() failed: %s", pa_alsa_strerror(ret)); ++ } + + if (_periods > 0) { + +- /* First we pass 0 as direction to get exactly what we asked +- * for. That this is necessary is presumably a bug in ALSA */ ++ /* First we pass 0 as direction to get exactly what we ++ * asked for. That this is necessary is presumably a bug ++ * in ALSA. All in all this is mostly a hint to ALSA, so ++ * we don't care if this fails. */ + + dir = 0; +- if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0) { ++ if (snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir) < 0) { + dir = 1; +- if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0) { ++ if (snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir) < 0) { + dir = -1; + if ((ret = snd_pcm_hw_params_set_periods_near(pcm_handle, hwparams, &_periods, &dir)) < 0) +- goto finish; ++ pa_log_info("snd_pcm_hw_params_set_periods_near() failed: %s", pa_alsa_strerror(ret)); + } + } + } +- +- if (_period_size > 0) +- if ((ret = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &buffer_size)) < 0) +- goto finish; + } + + if ((ret = snd_pcm_hw_params(pcm_handle, hwparams)) < 0) +-- +1.6.2.2 + diff --git a/0001-conf-remove-obsolete-module-idle-time-directive-fro.patch b/0001-conf-remove-obsolete-module-idle-time-directive-fro.patch new file mode 100644 index 0000000..121643d --- /dev/null +++ b/0001-conf-remove-obsolete-module-idle-time-directive-fro.patch @@ -0,0 +1,43 @@ +From 78bccde2264c439702b103fd8491d9f56c79f54f Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Sun, 7 Jun 2009 00:44:16 +0200 +Subject: [PATCH] conf: remove obsolete module-idle-time directive from default config file/man page + +--- + man/pulse-daemon.conf.5.xml.in | 7 ------- + src/daemon/daemon.conf.in | 1 - + 2 files changed, 0 insertions(+), 8 deletions(-) + +diff --git a/man/pulse-daemon.conf.5.xml.in b/man/pulse-daemon.conf.5.xml.in +index b4a7fdb..a7c49a4 100644 +--- a/man/pulse-daemon.conf.5.xml.in ++++ b/man/pulse-daemon.conf.5.xml.in +@@ -236,13 +236,6 @@ USA. + + + +- +- +-- +1.6.2.2 + diff --git a/0001-man-document-log-related-daemon.conf-options.patch b/0001-man-document-log-related-daemon.conf-options.patch new file mode 100644 index 0000000..0b87eb4 --- /dev/null +++ b/0001-man-document-log-related-daemon.conf-options.patch @@ -0,0 +1,52 @@ +From 5be1cc52ffcc01c655f897fd7fdead4484bfd86b Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Sun, 7 Jun 2009 00:44:49 +0200 +Subject: [PATCH] man: document log related daemon.conf options + +--- + man/pulse-daemon.conf.5.xml.in | 21 +++++++++++++++++++-- + 1 files changed, 19 insertions(+), 2 deletions(-) + +diff --git a/man/pulse-daemon.conf.5.xml.in b/man/pulse-daemon.conf.5.xml.in +index a7c49a4..fe30016 100644 +--- a/man/pulse-daemon.conf.5.xml.in ++++ b/man/pulse-daemon.conf.5.xml.in +@@ -268,9 +268,9 @@ USA. + + + + + +@@ -297,6 +297,23 @@ USA. + might alter this setting.

+ + ++ ++ ++ ++ ++ ++ + + +
+-- +1.6.2.2 + diff --git a/0001-man-document-that-tsched-doesn-t-use-fragment-setti.patch b/0001-man-document-that-tsched-doesn-t-use-fragment-setti.patch new file mode 100644 index 0000000..0c80f92 --- /dev/null +++ b/0001-man-document-that-tsched-doesn-t-use-fragment-setti.patch @@ -0,0 +1,26 @@ +From 8adf1d5eea0750cea52a5ce8fb75d4331bf8a7cc Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Sun, 7 Jun 2009 00:45:21 +0200 +Subject: [PATCH] man: document that tsched doesn't use fragment settings + +--- + man/pulse-daemon.conf.5.xml.in | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/man/pulse-daemon.conf.5.xml.in b/man/pulse-daemon.conf.5.xml.in +index c23d8a7..68bcb77 100644 +--- a/man/pulse-daemon.conf.5.xml.in ++++ b/man/pulse-daemon.conf.5.xml.in +@@ -421,7 +421,8 @@ USA. + these buffer metrics for machines with high scheduling + latencies. Not all possible values that may be configured here are + available in all hardware. The driver will to find the nearest +- setting supported.

++ setting supported. Modern drivers that support timer-based ++ scheduling ignore these options.

+ +