Skip to content

Commit

Permalink
[lgwebos] Handle volume update whatever the audio output (#7259)
Browse files Browse the repository at this point in the history
Fix #7207

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored Mar 31, 2020
1 parent 44fe976 commit 8a5b3d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected <Y> ResponseListener<Y> createResponseListener() {

@Override
public void onError(String error) {
logger.warn("{} received error response: {}", BaseChannelHandler.this.getClass().getSimpleName(),
logger.debug("{} received error response: {}", BaseChannelHandler.this.getClass().getSimpleName(),
error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,31 +448,17 @@ public ServiceCommand<Boolean> getMute(ResponseListener<Boolean> listener) {

public ServiceSubscription<Float> subscribeVolume(ResponseListener<Float> listener) {
ServiceSubscription<Float> request = new ServiceSubscription<>(VOLUME, null,
// "scenario" in the response determines whether "volume" is absolute or a delta value.
// it only makes sense to subscribe to changes in absolute volume
// accept: "mastervolume_tv_speaker" or "mastervolume_tv_speaker_ext" or
// "mastervolume_ext_speaker_lg_optical"
// ignore external amp/receiver: "mastervolume_ext_speaker_arc" or "mastervolume_ext_speaker_urcu_oss"
jsonObj -> jsonObj.get("scenario").getAsString().startsWith("mastervolume_tv_speaker")
|| "mastervolume_ext_speaker_lg_optical".equals(jsonObj.get("scenario").getAsString())
? (float) (jsonObj.get("volume").getAsInt() / 100.0)
: Float.NaN,
jsonObj -> jsonObj.get("volume").getAsInt() >= 0 ? (float) (jsonObj.get("volume").getAsInt() / 100.0)
: Float.NaN,
listener);
sendCommand(request);
return request;
}

public ServiceCommand<Float> getVolume(ResponseListener<Float> listener) {
ServiceCommand<Float> request = new ServiceCommand<>(VOLUME, null,
// "scenario" in the response determines whether "volume" is absolute or a delta value.
// it only makes sense to subscribe to changes in absolute volume
// accept: "mastervolume_tv_speaker" or "mastervolume_tv_speaker_ext" or
// "mastervolume_ext_speaker_lg_optical"
// ignore external amp/receiver: "mastervolume_ext_speaker_arc" or "mastervolume_ext_speaker_urcu_oss"
jsonObj -> jsonObj.get("scenario").getAsString().startsWith("mastervolume_tv_speaker")
|| "mastervolume_ext_speaker_lg_optical".equals(jsonObj.get("scenario").getAsString())
? (float) (jsonObj.get("volume").getAsInt() / 100.0)
: Float.NaN,
jsonObj -> jsonObj.get("volume").getAsInt() >= 0 ? (float) (jsonObj.get("volume").getAsInt() / 100.0)
: Float.NaN,
listener);
sendCommand(request);
return request;
Expand Down

0 comments on commit 8a5b3d0

Please sign in to comment.