Sfoglia il codice sorgente

local network: do not re-init DSM discovery if it already runs and dispatch the init from the main thread

Felix Paul Kühne 10 anni fa
parent
commit
3dd4b4f8db
1 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 8 6
      Sources/VLCLocalServerListViewController.m

+ 8 - 6
Sources/VLCLocalServerListViewController.m

@@ -111,7 +111,7 @@
     if (_reachability.currentReachabilityStatus == ReachableViaWiFi) {
         [self _startUPNPDiscovery];
         [self performSelectorInBackground:@selector(_startSAPDiscovery) withObject:nil];
-        [self performSelectorInBackground:@selector(_startDSMDiscovery) withObject:nil];
+        [self _startDSMDiscovery];
     }
 }
 
@@ -212,7 +212,7 @@
     if (_reachability.currentReachabilityStatus == ReachableViaWiFi) {
         [self _startUPNPDiscovery];
         [self performSelectorInBackground:@selector(_startSAPDiscovery) withObject:nil];
-        [self performSelectorInBackground:@selector(_startDSMDiscovery) withObject:nil];
+        [self _startDSMDiscovery];
     } else {
         [self _stopUPNPDiscovery];
         [self _stopSAPDiscovery];
@@ -461,9 +461,9 @@
 
     [self.tableView reloadData];
 
-    [self performSelectorInBackground:@selector(_startUPNPDiscovery) withObject:nil];
+    [self _startUPNPDiscovery];
     [self performSelectorInBackground:@selector(_startSAPDiscovery) withObject:nil];
-    [self performSelectorInBackground:@selector(_startDSMDiscovery) withObject:nil];
+    [self _startDSMDiscovery];
 }
 
 #pragma mark - login panel protocol
@@ -654,8 +654,10 @@
     if (_reachability.currentReachabilityStatus != ReachableViaWiFi)
         return;
 
-    if (!_dsmDiscoverer)
-        _dsmDiscoverer = [[VLCMediaDiscoverer alloc] initWithName:@"dsm"];
+    if (_dsmDiscoverer)
+        return;
+
+    _dsmDiscoverer = [[VLCMediaDiscoverer alloc] initWithName:@"dsm"];
     [_dsmDiscoverer startDiscoverer];
     _dsmDiscoverer.discoveredMedia.delegate = self;
 }