aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-11-05 13:38:45 -0800
committerScott Jackson <daneren2005@gmail.com>2014-11-05 13:38:45 -0800
commitede21d014b26a1f9d68b11fc7de64f8bd316c571 (patch)
treecbd50d41897637c024ceb4cd2733919d1d87f722 /src/github/daneren2005
parent10c9ad416dafbe33f81746fdec1c48953ec71cee (diff)
downloaddsub-ede21d014b26a1f9d68b11fc7de64f8bd316c571.tar.gz
dsub-ede21d014b26a1f9d68b11fc7de64f8bd316c571.tar.bz2
dsub-ede21d014b26a1f9d68b11fc7de64f8bd316c571.zip
Add rendering control service, don't try to add same device more then once at a time
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/provider/DLNARouteProvider.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
index 25cb14db..d4109a36 100644
--- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
+++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
@@ -66,6 +66,7 @@ public class DLNARouteProvider extends MediaRouteProvider {
private RemoteController controller;
private HashMap<String, DLNADevice> devices = new HashMap<String, DLNADevice>();
+ private List<String> adding = new List<String>();
private AndroidUpnpService dlnaService;
private ServiceConnection dlnaServiceConnection;
@@ -185,7 +186,17 @@ public class DLNARouteProvider extends MediaRouteProvider {
}
private void deviceAdded(final Device device) {
- final org.teleal.cling.model.meta.Service renderingControl = null;
+ final org.teleal.cling.model.meta.Service renderingControl = device.findService(new ServiceType("schemas-upnp-org", "RenderingControl"));
+ if(renderingControl == null) {
+ return;
+ }
+
+ final String id = device.getIdentity().getUdn().toString();
+ // In the process of looking up it's details already
+ if(adding.contains(id)) {
+ return;
+ }
+ adding.add(id);
if(device.getType().getType().equals("MediaRenderer") && device instanceof RemoteDevice) {
dlnaService.getControlPoint().execute(new GetVolume(renderingControl) {
@@ -198,6 +209,7 @@ public class DLNARouteProvider extends MediaRouteProvider {
maxVolume = (int) volumeRange.getMaximum();
}
+ // Create a new DLNADevice to represent this item
String id = device.getIdentity().getUdn().toString();
String name = device.getDetails().getFriendlyName();
String displayName = device.getDisplayString();
@@ -205,12 +217,14 @@ public class DLNARouteProvider extends MediaRouteProvider {
DLNADevice newDevice = new DLNADevice(id, name, displayName, currentVolume, maxVolume);
devices.put(id, newDevice);
broadcastDescriptors();
+ 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);
}
});
}