Bläddra i källkod

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 år sedan
förälder
incheckning
3dd4b4f8db
1 ändrade filer med 8 tillägg och 6 borttagningar
  1. 8 6
      Sources/VLCLocalServerListViewController.m

+ 8 - 6
Sources/VLCLocalServerListViewController.m

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