From e1fb7b9bd791df6e325be36442efbfeed9e27a11 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 9 Dec 2022 22:34:47 -0800 Subject: [PATCH] Playback Controller: Fixed title bar updating This change had several components. For one, the delay of the dispatch was increased from 5 milliseconds to 50 milliseconds. Two, the post to the notification center was included in the delayed dispatch, so that retains the PlaylistEntry object. Finally, the playlistController's currentEntry object is reassigned from the input PlaylistEntry object, which facilitates all watchers which are observing that variable for updates. This final step also retains self for the callback, which should be fine, since it's a quick dispatch with a short delay. Fixes #335 Signed-off-by: Christopher Snowhill --- Application/PlaybackController.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Application/PlaybackController.m b/Application/PlaybackController.m index 19dd0055f..02f6457b0 100644 --- a/Application/PlaybackController.m +++ b/Application/PlaybackController.m @@ -709,10 +709,11 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) { [pe setMetadata:info]; [playlistView refreshTrack:pe]; // Delay the action until this function has returned to the audio thread - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 50 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ + self->playlistController.currentEntry = pe; [self sendMetaData]; + [[NSNotificationCenter defaultCenter] postNotificationName:CogPlaybackDidBeginNotficiation object:pe]; }); - [[NSNotificationCenter defaultCenter] postNotificationName:CogPlaybackDidBeginNotficiation object:pe]; } - (void)audioPlayer:(AudioPlayer *)player reportPlayCountForTrack:(id)userInfo {