[vlc-commits] macosx: fix UI freeze when large amount of playlist items are added at once
David Fuhrmann
git at videolan.org
Fri Apr 12 21:51:09 CEST 2013
vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Fri Apr 12 21:44:27 2013 +0200| [0150650e48aa90497e4693b9e6cf5aab770442af] | committer: David Fuhrmann
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0150650e48aa90497e4693b9e6cf5aab770442af
---
modules/gui/macosx/intf.h | 4 +++-
modules/gui/macosx/intf.m | 17 ++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 8c5d1e7..79f9e0d 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -149,11 +149,13 @@ struct intf_sys_t
/* iTunes play/pause support */
BOOL b_has_itunes_paused;
NSTimer *o_itunes_play_timer;
+
+ BOOL b_playlist_updated_selector_in_queue;
}
@property (readonly) VLCVoutWindowController* voutController;
@property (readonly) BOOL nativeFullscreenMode;
-
+ at property (nonatomic, readwrite) BOOL playlistUpdatedSelectorInQueue;
+ (VLCMain *)sharedInstance;
- (intf_thread_t *)intf;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index aba3666..479027e 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -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)
{
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];
return VLC_SUCCESS;
@@ -591,6 +601,7 @@ audio_output_t *getAout(void)
@synthesize voutController=o_vout_controller;
@synthesize nativeFullscreenMode=b_nativeFullscreenMode;
+ at synthesize playlistUpdatedSelectorInQueue=b_playlist_updated_selector_in_queue;
#pragma mark -
#pragma mark Initialization
@@ -1342,6 +1353,10 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)playlistUpdated
{
+ @synchronized(self) {
+ b_playlist_updated_selector_in_queue = NO;
+ }
+
[self playbackStatusUpdated];
[o_playlist playlistUpdated];
[o_mainwindow updateWindow];
More information about the vlc-commits
mailing list