Improve logging and FadeCurve generation. Tidy.
This commit is contained in:
parent
e179e57459
commit
e9a3047f00
@ -13,6 +13,7 @@ from sqlalchemy.orm import scoped_session
|
||||
|
||||
# App imports
|
||||
from config import Config
|
||||
from log import log
|
||||
from models import PlaylistRows
|
||||
import helpers
|
||||
|
||||
@ -29,6 +30,7 @@ class FadeCurve:
|
||||
|
||||
audio = helpers.get_audio_segment(track_path)
|
||||
if not audio:
|
||||
log.error(f"FadeCurve: could not get audio for {track_path=}")
|
||||
return None
|
||||
|
||||
# Start point of curve is Config.FADE_CURVE_MS_BEFORE_FADE
|
||||
@ -116,7 +118,7 @@ class PlaylistTrack:
|
||||
self.end_time: Optional[dt.datetime] = None
|
||||
self.fade_at: Optional[int] = None
|
||||
self.fade_graph: Optional[FadeCurve] = None
|
||||
self.fade_graph_start_updates: Optional[datetime] = None
|
||||
self.fade_graph_start_updates: Optional[dt.datetime] = None
|
||||
self.fade_length: Optional[int] = None
|
||||
self.path: Optional[str] = None
|
||||
self.playlist_id: Optional[int] = None
|
||||
@ -163,7 +165,6 @@ class PlaylistTrack:
|
||||
self.fade_length = track.silence_at - track.fade_at
|
||||
|
||||
# Initialise and add FadeCurve in a thread as it's slow
|
||||
# Import in separate thread
|
||||
self.fadecurve_thread = QThread()
|
||||
self.worker = AddFadeCurve(
|
||||
self,
|
||||
@ -197,10 +198,9 @@ class PlaylistTrack:
|
||||
milliseconds=update_graph_at_ms
|
||||
)
|
||||
|
||||
# Calculate time fade_graph should start updating
|
||||
if self.fade_at:
|
||||
# Calculate time fade_graph should start updating
|
||||
update_graph_at_ms = max(0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1)
|
||||
self.fade_graph_start_updates = now + timedelta(milliseconds=update_graph_at_ms)
|
||||
self.fade_graph_start_updates = now + dt.timedelta(milliseconds=update_graph_at_ms)
|
||||
|
||||
|
||||
class AddFadeCurve(QObject):
|
||||
@ -229,9 +229,11 @@ class AddFadeCurve(QObject):
|
||||
Create fade curve and add to PlaylistTrack object
|
||||
"""
|
||||
|
||||
self.playlist_track.fade_graph = FadeCurve(
|
||||
self.track_path, self.track_fade_at, self.track_silence_at
|
||||
)
|
||||
fc = FadeCurve(self.track_path, self.track_fade_at, self.track_silence_at)
|
||||
if not fc:
|
||||
log.error(f"Failed to create FadeCurve for {self.track_path=}")
|
||||
else:
|
||||
self.playlist_track.fade_graph = fc
|
||||
self.finished.emit()
|
||||
|
||||
|
||||
|
||||
@ -1240,9 +1240,19 @@ class PlaylistModel(QAbstractTableModel):
|
||||
if plr:
|
||||
# Check this isn't a header row
|
||||
if self.is_header_row(row_number):
|
||||
log.error(
|
||||
"Tried to set next row on header row: "
|
||||
f"playlistmodel.set_next_track({row_number=}, "
|
||||
f"{self.playlist_id=}"
|
||||
)
|
||||
return
|
||||
# Check track is readable
|
||||
if file_is_unreadable(plr.track.path):
|
||||
log.error(
|
||||
"Tried to set next row on unreadable row: "
|
||||
f"playlistmodel.set_next_track({row_number=}, "
|
||||
f"{self.playlist_id=}"
|
||||
)
|
||||
return
|
||||
track_sequence.next.set_plr(session, plr)
|
||||
self.signals.next_track_changed_signal.emit()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user