Rename "stop" to "interrupt"

The purpose of video_buffer_stop() is to interrupt any blocking call, so
rename it to video_buffer_interrupt().
This commit is contained in:
Romain Vimont 2019-03-02 17:01:52 +01:00
parent fff87095d9
commit 84270e2d18
3 changed files with 7 additions and 7 deletions

View file

@ -317,7 +317,7 @@ SDL_bool decoder_start(struct decoder *decoder) {
} }
void decoder_stop(struct decoder *decoder) { void decoder_stop(struct decoder *decoder) {
video_buffer_stop(decoder->video_buffer); video_buffer_interrupt(decoder->video_buffer);
} }
void decoder_join(struct decoder *decoder) { void decoder_join(struct decoder *decoder) {

View file

@ -27,7 +27,7 @@ SDL_bool video_buffer_init(struct video_buffer *vb) {
SDL_DestroyMutex(vb->mutex); SDL_DestroyMutex(vb->mutex);
goto error_2; goto error_2;
} }
vb->stopped = SDL_FALSE; vb->interrupted = SDL_FALSE;
#endif #endif
// there is initially no rendering frame, so consider it has already been // there is initially no rendering frame, so consider it has already been
@ -65,7 +65,7 @@ SDL_bool video_buffer_offer_decoded_frame(struct video_buffer *vb) {
#ifndef SKIP_FRAMES #ifndef SKIP_FRAMES
// if SKIP_FRAMES is disabled, then the decoder must wait for the current // if SKIP_FRAMES is disabled, then the decoder must wait for the current
// frame to be consumed // frame to be consumed
while (!vb->rendering_frame_consumed && !vb->stopped) { while (!vb->rendering_frame_consumed && !vb->interrupted) {
cond_wait(vb->rendering_frame_consumed_cond, vb->mutex); cond_wait(vb->rendering_frame_consumed_cond, vb->mutex);
} }
#else #else
@ -97,12 +97,12 @@ const AVFrame *video_buffer_consume_rendered_frame(struct video_buffer *vb) {
return vb->rendering_frame; return vb->rendering_frame;
} }
void video_buffer_stop(struct video_buffer *vb) { void video_buffer_interrupt(struct video_buffer *vb) {
#ifdef SKIP_FRAMES #ifdef SKIP_FRAMES
(void) vb; // unused (void) vb; // unused
#else #else
mutex_lock(vb->mutex); mutex_lock(vb->mutex);
vb->stopped = SDL_TRUE; vb->interrupted = SDL_TRUE;
mutex_unlock(vb->mutex); mutex_unlock(vb->mutex);
// wake up blocking wait // wake up blocking wait
cond_signal(vb->rendering_frame_consumed_cond); cond_signal(vb->rendering_frame_consumed_cond);

View file

@ -15,7 +15,7 @@ struct video_buffer {
AVFrame *rendering_frame; AVFrame *rendering_frame;
SDL_mutex *mutex; SDL_mutex *mutex;
#ifndef SKIP_FRAMES #ifndef SKIP_FRAMES
SDL_bool stopped; SDL_bool interrupted;
SDL_cond *rendering_frame_consumed_cond; SDL_cond *rendering_frame_consumed_cond;
#endif #endif
SDL_bool rendering_frame_consumed; SDL_bool rendering_frame_consumed;
@ -37,6 +37,6 @@ SDL_bool video_buffer_offer_decoded_frame(struct video_buffer *vb);
const AVFrame *video_buffer_consume_rendered_frame(struct video_buffer *vb); const AVFrame *video_buffer_consume_rendered_frame(struct video_buffer *vb);
// wake up and avoid any blocking call // wake up and avoid any blocking call
void video_buffer_stop(struct video_buffer *vb); void video_buffer_interrupt(struct video_buffer *vb);
#endif #endif