From: Sangchul Lee Date: Mon, 14 May 2018 07:29:19 +0000 (+0900) Subject: sink, alsa-sink: Add conditions for selected sample rate X-Git-Tag: submit/tizen/20180601.091654~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=872fb5deaa3b7df76686fcd5c0a5b6c0afd7984a;p=platform%2Fupstream%2Fpulseaudio.git sink, alsa-sink: Add conditions for selected sample rate [Version] 11.1-36 [Issue Type] Feature Change-Id: I1385b7de93b1fec7b3bbc6baf016bdb73b8ba15d Signed-off-by: Sangchul Lee --- diff --git a/packaging/pulseaudio.spec b/packaging/pulseaudio.spec index 0a79e6a..519c34c 100644 --- a/packaging/pulseaudio.spec +++ b/packaging/pulseaudio.spec @@ -3,7 +3,7 @@ Name: pulseaudio Summary: Improved Linux sound server Version: 11.1 -Release: 35 +Release: 36 Group: Multimedia/Audio License: LGPL-2.1 URL: http://pulseaudio.org diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 582f106..402b441 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -2391,6 +2391,9 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca u->sink->set_port = sink_set_port_cb; u->sink->reconfigure = sink_reconfigure_cb; u->sink->userdata = u; +#ifdef __TIZEN__ + u->sink->supported_sample_rates = u->rates; +#endif pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq); pa_sink_set_rtpoll(u->sink, u->rtpoll); diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index dad0cc8..5d3445b 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -338,6 +338,7 @@ pa_sink* pa_sink_new( s->alternate_sample_rate = s->core->alternate_sample_rate; #ifdef __TIZEN__ s->avoid_resampling = data->avoid_resampling; + s->selected_sample_rate = s->default_sample_rate; #endif s->inputs = pa_idxset_new(NULL, NULL); @@ -1554,13 +1555,21 @@ int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, bool passthrough) { /* We currently only try to reconfigure the sample rate */ +#ifdef __TIZEN__ + if (!s->selected_sample_rate && !avoid_resampling && pa_sample_spec_equal(spec, &s->sample_spec)) +#else if (pa_sample_spec_equal(spec, &s->sample_spec)) +#endif return 0; if (!s->reconfigure) return -1; +#ifdef __TIZEN__ + if (!s->selected_sample_rate && PA_UNLIKELY(default_rate == alternate_rate && !passthrough && !avoid_resampling)) { +#else if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough && !avoid_resampling)) { +#endif pa_log_debug("Default and alternate sample rates are the same, so there is no point in switching."); return -1; } @@ -1583,6 +1592,10 @@ int pa_sink_reconfigure(pa_sink *s, pa_sample_spec *spec, bool passthrough) { desired_spec = s->sample_spec; +#ifdef __TIZEN__ + if (!avoid_resampling && s->selected_sample_rate) + default_rate = alternate_rate = s->selected_sample_rate; +#endif if (passthrough) { /* We have to try to use the sink input rate */ desired_spec.rate = spec->rate; diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h index 2d6c80d..07de5be 100644 --- a/src/pulsecore/sink.h +++ b/src/pulsecore/sink.h @@ -85,6 +85,8 @@ struct pa_sink { uint32_t alternate_sample_rate; #ifdef __TIZEN__ bool avoid_resampling:1; + uint32_t *supported_sample_rates; + uint32_t selected_sample_rate; #endif pa_idxset *inputs;