[pulseaudio-discuss] [PATCH] introspect: Expose card profile available flag

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Mon Jul 15 03:00:31 PDT 2013


On Fri, 2013-07-12 at 18:18 +0300, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>
> 
> Available flag can be used by clients to disable the selection of
> profiles unavailable.
> 
> Update protocol to 29
> ---
>  PROTOCOL                        |  9 +++++++++
>  configure.ac                    |  2 +-
>  src/pulse/introspect.c          | 33 ++++++++++++++++++---------------
>  src/pulse/introspect.h          |  1 +
>  src/pulsecore/protocol-native.c |  3 +++
>  5 files changed, 32 insertions(+), 16 deletions(-)

> diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
> index 334ffd9..32de8a6 100644
> --- a/src/pulse/introspect.c
> +++ b/src/pulse/introspect.c
> @@ -902,11 +898,15 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u
>                          pa_tagstruct_gets(t, &i.profiles[j].description) < 0 ||
>                          pa_tagstruct_getu32(t, &i.profiles[j].n_sinks) < 0 ||
>                          pa_tagstruct_getu32(t, &i.profiles[j].n_sources) < 0 ||
> -                        pa_tagstruct_getu32(t, &i.profiles[j].priority) < 0) {
> +                        pa_tagstruct_getu32(t, &i.profiles[j].priority) < 0)
> +                            goto fail;
>  
> -                        pa_context_fail(o->context, PA_ERR_PROTOCOL);
> -                        card_info_free(&i);
> -                        goto finish;
> +                    i.profiles[j].available = 1;
> +                    if (o->context->version >= 29) {
> +                        uint32_t av;
> +                        if (pa_tagstruct_getu32(t, &av) < 0)
> +                            goto fail;
> +                        i.ports[0][j].available = av;

I presume this should be i.profiles[j].available = av;

>                      }
>                  }
>  
> @@ -934,11 +934,8 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u
>              }
>  
>              if (o->context->version >= 26) {
> -                if (fill_card_port_info(o->context, t, &i) < 0) {
> -                    pa_context_fail(o->context, PA_ERR_PROTOCOL);
> -                    card_info_free(&i);
> -                    goto finish;
> -                }
> +                if (fill_card_port_info(o->context, t, &i) < 0)
> +                    goto fail;
>              }
>  
>              if (o->callback) {
> @@ -958,6 +955,12 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u
>  finish:
>      pa_operation_done(o);
>      pa_operation_unref(o);
> +    return;
> +
> +fail:
> +    pa_context_fail(o->context, PA_ERR_PROTOCOL);
> +    card_info_free(&i);
> +    goto finish;
>  }
>  
>  pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_card_info_cb_t cb, void *userdata) {
> diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h
> index a833471..23776bc 100644
> --- a/src/pulse/introspect.h
> +++ b/src/pulse/introspect.h
> @@ -452,6 +452,7 @@ typedef struct pa_card_profile_info {
>      uint32_t n_sinks;                   /**< Number of sinks this profile would create */
>      uint32_t n_sources;                 /**< Number of sources this profile would create */
>      uint32_t priority;                  /**< The higher this value is, the more useful this profile is as a default. */
> +    int available;                      /**< A flags indicating availability status of this profile. \since 5.0 */

I would like more elaborate documentation. A suggestion:

    int available;
    /**< Is this profile available? If this is zero, meaning "unavailable",
     * then it makes no sense to try to activate this profile. If this is
     * non-zero, it's still not a guarantee that activating the profile will
     * result in anything useful, it just means that the server isn't aware of
     * any reason why the profile would definitely be useless. \since 5.0 */

-- 
Tanu



More information about the pulseaudio-discuss mailing list