alsa: add spa_alsa_prepare()

Split the spa_alsa_start() in a prepare and start function. Prepare
will then also reset state and prefill the playback buffer with silence.

This makes it possible to reuse the prepare function in recover().
This commit is contained in:
Wim Taymans 2023-09-15 11:15:26 +02:00
parent a5d684af8a
commit e975cb16d3
2 changed files with 39 additions and 25 deletions

View file

@ -112,7 +112,9 @@ struct state {
struct spa_param_info params[N_NODE_PARAMS];
struct props props;
bool opened;
unsigned int opened:1;
unsigned int prepared:1;
unsigned int started:1;
snd_pcm_t *hndl;
bool have_format;
@ -170,7 +172,6 @@ struct state {
size_t ready_offset;
bool started;
/* Either a single source for tsched, or a set of pollfds from ALSA */
struct spa_source source[MAX_POLL];
int timerfd;
@ -241,6 +242,7 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info);
int spa_alsa_clear(struct state *state);
int spa_alsa_open(struct state *state, const char *params);
int spa_alsa_prepare(struct state *state);
int spa_alsa_start(struct state *state);
int spa_alsa_reassign_follower(struct state *state);
int spa_alsa_pause(struct state *state);