[pulseaudio-discuss] [PATCH] card-restore: Add the ability to save and restore the latency offset.

Tanu Kaskinen tanuk at iki.fi
Thu Jul 5 01:13:41 PDT 2012


On Thu, 2012-07-05 at 00:57 +0200, poljar (Damir Jelić) wrote:
> module-card-restore now saves the latency offsets.
> 
> This change includes a entry version bump.
> 
> The entry now consists of a port count and a port name and offset for
> every port that belongs to the relevant card.

Thanks! Some small issues still, but I've fixed them myself and pushed
the patch.

>  struct entry {
>      uint8_t version;
>      char *profile;
> +    uint32_t port_count;
> +    pa_hashmap *port_info;

port_count isn't needed anymore, because you can use pa_hashmap_size().

I'd prefer plural for the hashmap name, "port_infos" or just "ports".

> +static void port_info_free(struct port_info *p_info, void *userdata) {

Coding style: functions should always assert that pointer parameters are
not NULL (unless NULL is an accepted value, of course).

> +    pa_xfree(p_info->name);
> +    pa_xfree(p_info);
> +}

> @@ -201,6 +224,28 @@ static struct entry* entry_read(struct userdata *u, const char *name) {
>  
>      e->profile = pa_xstrdup(profile);
>  
> +    if (e->version >= 2) {
> +        const char *port_name = NULL;
> +        int64_t port_offset = 0;
> +        struct port_info *p_info;
> +        unsigned i;
> +
> +        if (pa_tagstruct_getu32(t, &e->port_count) < 0)
> +            goto fail;
> +
> +        for (i = 0; i < e->port_count; i++) {
> +            if (pa_tagstruct_gets(t, &port_name) < 0 ||

I didn't realize this earlier: it needs to be checked that port_name is
not NULL. pa_hashmap_put() will otherwise crash if the database file
contains a NULL port name for some reason. Also, it needs to be checked
that the hashmap doesn't already contain the port (that is, the database
doesn't contain duplicate port names).

-- 
Tanu



More information about the pulseaudio-discuss mailing list