[pulseaudio-discuss] [PATCH v2 4/4] native-protocol: send supported extensions in client & server
Lennart Poettering
lennart at poettering.net
Mon May 11 17:34:55 PDT 2009
On Tue, 12.05.09 01:35, Marc-André Lureau (marc-andre.lureau at nokia.com) wrote:
> +/** Check if "extension" is supported in server side. \since 0.9.16 */
> +int pa_context_extension_supported(pa_context *c, const char *extension);
> +
> PA_C_DECL_END
This function should be private for now. We don't allow implementing
extensions out-of-tree for now, so there is noch much need for it for
external programs. This should move to internal.h. Later on we can
make this public again.
> +++ b/src/pulse/xmalloc.h
> @@ -91,6 +91,19 @@ static inline void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) {
> /** Same as pa_xnew() but set the memory to zero */
> #define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
>
> +/** Free a string array and its strings */
> +static inline void pa_strv_free(char *strv[]) {
> + unsigned i;
> +
> + if (!strv)
> + return;
> +
> + for (i = 0; strv[i]; ++i)
> + pa_xfree(strv[i]);
> +
> + pa_xfree(strv);
> +}
> +
> PA_C_DECL_END
Grmbl. This is a public header. We already have enough cruft public,
I'd rather see this is pulsecore/core-util.h. Also I doubt the
compiler would inline this, so this should be normal function.
> #endif
> diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
> index f96fa44..6f929e4 100644
> --- a/src/pulsecore/core-util.h
> +++ b/src/pulsecore/core-util.h
> @@ -201,6 +201,22 @@ pa_bool_t pa_in_system_mode(void);
>
> #define pa_streq(a,b) (!strcmp((a),(b)))
>
> +static inline int pa_strv_index(const char * const *strv, const char *needle, unsigned *idx) {
> + unsigned i;
> +
> + if (!strv)
> + return -1;
> +
> + for (i = 0; strv[i]; ++i)
> + if (pa_streq(strv[i], needle)) {
> + if (idx)
> + *idx = i;
> + return 0;
> + }
> +
> + return -1;
> +}
> +
Should be a normal function too. No inline.
> @@ -2410,14 +2427,29 @@ static void command_set_client_name(pa_pdispatch *pd, uint32_t command, uint32_t
> p = pa_proplist_new();
>
> if ((c->version < 13 && pa_tagstruct_gets(t, &name) < 0) ||
> - (c->version >= 13 && pa_tagstruct_get_proplist(t, p) < 0) ||
> - !pa_tagstruct_eof(t)) {
> + (c->version >= 13 && pa_tagstruct_get_proplist(t, p) < 0))
> + goto error;
>
> - protocol_error(c);
> - pa_proplist_free(p);
> - return;
> + if (c->version >= 16) {
> + uint32_t n;
> +
> + if (pa_tagstruct_getu32(t, &n) < 0)
> + goto error;
> +
> + c->supported_extensions = pa_xnew(char *, n + 1);
> + c->supported_extensions[n] = NULL;
> +
> + while (n) {
> + --n;
> + if (pa_tagstruct_gets(t, &ext) < 0)
> + goto error;
> + c->supported_extensions[n] = pa_xstrdup(ext);
> + }
I think we should only store information about extension we ourselves
understand. i.e. Nego should happen at startup and then stay
static.
Otherwise I am happy!
Lennart
--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
More information about the pulseaudio-discuss
mailing list