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 <>
Christopher Snowhill 2022-12-09 22:34:47 -08:00
parent 9822dcc4c0
commit e1fb7b9bd7
No known key found for this signature in database
1 changed files with 3 additions and 2 deletions

View File

@ -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 {