alsa: small cleanups

This commit is contained in:
Wim Taymans 2023-09-15 12:40:30 +02:00
parent c6745ed0d0
commit bf5b526464

View file

@ -2178,11 +2178,6 @@ static int update_time(struct state *state, uint64_t current_time, snd_pcm_sfram
return 0; return 0;
} }
static inline bool is_following(struct state *state)
{
return state->position && state->clock && state->position->clock.id != state->clock->id;
}
static int setup_matching(struct state *state) static int setup_matching(struct state *state)
{ {
state->matching = state->following; state->matching = state->following;
@ -2220,7 +2215,7 @@ static inline int check_position_config(struct state *state)
uint64_t target_duration; uint64_t target_duration;
struct spa_fraction target_rate; struct spa_fraction target_rate;
if (SPA_UNLIKELY(state->position == NULL)) if (SPA_UNLIKELY(state->position == NULL))
return 0; return 0;
if (state->disable_tsched && state->started && !state->following) { if (state->disable_tsched && state->started && !state->following) {
@ -2988,11 +2983,13 @@ int spa_alsa_start(struct state *state)
int spa_alsa_reassign_follower(struct state *state) int spa_alsa_reassign_follower(struct state *state)
{ {
bool following, freewheel; bool following, freewheel;
struct spa_io_position *pos = state->position;
struct spa_io_clock *clock = state->clock;
if (state->clock != NULL) if (clock != NULL)
spa_scnprintf(state->clock->name, sizeof(state->clock->name), "%s", state->clock_name); spa_scnprintf(clock->name, sizeof(clock->name), "%s", state->clock_name);
following = is_following(state); following = pos && clock && pos->clock.id != clock->id;
if (following != state->following) { if (following != state->following) {
spa_log_debug(state->log, "%p: reassign follower %d->%d", state, state->following, following); spa_log_debug(state->log, "%p: reassign follower %d->%d", state, state->following, following);
state->following = following; state->following = following;
@ -3001,8 +2998,7 @@ int spa_alsa_reassign_follower(struct state *state)
spa_loop_invoke(state->data_loop, do_setup_sources, 0, NULL, 0, true, state); spa_loop_invoke(state->data_loop, do_setup_sources, 0, NULL, 0, true, state);
} }
freewheel = state->position && freewheel = pos != NULL && SPA_FLAG_IS_SET(pos->clock.flags, SPA_IO_CLOCK_FLAG_FREEWHEEL);
SPA_FLAG_IS_SET(state->position->clock.flags, SPA_IO_CLOCK_FLAG_FREEWHEEL);
if (state->freewheel != freewheel) { if (state->freewheel != freewheel) {
spa_log_debug(state->log, "%p: freewheel %d->%d", state, state->freewheel, freewheel); spa_log_debug(state->log, "%p: freewheel %d->%d", state, state->freewheel, freewheel);