On Tue, 2012-10-23 at 16:41 +0200, Mikel Astiz wrote:
> From: Mikel Astiz <[email protected]>
> 
> Use the recently added core hook to detect when new profiles are added
> to a card, and update the D-Bus object accordingly.

> +static pa_hook_result_t card_profile_added_cb(void *hook_data, void 
> *call_data, void *slot_data) {
> +    pa_core *core = hook_data;
> +    pa_dbusiface_card *c = slot_data;
> +    pa_card_profile *profile = call_data;
> +    pa_dbusiface_card_profile *p;
> +
> +    if (!card_has_profile(c->card, profile))
> +        return PA_HOOK_OK;
> +
> +    if (pa_hashmap_get(c->profiles, profile->name) != NULL)
> +        return PA_HOOK_OK;
> +
> +    p = pa_dbusiface_card_profile_new(c, core, profile, 
> c->next_profile_index++);
> +    pa_hashmap_put(c->profiles, pa_dbusiface_card_profile_get_name(p), p);
> +
> +    return PA_HOOK_OK;
> +}

Why do you have the two checks in the beginning? As far as I can see,
the card will have the profile with 100% certainty, and also c->profiles
will not have the profile with 100% certainty.

The pa_hashmap_put() call could be inside pa_assert_se().

-- 
Tanu

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to