mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: refactor a bit
Make spa_alsa_close() do spa_alsa_pause() first and also clear the format.
This commit is contained in:
parent
13923416e0
commit
25bfc9c63d
3 changed files with 9 additions and 11 deletions
|
|
@ -644,11 +644,8 @@ static int port_set_format(void *object,
|
|||
return 0;
|
||||
|
||||
spa_log_debug(this->log, "clear format");
|
||||
this->card->format_ref--;
|
||||
spa_alsa_pause(this);
|
||||
clear_buffers(this);
|
||||
spa_alsa_close(this);
|
||||
this->have_format = false;
|
||||
clear_buffers(this);
|
||||
} else {
|
||||
struct spa_audio_info info = { 0 };
|
||||
|
||||
|
|
@ -679,7 +676,6 @@ static int port_set_format(void *object,
|
|||
return err;
|
||||
|
||||
this->current_format = info;
|
||||
this->have_format = true;
|
||||
}
|
||||
|
||||
this->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;
|
||||
|
|
@ -1025,7 +1021,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->multi_rate = spa_atob(s);
|
||||
}
|
||||
}
|
||||
|
||||
return spa_alsa_init(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -587,11 +587,8 @@ static int port_set_format(void *object,
|
|||
return 0;
|
||||
|
||||
spa_log_debug(this->log, "clear format");
|
||||
this->card->format_ref--;
|
||||
spa_alsa_pause(this);
|
||||
clear_buffers(this);
|
||||
spa_alsa_close(this);
|
||||
this->have_format = false;
|
||||
clear_buffers(this);
|
||||
} else {
|
||||
struct spa_audio_info info = { 0 };
|
||||
|
||||
|
|
@ -609,7 +606,6 @@ static int port_set_format(void *object,
|
|||
return err;
|
||||
|
||||
this->current_format = info;
|
||||
this->have_format = true;
|
||||
}
|
||||
|
||||
this->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;
|
||||
|
|
|
|||
|
|
@ -176,6 +176,8 @@ int spa_alsa_close(struct state *state)
|
|||
if (!state->opened)
|
||||
return 0;
|
||||
|
||||
spa_alsa_pause(state);
|
||||
|
||||
spa_log_info(state->log, "%p: Device '%s' closing", state, state->props.device);
|
||||
if ((err = snd_pcm_close(state->hndl)) < 0)
|
||||
spa_log_warn(state->log, "%s: close failed: %s", state->props.device,
|
||||
|
|
@ -186,6 +188,10 @@ int spa_alsa_close(struct state *state)
|
|||
|
||||
spa_system_close(state->data_system, state->timerfd);
|
||||
|
||||
if (state->have_format)
|
||||
state->card->format_ref--;
|
||||
|
||||
state->have_format = false;
|
||||
state->opened = false;
|
||||
|
||||
return err;
|
||||
|
|
@ -1022,6 +1028,7 @@ int spa_alsa_set_format(struct state *state, struct spa_audio_info *fmt, uint32_
|
|||
else
|
||||
state->frame_size *= rchannels;
|
||||
|
||||
state->have_format = true;
|
||||
if (state->card->format_ref++ == 0)
|
||||
state->card->rate = rrate;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue