diff --git a/spa/plugins/alsa/alsa-udev.c b/spa/plugins/alsa/alsa-udev.c index 7d1ae9a3a..b05bd7d06 100644 --- a/spa/plugins/alsa/alsa-udev.c +++ b/spa/plugins/alsa/alsa-udev.c @@ -39,6 +39,14 @@ enum action { /* Used for unavailable devices in the card structure. */ #define ID_DEVICE_NOT_SUPPORTED 0 +#define MAX_PARENT_TRAVERSAL_DEPTH 5 + +enum wireless_status { + WIRELESS_STATUS_UNKNOWN = 0, + WIRELESS_STATUS_CONNECTED, + WIRELESS_STATUS_DISCONNECTED, +}; + /* This represents an ALSA card. * One card can have up to 1 PCM and 1 Compress-Offload device. */ struct card { @@ -48,6 +56,7 @@ struct card { unsigned int accessible:1; unsigned int ignored:1; unsigned int emitted:1; + unsigned int wireless_disconnected:1; /* Local SPA object IDs. (Global IDs are produced by PipeWire * out of this using its registry.) Compress-Offload or PCM @@ -59,6 +68,8 @@ struct card { * is used because 0 is a valid ALSA card number. */ uint32_t pcm_device_id; uint32_t compress_offload_device_id; + + char *wireless_status_path; }; static uint32_t calc_pcm_device_id(struct card *card) @@ -144,14 +155,19 @@ static struct card *find_card(struct impl *this, unsigned int card_nr) static void remove_card(struct impl *this, struct card *card) { udev_device_unref(card->udev_device); - *card = this->cards[--this->n_cards]; + free(card->wireless_status_path); + this->n_cards--; + if (card != &this->cards[this->n_cards]) + *card = this->cards[this->n_cards]; } static void clear_cards(struct impl *this) { unsigned int i; - for (i = 0; i < this->n_cards; i++) + for (i = 0; i < this->n_cards; i++) { udev_device_unref(this->cards[i].udev_device); + free(this->cards[i].wireless_status_path); + } this->n_cards = 0; }