Round 17: task batch + cruft sweep (ratings, art download, MPRIS/exit/BT fixes)
Features:
- Rating hover dots: hovering a rating cell shows 5 clickable slots
(RatingDelegate); click slot k sets k stars, clicking the current count
clears. Undoable, library-only (ratings never rewrite music files).
- Search bar moved into the Library header strip, right of the Library
button, so the tracklist top aligns with the playlist tree.
- Right-click "Download Album Art…": iTunes Search API (no key), off-thread
fetch, preview/confirm dialog with Next Result, embeds via write_artwork
+ size refresh, invalidates the MPRIS art cache.
Fixes:
- MPRIS media keys: PropertiesChanged sent invalidated_properties as "av"
instead of "as", so gsd-media-keys dropped it and never MRU-bumped
lintunes (why the play/pause key kept waking stale players). Now an
explicit QDBusArgument string array; loopback-verified sa{sv}as.
- Exit segfault: ordered Player.shutdown() (stop, clear source, detach
buffer/audio outputs) from closeEvent/aboutToQuit; scripted run exits 0.
- BT zero-volume after pause/resume: volume re-applied on resume, device
swap, and BufferedMedia (needs verify on the affected machine).
Cruft sweep:
- Tag writes filtered to EDITABLE_FIELDS; failures logged + surfaced in
the status bar (was a swallowed print).
- O(n²) import fixed (location index + cached max track id); O(1)
refresh/reveal via TrackTableModel row index.
- lastfm: scrobble-queue thread lock, login prefs write marshalled to the
GUI thread, JSON/raise_for_status order fixed.
- Shared read_json/write_json; TableSettingsMixin dedupes view settings.
TASKS.md rewritten as a resumable board; tests in tests/test_round17.py
(251 total pass).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+34
-1
@@ -74,6 +74,27 @@ class Player(QObject):
|
||||
self._media.mediaStatusChanged.connect(self._on_media_status)
|
||||
self._media.errorOccurred.connect(self._on_error)
|
||||
|
||||
self._shutdown_done = False
|
||||
|
||||
def shutdown(self):
|
||||
"""Tear down the Qt Multimedia pipeline in a safe order before Qt
|
||||
destroys the objects. Without this, QObject children are destroyed in
|
||||
creation order at exit — the QAudioOutput dies while the QMediaPlayer
|
||||
(FFmpeg backend) still references it, which segfaults after the GUI is
|
||||
gone. Idempotent; wired to both closeEvent and aboutToQuit."""
|
||||
if self._shutdown_done:
|
||||
return
|
||||
self._shutdown_done = True
|
||||
try:
|
||||
self._media_devices.audioOutputsChanged.disconnect(
|
||||
self._on_audio_outputs_changed)
|
||||
except TypeError:
|
||||
pass
|
||||
self._media.stop()
|
||||
self._media.setSource(QUrl()) # release the demux/decode pipeline
|
||||
self._media.setAudioBufferOutput(None)
|
||||
self._media.setAudioOutput(None) # detach the sink while both live
|
||||
|
||||
# ---- queue ----
|
||||
|
||||
def play_queue(self, track_ids: list[int], start_index: int):
|
||||
@@ -148,8 +169,15 @@ class Player(QObject):
|
||||
than jumping to "loud" in the first few percent."""
|
||||
level = max(0.0, min(1.0, float(level)))
|
||||
self._volume = level
|
||||
self._apply_volume()
|
||||
|
||||
def _apply_volume(self):
|
||||
"""Push the stored logical volume to the sink. Called again on resume
|
||||
and after device swaps: some backends (seen with Bluetooth sinks)
|
||||
re-create the sink with a stale/zero gain, which played silently until
|
||||
a seek re-primed it."""
|
||||
self._audio.setVolume(QAudio.convertVolume(
|
||||
level,
|
||||
self._volume,
|
||||
QAudio.VolumeScale.LogarithmicVolumeScale,
|
||||
QAudio.VolumeScale.LinearVolumeScale,
|
||||
))
|
||||
@@ -164,6 +192,7 @@ class Player(QObject):
|
||||
if self.is_playing():
|
||||
self._media.pause()
|
||||
elif self._current_track is not None:
|
||||
self._apply_volume()
|
||||
self._media.play()
|
||||
elif self._queue:
|
||||
self._index = max(self._index, 0)
|
||||
@@ -267,6 +296,7 @@ class Player(QObject):
|
||||
return
|
||||
was_playing = self.is_playing()
|
||||
self._audio.setDevice(new_default)
|
||||
self._apply_volume() # the new sink may come up at a stale/zero gain
|
||||
# Some backends stall the sink across a device swap; nudge it back.
|
||||
# play() is a no-op if playback actually continued.
|
||||
if was_playing:
|
||||
@@ -284,6 +314,9 @@ class Player(QObject):
|
||||
self._pending_start_ms = 0
|
||||
self._media.setPosition(start)
|
||||
return
|
||||
if status == QMediaPlayer.MediaStatus.BufferedMedia:
|
||||
self._apply_volume() # sink can be re-created per source
|
||||
return
|
||||
if status == QMediaPlayer.MediaStatus.EndOfMedia:
|
||||
self._note_finished(self._current_track)
|
||||
# The player has already stopped at EndOfMedia, so force autoplay
|
||||
|
||||
Reference in New Issue
Block a user