Skip to content

Commit

Permalink
Playback Controller: Fixed title bar updating
Browse files Browse the repository at this point in the history
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 <kode54@gmail.com>
  • Loading branch information
kode54 committed Dec 10, 2022
1 parent 72ee38a commit 01c38c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Application/PlaybackController.m
Expand Up @@ -709,10 +709,11 @@ - (void)audioPlayer:(AudioPlayer *)player pushInfo:(NSDictionary *)info toTrack:
[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 {
Expand Down

0 comments on commit 01c38c9

Please sign in to comment.