Skip to content

Commit c713afe

Browse files
committed
possible fix for crash on media_change event (#581)
1 parent 367c9d9 commit c713afe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/media.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ - (void)playing_change:(NSNotification *)notification {
113113

114114
- (void)media_change:(NSNotification *)notification {
115115
if (!g_media_events) return;
116-
MRMediaRemoteGetNowPlayingApplicationDisplayName(0, dispatch_get_main_queue(), ^(CFStringRef name) {
116+
MRMediaRemoteGetNowPlayingApplicationDisplayName(0, dispatch_get_main_queue(), ^(CFStringRef name_nr) {
117+
if (!name_nr) return;
118+
119+
CFStringRef name = CFStringCreateCopy(CFAllocatorGetDefault(), name_nr);
117120
@autoreleasepool {
118121
MRMediaRemoteGetNowPlayingInfo(dispatch_get_main_queue(), ^(NSDictionary* dict) {
119122
@autoreleasepool {
@@ -155,6 +158,8 @@ - (void)media_change:(NSNotification *)notification {
155158
}
156159
}
157160
}
161+
162+
CFRelease(name);
158163
});
159164
}
160165
});

0 commit comments

Comments
 (0)