|
@@ -29,6 +29,9 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
int _upnpErrorCode;
|
|
|
NSMutableArray *_baseUrlArray;
|
|
|
dispatch_source_t _searchTimer;
|
|
|
+ NSString *_ssid;
|
|
|
+ BOOL _shutDownUpnping;
|
|
|
+ BOOL _updateLocalResourceLock;
|
|
|
}
|
|
|
|
|
|
@property (nonatomic, strong) NSHashTable *listeners;
|
|
@@ -89,9 +92,34 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
return _upnpErrorCode;
|
|
|
}
|
|
|
|
|
|
+- (void)reloadUpnp{
|
|
|
+ NSString *ssid = [UIDevice currentSSID];
|
|
|
+ if ([ssid isEqualToString:_ssid]) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_shutDownUpnping) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _ssid = ssid;
|
|
|
+ wd_playControl_queue(^{
|
|
|
+ _shutDownUpnping = YES;
|
|
|
+ libupnp_StopBuildFilesList();
|
|
|
+ int exitCount = 0;
|
|
|
+ while (_updateLocalResourceLock) {
|
|
|
+ exitCount++;
|
|
|
+ [NSThread sleepForTimeInterval:1.0];
|
|
|
+ if (exitCount > 10)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ _updateLocalResourceLock = NO;
|
|
|
+ [self searchDeviceWithSearchTime:20 timeBlock:nil];
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
- (void)searchDeviceWithSearchTime:(int)searchTime
|
|
|
timeBlock:(void(^)(NSInteger time))timeBlock {
|
|
|
wd_playControl_queue(^{
|
|
|
+ _updateLocalResourceLock = YES;
|
|
|
if (_upnpErrorCode != 0) {
|
|
|
if ([self startUpnp] == 0) {
|
|
|
[self checkBaseURL];
|
|
@@ -100,6 +128,7 @@ static inline void wd_playControl_queue(void (^block)(void)){
|
|
|
}
|
|
|
libupnp_SearchDevice(20);
|
|
|
});
|
|
|
+ _ssid = [UIDevice currentSSID];
|
|
|
__block int count = searchTime +1;
|
|
|
_searchTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(0, 0));
|
|
|
dispatch_source_set_timer(_searchTimer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
|