Skip to content

Commit

Permalink
restore playback_mod
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Jan 7, 2025
1 parent 90aec59 commit 5752e11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions feeluown/player/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def __init__(self, app: 'App', songs=None, playback_mode=PlaybackMode.loop,
#: store value for ``songs`` property
self._songs = DedupList(songs or [])
# Acquire this lock before changing _current_song or _songs.
# TODO: use emit_nowait???
# NOTE: some methods emit some signal while holding the lock,
# the signal handler should pay much attention to avoid deadlock.
# One thing is that the signal handler should not call any method
# that requires the lock!!!
self._songs_lock = Lock()

self.audio_select_policy = audio_select_policy
Expand Down Expand Up @@ -166,13 +169,13 @@ def mode(self):
def mode(self, mode):
"""set playlist mode"""
if self._mode is not mode:
# we should change _mode at the very end
self._mode = mode
if mode is PlaylistMode.fm:
self._normal_mode_playback_mode = self.playback_mode
self.playback_mode = PlaybackMode.sequential
else:
self.playback_mode = self._normal_mode_playback_mode
# we should change _mode at the very end
self._mode = mode
self.mode_changed.emit(mode)
logger.info('playlist mode changed to %s', mode)

Expand Down
2 changes: 1 addition & 1 deletion tests/player/test_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def mock_prepare_metadata(mocker):
async def test_playlist_change_mode(app_mock, mocker):
# from normal to fm
pl = Playlist(app_mock)
pl.mode = PlaylistMode.fm
old_playback_mode = pl.playback_mode
pl.mode = PlaylistMode.fm
assert pl.playback_mode is PlaybackMode.sequential

# from fm to normal
Expand Down

0 comments on commit 5752e11

Please sign in to comment.