aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java b/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java
index 0ee16723..f4238c99 100644
--- a/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java
+++ b/app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java
@@ -228,7 +228,9 @@ public class DLNARouteProvider extends MediaRouteProvider {
removing.remove(id);
return;
}
- adding.add(id);
+ synchronized (adding) {
+ adding.add(id);
+ }
if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) {
try {
@@ -255,21 +257,35 @@ public class DLNARouteProvider extends MediaRouteProvider {
broadcastDescriptors();
}
});
- adding.remove(id);
+
+ synchronized (adding) {
+ if (adding.contains(id)) {
+ adding.remove(id);
+ }
+ }
}
@Override
public void failure(ActionInvocation actionInvocation, UpnpResponse upnpResponse, String s) {
Log.w(TAG, "Failed to get default volume for DLNA route");
Log.w(TAG, "Reason: " + s);
- adding.remove(id);
+
+ synchronized (adding) {
+ if (adding.contains(id)) {
+ adding.remove(id);
+ }
+ }
}
});
} catch(Exception e) {
Log.e(TAG, "Failed to add device", e);
}
} else {
- adding.remove(id);
+ synchronized (adding) {
+ if(adding.contains(id)) {
+ adding.remove(id);
+ }
+ }
}
}
private void deviceRemoved(Device device) {