Commit 08be3034 authored by Bryan Clark's avatar Bryan Clark Committed by Commit Bot

Add SystemVolumeControl implementation for desktop.

We don't have support for alsa on borg, so this is needed to prevent an
endless stream of alsa related errors.

Bug: b/151360165
Change-Id: I765b98d637ed1741c16069024160c5748ec6cde9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2150032
Commit-Queue: Kenneth MacKay <kmackay@chromium.org>
Auto-Submit: Bryan Clark <bryanclark@google.com>
Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759369}
parent 44a6fc3d
......@@ -25,10 +25,11 @@ cast_source_set("desktop") {
"//media",
]
if (enable_video_with_mixed_audio) {
sources += [ "desktop_system_volume_control.cc" ]
deps += [
"//chromecast/media/cma/backend:for_mixer_audio",
"//chromecast/media/cma/backend:null_video",
"//chromecast/media/cma/backend/alsa:volume_control",
"//chromecast/media/cma/backend:public",
"//chromecast/media/cma/backend/video:av_sync_video",
]
} else {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "chromecast/media/cma/backend/system_volume_control.h"
namespace chromecast {
namespace media {
class DesktopSystemVolumeControl : public SystemVolumeControl {
public:
explicit DesktopSystemVolumeControl(Delegate* delegate)
: delegate_(delegate) {}
~DesktopSystemVolumeControl() override = default;
// SystemVolumeControl interface.
// Consider 'level' and 'volume' equivalent for simplicity.
float GetRoundtripVolume(float volume) override { return volume; }
float GetVolume() override { return volume_; }
void SetVolume(float level) override {
if (level != volume_) {
volume_ = level;
delegate_->OnSystemVolumeOrMuteChange(volume_, muted_);
}
}
bool IsMuted() override { return muted_; }
void SetMuted(bool muted) override {
if (muted != muted_) {
muted_ = muted;
delegate_->OnSystemVolumeOrMuteChange(volume_, muted_);
}
}
void SetPowerSave(bool power_save_on) override {}
void SetLimit(float limit) override {}
private:
Delegate* delegate_;
float volume_ = 0.0f;
bool muted_ = false;
};
// static
std::unique_ptr<SystemVolumeControl> SystemVolumeControl::Create(
Delegate* delegate) {
return std::make_unique<DesktopSystemVolumeControl>(delegate);
}
} // namespace media
} // namespace chromecast
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment