X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fplayer.cpp;h=b871fa1f3c62ac4176b2c0138c312749410fda7d;hb=b44bf7cfce6a5aaffbcd1e37df39068a163438ad;hp=7c38821c395d55a7fd25dc1ed70a182b0f73c01e;hpb=c18585d1f7b4476c74c4c5a064cb3ce357c644ae;p=nageru diff --git a/futatabi/player.cpp b/futatabi/player.cpp index 7c38821..b871fa1 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -427,20 +427,20 @@ Player::~Player() void Player::play(const vector &clips) { - { - lock_guard lock(queue_state_mu); - new_clip_ready = true; - queued_clip_list = clips; - override_stream_idx = -1; - new_clip_changed.notify_all(); - } + lock_guard lock(queue_state_mu); + new_clip_ready = true; + queued_clip_list = clips; + override_stream_idx = -1; + new_clip_changed.notify_all(); } void Player::override_angle(unsigned stream_idx) { + int64_t last_pts; + // Corner case: If a new clip is waiting to be played, change its stream and then we're done. { - unique_lock lock(queue_state_mu); + lock_guard lock(queue_state_mu); if (new_clip_ready) { assert(queued_clip_list.size() == 1); queued_clip_list[0].stream_idx = stream_idx; @@ -454,14 +454,10 @@ void Player::override_angle(unsigned stream_idx) new_clip_changed.notify_all(); return; } - } - // OK, so we're standing still, presumably at the end of a clip. - // Look at the last frame played (if it exists), and show the closest - // thing we've got. - int64_t last_pts; - { - lock_guard lock(queue_state_mu); + // OK, so we're standing still, presumably at the end of a clip. + // Look at the last frame played (if it exists), and show the closest + // thing we've got. if (last_pts_played < 0) { return; } @@ -478,13 +474,13 @@ void Player::override_angle(unsigned stream_idx) void Player::take_queue_spot() { - unique_lock lock(queue_state_mu); + lock_guard lock(queue_state_mu); ++num_queued_frames; } void Player::release_queue_spot() { - unique_lock lock(queue_state_mu); + lock_guard lock(queue_state_mu); assert(num_queued_frames > 0); --num_queued_frames; new_clip_changed.notify_all();