summaryrefslogtreecommitdiffstats
path: root/player/audio.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-16 14:24:15 +0200
committerwm4 <wm4@nowhere>2016-09-16 14:39:45 +0200
commit03fec24e192ea1b5c0cf957a5a64c0db9d33e67a (patch)
tree75f58b93ce56c3f6cd3afdbd3ce028f93dcf35bb /player/audio.c
parentb8ade7c99b830ee9870040bcfc1f2c3d3a64d172 (diff)
downloadmpv-03fec24e192ea1b5c0cf957a5a64c0db9d33e67a.tar.bz2
mpv-03fec24e192ea1b5c0cf957a5a64c0db9d33e67a.tar.xz
player: litter code with explicit wakeup calls
This does 3 kinds of changes: - change sleeptime=x to mp_set_timeout() - change sleeptime=0 to mp_wakeup_core() calls (to be more explicit) - change commands etc. to call mp_wakeup_core() if they do changes that require the playloop to be rerun This is preparation for the following changes. The goal is to process client API requests without having to rerun the playloop every time. As of this commit, the changes should not change behavior. In particular, the playloop is still implicitly woken up on every command.
Diffstat (limited to 'player/audio.c')
-rw-r--r--player/audio.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/player/audio.c b/player/audio.c
index 7bcd5c87bb..7990a4b77b 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -334,7 +334,7 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
if (!mp_audio_config_valid(&in_format)) {
// We don't know the audio format yet - so configure it later as we're
// resyncing. fill_audio_buffers() will call this function again.
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return;
}
@@ -427,7 +427,7 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
goto init_error;
reset_audio_state(mpctx);
ao_c->input_format = (struct mp_audio){0};
- mpctx->sleeptime = 0; // reinit with new format next time
+ mp_wakeup_core(mpctx); // reinit with new format next time
return;
}
@@ -550,7 +550,7 @@ void reinit_audio_chain_src(struct MPContext *mpctx, struct lavfi_pad *src)
mp_audio_buffer_reinit(ao_c->ao_buffer, &fmt);
}
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return;
init_error:
@@ -901,20 +901,20 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
return;
}
reinit_audio_filters_and_output(mpctx);
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return; // try again next iteration
}
if (ao_c->ao_resume_time > mp_time_sec()) {
double remaining = ao_c->ao_resume_time - mp_time_sec();
- mpctx->sleeptime = MPMIN(mpctx->sleeptime, remaining);
+ mp_set_timeout(mpctx, remaining);
return;
}
if (mpctx->vo_chain && ao_c->pts_reset) {
MP_VERBOSE(mpctx, "Reset playback due to audio timestamp reset.\n");
reset_playback_state(mpctx);
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return;
}
@@ -965,7 +965,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
if (status == AD_WAIT)
return;
if (status == AD_NO_PROGRESS) {
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return;
}
if (status == AD_NEW_FMT) {
@@ -976,11 +976,11 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
if (mpctx->opts->gapless_audio < 1)
uninit_audio_out(mpctx);
reinit_audio_filters_and_output(mpctx);
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return; // retry on next iteration
}
if (status == AD_ERR)
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
working = true;
}
@@ -1031,7 +1031,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
if (status != AD_OK && !mp_audio_buffer_samples(ao_c->ao_buffer))
mpctx->audio_status = STATUS_EOF;
if (working || end_sync)
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
return; // continue on next iteration
}
@@ -1089,7 +1089,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
if (ao_eof_reached(mpctx->ao) || opts->gapless_audio) {
mpctx->audio_status = STATUS_EOF;
if (!was_eof)
- mpctx->sleeptime = 0;
+ mp_wakeup_core(mpctx);
}
}
}