1515 * thread and sends it commands.
1616 *
1717 * The player thread itself does not do any I/O. It synchronizes with
18- * other threads via #GMutex and #GCond objects, and passes
18+ * other threads via #Mutex and #Cond objects, and passes
1919 * #MusicChunk instances around in #MusicPipe objects.
2020 */
2121
@@ -404,13 +404,11 @@ Player::StopDecoder(std::unique_lock<Mutex> &lock) noexcept
404404 decoder_starting = false ;
405405}
406406
407- bool
407+ inline bool
408408Player::ForwardDecoderError () noexcept
409409{
410- try {
411- dc.CheckRethrowError ();
412- } catch (...) {
413- pc.SetError (PlayerError::DECODER , std::current_exception ());
410+ if (dc.HasFailed ()) {
411+ pc.SetError (PlayerError::DECODER , dc.GetError ());
414412 return false ;
415413 }
416414
@@ -550,15 +548,16 @@ Player::OpenOutput() noexcept
550548 const ScopeUnlock unlock (pc.mutex );
551549 pc.outputs .Open (play_audio_format);
552550 } catch (...) {
553- LogError (std::current_exception ());
551+ auto error = std::current_exception ();
552+ LogError (error);
554553
555554 output_open = false ;
556555
557556 /* pause: the user may resume playback as soon as an
558557 audio output becomes available */
559558 paused = true ;
560559
561- pc.SetOutputError (std::current_exception ( ));
560+ pc.SetOutputError (std::move (error ));
562561
563562 return false ;
564563 }
@@ -585,7 +584,7 @@ Player::CheckDecoderStartup(std::unique_lock<Mutex> &lock) noexcept
585584
586585 if (output_open &&
587586 !pc.WaitOutputConsumed (lock, 1 ))
588- /* the output devices havn 't finished playing
587+ /* the output devices haven 't finished playing
589588 all chunks yet - wait for that */
590589 return true ;
591590
@@ -837,9 +836,11 @@ Player::ProcessCommand(std::unique_lock<Mutex> &lock) noexcept
837836 pc.outputs .CheckPipe ();
838837 }
839838
840- pc.elapsed_time = !pc.outputs .GetElapsedTime ().IsNegative ()
841- ? SongTime (pc.outputs .GetElapsedTime ())
842- : elapsed_time;
839+ if (const auto outputs_time = pc.outputs .GetElapsedTime ();
840+ !outputs_time.IsNegative ())
841+ pc.elapsed_time = static_cast <SongTime>(outputs_time);
842+ else
843+ pc.elapsed_time = elapsed_time;
843844
844845 pc.CommandFinished ();
845846 break ;
@@ -858,16 +859,15 @@ Player::CheckCrossFade() noexcept
858859 if (pc.border_pause ) {
859860 /* no cross-fading if MPD is going to pause at the end
860861 of the current song */
861- xfade_state = CrossFadeState::UNKNOWN ;
862862 return ;
863863 }
864864
865865 if (!IsDecoderAtNextSong () || dc.IsStarting () || dc.pipe ->IsEmpty ())
866866 /* we need information about the next song before we
867867 can decide */
868868 /* the "pipe.empty" check is here so we wait for all
869- (ReplayGain/MixRamp) metadata to appear, which some
870- decoders parse only after reporting readiness */
869+ (ReplayGain/MixRamp) metadata to appear, which some
870+ decoders parse only after reporting readiness */
871871 return ;
872872
873873 if (!pc.cross_fade .CanCrossFade (pc.total_time , dc.total_time ,
@@ -986,7 +986,7 @@ Player::PlayNextChunk() noexcept
986986 std::move (other_chunk->tag ));
987987
988988 if (pc.cross_fade .mixramp_delay <= FloatDuration::zero ()) {
989- chunk->mix_ratio = (( float ) cross_fade_position)
989+ chunk->mix_ratio = static_cast < float >( cross_fade_position)
990990 / cross_fade_chunks;
991991 } else {
992992 chunk->mix_ratio = -1 ;
@@ -1042,15 +1042,16 @@ Player::PlayNextChunk() noexcept
10421042 pc.PlayChunk (*song, std::move (chunk),
10431043 play_audio_format);
10441044 } catch (...) {
1045- LogError (std::current_exception ());
1045+ auto error = std::current_exception ();
1046+ LogError (error);
10461047
10471048 chunk.reset ();
10481049
10491050 /* pause: the user may resume playback as soon as an
10501051 audio output becomes available */
10511052 paused = true ;
10521053
1053- pc.LockSetOutputError (std::current_exception ( ));
1054+ pc.LockSetOutputError (std::move (error ));
10541055
10551056 return false ;
10561057 }
0 commit comments