diff options
author | Scott Jackson <daneren2005@gmail.com> | 2018-07-29 14:31:32 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2018-07-29 14:31:32 -0700 |
commit | 2f2a031cfbf71b3cfe87567be86618235493f564 (patch) | |
tree | 090b162f065f099268361d18e9aee93ca848438e /app/src | |
parent | eebdb979a2d6d114ab4d8c2e6f5f6ed762b3ae4c (diff) | |
download | dsub-2f2a031cfbf71b3cfe87567be86618235493f564.tar.gz dsub-2f2a031cfbf71b3cfe87567be86618235493f564.tar.bz2 dsub-2f2a031cfbf71b3cfe87567be86618235493f564.zip |
Probably fix crashes in DLNARouterProvider from concurrent add/remove events
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/provider/DLNARouteProvider.java | 24 |
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) { |