From 798e39a5b686da5b5f0b0335cb21fc14c715f9e4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 27 Feb 2009 01:15:29 +0100 Subject: [PATCH] when alsa tweaks our sample_spec make sure we adjust the watermark accordingly --- src/modules/alsa/alsa-sink.c | 5 +++-- src/modules/alsa/alsa-source.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index a33dad4..0aef1bd 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1496,7 +1496,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca struct userdata *u = NULL; const char *dev_id = NULL; - pa_sample_spec ss; + pa_sample_spec ss, requested_ss; pa_channel_map map; uint32_t nfrags, hwbuf_size, frag_size, tsched_size, tsched_watermark; snd_pcm_uframes_t period_frames, tsched_frames; @@ -1515,6 +1515,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca goto fail; } + requested_ss = ss; frame_size = pa_frame_size(&ss); nfrags = m->core->default_n_fragments; @@ -1686,7 +1687,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca u->fragment_size = frag_size = (uint32_t) (period_frames * frame_size); u->nfragments = nfrags; u->hwbuf_size = u->fragment_size * nfrags; - u->tsched_watermark = tsched_watermark; + u->tsched_watermark = pa_usec_to_bytes_round_up(pa_bytes_to_usec_round_up(tsched_watermark, &requested_ss), &u->sink->sample_spec); pa_cvolume_mute(&u->hardware_volume, u->sink->sample_spec.channels); if (use_tsched) { diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 8ae190f..671df3f 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -1344,7 +1344,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p struct userdata *u = NULL; const char *dev_id = NULL; - pa_sample_spec ss; + pa_sample_spec ss, requested_ss; pa_channel_map map; uint32_t nfrags, hwbuf_size, frag_size, tsched_size, tsched_watermark; snd_pcm_uframes_t period_frames, tsched_frames; @@ -1362,6 +1362,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p goto fail; } + requested_ss = ss; frame_size = pa_frame_size(&ss); nfrags = m->core->default_n_fragments; @@ -1528,7 +1529,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p u->fragment_size = frag_size = (uint32_t) (period_frames * frame_size); u->nfragments = nfrags; u->hwbuf_size = u->fragment_size * nfrags; - u->tsched_watermark = tsched_watermark; + u->tsched_watermark = pa_usec_to_bytes_round_up(pa_bytes_to_usec_round_up(tsched_watermark, &requested_ss), &u->source->sample_spec); pa_cvolume_mute(&u->hardware_volume, u->source->sample_spec.channels); if (use_tsched) { -- 2.7.4