[vlc-commits] macosx: load media sources on request only

Felix Paul Kühne git at videolan.org
Sun May 5 17:17:19 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun May  5 16:55:45 2019 +0200| [8a7fead4cbeeaf700405ac5b1970e3de04bec096] | committer: Felix Paul Kühne

macosx: load media sources on request only

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8a7fead4cbeeaf700405ac5b1970e3de04bec096
---

 modules/gui/macosx/library/VLCLibraryWindow.m              | 2 ++
 modules/gui/macosx/media-source/VLCMediaSourceDataSource.h | 3 +++
 modules/gui/macosx/media-source/VLCMediaSourceDataSource.m | 7 +++----
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index ec7ffa5eef..e56e21d21a 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -128,6 +128,7 @@ static const float f_playlist_row_height = 72.;
     [_libraryCollectionView registerClass:[VLCLibraryCollectionViewItem class] forItemWithIdentifier:VLCLibraryCellIdentifier];
 
     _mediaSourceDataSource = [[VLCMediaSourceDataSource alloc] init];
+    _mediaSourceDataSource.collectionView = _mediaSourceCollectionView;
     _mediaSourceCollectionView.dataSource = _mediaSourceDataSource;
     _mediaSourceCollectionView.delegate = _mediaSourceDataSource;
     [_mediaSourceCollectionView registerClass:[VLCMediaSourceCollectionViewItem class] forItemWithIdentifier:VLCMediaSourceCellIdentifier];
@@ -256,6 +257,7 @@ static const float f_playlist_row_height = 72.;
         default:
             _mediaSourceScrollView.hidden = NO;
             _libraryCollectionView.hidden = YES;
+            [_mediaSourceDataSource loadMediaSources];
             [_mediaSourceCollectionView reloadData];
             break;
     }
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
index 97bf803182..897231ed68 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
+++ b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.h
@@ -32,6 +32,9 @@ NS_ASSUME_NONNULL_BEGIN
 @interface VLCMediaSourceDataSource : NSObject <NSCollectionViewDataSource, NSCollectionViewDelegate>
 
 @property (readwrite) VLCMediaSourceMode mediaSourceMode;
+ at property (readwrite) NSCollectionView *collectionView;
+
+- (void)loadMediaSources;
 
 @end
 
diff --git a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
index e5b14c22f3..c07245761b 100644
--- a/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSourceDataSource.m
@@ -42,14 +42,12 @@
 {
     self = [super init];
     if (self) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [self lazyLoadMediaSources];
-        });
+        _mediaDiscovery = @[];
     }
     return self;
 }
 
-- (void)lazyLoadMediaSources
+- (void)loadMediaSources
 {
     NSArray *mediaDiscoveryForLAN = [VLCMediaSourceProvider listOfMediaSourcesForCategory:SD_CAT_LAN];
     NSUInteger count = mediaDiscoveryForLAN.count;
@@ -61,6 +59,7 @@
         }
     }
     _mediaDiscovery = mediaDiscoveryForLAN;
+    [self.collectionView reloadData];
 }
 
 - (NSInteger)collectionView:(NSCollectionView *)collectionView



More information about the vlc-commits mailing list