[PATCH 2/2] alsa-ucm: Add mechanism to prevent auto-suspend of sources/sinks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2013-08-08 at 10:53 +0530, Arun Raghavan wrote:
> This is required for things like modem PCMs on phones that are
> essentially fake devices that need to be kept open for the correspnding
> route (modem -> CODEC) to remain active.
> ---
>  src/modules/alsa/alsa-mixer.h  |  3 +++
>  src/modules/alsa/alsa-sink.c   |  2 +-
>  src/modules/alsa/alsa-source.c |  4 +++-
>  src/modules/alsa/alsa-ucm.c    | 13 +++++++++++++
>  src/modules/alsa/alsa-ucm.h    |  3 +++
>  5 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
> index 995a34b..a4a2345 100644
> --- a/src/modules/alsa/alsa-mixer.h
> +++ b/src/modules/alsa/alsa-mixer.h
> @@ -272,6 +272,9 @@ struct pa_alsa_mapping {
>      pa_sink *sink;
>      pa_source *source;
>  
> +    /* Inhibit auto-suspend */
> +    bool always_running;
> +
>      /* ucm device context*/
>      pa_alsa_ucm_mapping_context ucm_context;
>  };
> diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
> index 261536a..d98e9de 100644
> --- a/src/modules/alsa/alsa-sink.c
> +++ b/src/modules/alsa/alsa-sink.c
> @@ -2298,7 +2298,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
>          pa_alsa_add_ports(&data, u->mixer_path_set, card);
>  
>      u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE | PA_SINK_LATENCY | (u->use_tsched ? PA_SINK_DYNAMIC_LATENCY : 0) |
> -                          (set_formats ? PA_SINK_SET_FORMATS : 0));
> +                          (set_formats ? PA_SINK_SET_FORMATS : 0) | (mapping->always_running ? PA_SINK_ALWAYS_RUNNING : 0));
>      pa_sink_new_data_done(&data);
>  
>      if (!u->sink) {
> diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
> index 4660c6a..2776daa 100644
> --- a/src/modules/alsa/alsa-source.c
> +++ b/src/modules/alsa/alsa-source.c
> @@ -1996,7 +1996,9 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
>      else if (u->mixer_path_set)
>          pa_alsa_add_ports(&data, u->mixer_path_set, card);
>  
> -    u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY|(u->use_tsched ? PA_SOURCE_DYNAMIC_LATENCY : 0));
> +    u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE | PA_SOURCE_LATENCY |
> +                              (u->use_tsched ? PA_SOURCE_DYNAMIC_LATENCY : 0) |
> +                              (mapping->always_running ? PA_SOURCE_ALWAYS_RUNNING : 0));
>      pa_source_new_data_done(&data);
>  
>      if (!u->source) {
> diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
> index 787dc9e..1025752 100644
> --- a/src/modules/alsa/alsa-ucm.c
> +++ b/src/modules/alsa/alsa-ucm.c
> @@ -92,6 +92,8 @@ static struct ucm_items item[] = {
>      {"CaptureRate", PA_ALSA_PROP_UCM_CAPTURE_RATE},
>      {"CaptureChannels", PA_ALSA_PROP_UCM_CAPTURE_CHANNELS},
>      {"TQ", PA_ALSA_PROP_UCM_QOS},
> +    /* PulseAudio-specific flag */
> +    {"AlwaysRunning", PA_ALSA_PROP_UCM_ALWAYS_RUNNING},

The UCM configuration should describe the hardware, not tell PulseAudio
how to manage sink suspending (I hope that in the long term we'll have
some better solution so that there won't be any sinks for this sort of
devices). I don't know what the Value item name should be, but I think
you should try to answer this question: what property of the hardware
makes it such that PulseAudio should apply the "always running" policy?
And try to get the item name standardized so that it isn't specific to
PulseAudio (and specific to how PulseAudio works today).

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux