Commit 0150650e authored by David Fuhrmann's avatar David Fuhrmann
Browse files

macosx: fix UI freeze when large amount of playlist items are added at once

This happened when selecting radio discovery, for instance.
Probably also fixes #7516.
parent 613bbb83
...@@ -149,11 +149,13 @@ struct intf_sys_t ...@@ -149,11 +149,13 @@ struct intf_sys_t
/* iTunes play/pause support */ /* iTunes play/pause support */
BOOL b_has_itunes_paused; BOOL b_has_itunes_paused;
NSTimer *o_itunes_play_timer; NSTimer *o_itunes_play_timer;
BOOL b_playlist_updated_selector_in_queue;
} }
@property (readonly) VLCVoutWindowController* voutController; @property (readonly) VLCVoutWindowController* voutController;
@property (readonly) BOOL nativeFullscreenMode; @property (readonly) BOOL nativeFullscreenMode;
@property (nonatomic, readwrite) BOOL playlistUpdatedSelectorInQueue;
+ (VLCMain *)sharedInstance; + (VLCMain *)sharedInstance;
- (intf_thread_t *)intf; - (intf_thread_t *)intf;
......
...@@ -420,7 +420,17 @@ static int PlaylistUpdated(vlc_object_t *p_this, const char *psz_var, ...@@ -420,7 +420,17 @@ static int PlaylistUpdated(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param) vlc_value_t oldval, vlc_value_t new_val, void *param)
{ {
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
[[VLCMain sharedInstance] performSelectorOnMainThread:@selector(playlistUpdated) withObject:nil waitUntilDone:NO];
/* Avoid event queue flooding with playlistUpdated selectors, leading to UI freezes.
* Therefore, only enqueue if no selector already enqueued.
*/
VLCMain *o_main = [VLCMain sharedInstance];
@synchronized(o_main) {
if(![o_main playlistUpdatedSelectorInQueue]) {
[o_main setPlaylistUpdatedSelectorInQueue:YES];
[o_main performSelectorOnMainThread:@selector(playlistUpdated) withObject:nil waitUntilDone:NO];
}
}
[o_pool release]; [o_pool release];
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -591,6 +601,7 @@ audio_output_t *getAout(void) ...@@ -591,6 +601,7 @@ audio_output_t *getAout(void)
@synthesize voutController=o_vout_controller; @synthesize voutController=o_vout_controller;
@synthesize nativeFullscreenMode=b_nativeFullscreenMode; @synthesize nativeFullscreenMode=b_nativeFullscreenMode;
@synthesize playlistUpdatedSelectorInQueue=b_playlist_updated_selector_in_queue;
#pragma mark - #pragma mark -
#pragma mark Initialization #pragma mark Initialization
...@@ -1342,6 +1353,10 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1342,6 +1353,10 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)playlistUpdated - (void)playlistUpdated
{ {
@synchronized(self) {
b_playlist_updated_selector_in_queue = NO;
}
[self playbackStatusUpdated]; [self playbackStatusUpdated];
[o_playlist playlistUpdated]; [o_playlist playlistUpdated];
[o_mainwindow updateWindow]; [o_mainwindow updateWindow];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment