introspect: Fix ABI break introduced by b98a2e1

The size of pa_card_profile_info cannot change even if it just a field
appended to end because each entry is appended to a contiguous memory
and accessed by offset this may lead clients to access invalid data.

To fix a new struct called pa_card_profile_info2 is introduced and shall
be used for now on while pa_card_profile_info shall be considered
deprecated but it is still mantained for backward compatibility.

A new field called profiles2 is introduced to pa_card_info, this new field
is an array of pointers to pa_card_profile_info2 so it should be possible
to append new fields to the end of the pa_card_profile_info2 without
breaking binary compatibility as the entries are not accessed by offset.
This commit is contained in:
Luiz Augusto von Dentz 2013-11-04 19:41:22 +02:00 committed by Tanu Kaskinen
parent 6dddee4214
commit 85e7fbc196
3 changed files with 75 additions and 35 deletions

View file

@ -570,13 +570,13 @@ static void get_card_info_callback(pa_context *c, const pa_card_info *i, int is_
pa_xfree(pl);
if (i->profiles) {
pa_card_profile_info *p;
if (i->n_profiles > 0) {
pa_card_profile_info2 **p;
printf(_("\tProfiles:\n"));
for (p = i->profiles; p->name; p++)
printf("\t\t%s: %s (sinks: %u, sources: %u, priority: %u, available: %s)\n", p->name,
p->description, p->n_sinks, p->n_sources, p->priority, pa_yes_no(p->available));
for (p = i->profiles2; *p; p++)
printf("\t\t%s: %s (sinks: %u, sources: %u, priority: %u, available: %s)\n", (*p)->name,
(*p)->description, (*p)->n_sinks, (*p)->n_sources, (*p)->priority, pa_yes_no((*p)->available));
}
if (i->active_profile)