aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/provider/DLNARouteProvider.java8
-rw-r--r--src/github/daneren2005/dsub/service/DLNAController.java9
2 files changed, 14 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
index 4a1ea067..e2450f1f 100644
--- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
+++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java
@@ -161,13 +161,17 @@ public class DLNARouteProvider extends MediaRouteProvider {
for(Map.Entry<String, DLNADevice> deviceEntry: devices.entrySet()) {
DLNADevice device = deviceEntry.getValue();
+ int increments = device.volumeMax / 10;
+ int volume = controller == null ? device.volume : (int) controller.getVolume();
+ volume = volume / increments;
+
MediaRouteDescriptor.Builder routeBuilder = new MediaRouteDescriptor.Builder(device.id, device.name);
routeBuilder.addControlFilter(routeIntentFilter)
.setPlaybackStream(AudioManager.STREAM_MUSIC)
.setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE)
.setDescription(device.description)
- .setVolume(controller == null ? 5 : (int) (controller.getVolume() * 10))
- .setVolumeMax(device.volumeMax)
+ .setVolume(volume)
+ .setVolumeMax(10)
.setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE);
providerBuilder.addRoute(routeBuilder.build());
}
diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java
index 522bf586..b863068b 100644
--- a/src/github/daneren2005/dsub/service/DLNAController.java
+++ b/src/github/daneren2005/dsub/service/DLNAController.java
@@ -232,6 +232,12 @@ public class DLNAController extends RemoteController {
@Override
public void setVolume(int volume) {
+ if(volume < 0) {
+ volume = 0;
+ } else if(volume > device.volumeMax) {
+ volume = device.volumeMax;
+ }
+
device.volume = volume;
controlPoint.execute(new SetVolume(device.renderer.findService(new ServiceType("schemas-upnp-org", "RenderingControl")), volume) {
@SuppressWarnings("rawtypes")
@@ -244,7 +250,8 @@ public class DLNAController extends RemoteController {
@Override
public void updateVolume(boolean up) {
- setVolume(device.volume + (up ? 1 : -1));
+ int increment = device.volumeMax / 10;
+ setVolume(device.volume + (up ? increment : -increment));
}
@Override