aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2018-07-29 14:31:32 -0700
committerScott Jackson <daneren2005@gmail.com>2018-07-29 14:31:32 -0700
commit2f2a031cfbf71b3cfe87567be86618235493f564 (patch)
tree090b162f065f099268361d18e9aee93ca848438e /app
parenteebdb979a2d6d114ab4d8c2e6f5f6ed762b3ae4c (diff)
downloaddsub-2f2a031cfbf71b3cfe87567be86618235493f564.tar.gz
dsub-2f2a031cfbf71b3cfe87567be86618235493f564.tar.bz2
dsub-2f2a031cfbf71b3cfe87567be86618235493f564.zip
Probably fix crashes in DLNARouterProvider from concurrent add/remove events
Diffstat (limited to 'app')
-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) {