mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: alsa: do not look up the card again when releasing
Currently, `release_card()` uses `find_card()` to find the card by the index stored in the state object. However, `find_card()` increments the reference count of the object, therefore `release_card()` will drop the reference that it has just created by calling `find_card()` and not the "calling scope's" reference. This prevents the card objects from being freed when the SPA handle is cleared. Fix it by having `release_card()` take a pointer to the card and not its index.
This commit is contained in:
parent
ee0963b68e
commit
b04b52ecf8
1 changed files with 6 additions and 5 deletions
|
|
@ -72,11 +72,9 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void release_card(uint32_t index)
|
||||
static void release_card(struct card *c)
|
||||
{
|
||||
struct card *c;
|
||||
if ((c = find_card(index)) == NULL)
|
||||
return;
|
||||
spa_assert(c->ref > 0);
|
||||
|
||||
if (--c->ref > 0)
|
||||
return;
|
||||
|
|
@ -420,8 +418,11 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info)
|
|||
|
||||
int spa_alsa_clear(struct state *state)
|
||||
{
|
||||
release_card(state->card_index);
|
||||
release_card(state->card);
|
||||
|
||||
state->card = NULL;
|
||||
state->card_index = SPA_ID_INVALID;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue