Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3330)

Unified Diff: chrome/browser/chromeos/audio/audio_mixer_cras.cc

Issue 10873085: Implement two new policies to control muting the audio I/O. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/audio/audio_mixer_cras.cc
diff --git a/chrome/browser/chromeos/audio/audio_mixer_cras.cc b/chrome/browser/chromeos/audio/audio_mixer_cras.cc
index cffb4eddc39e2e8cf010ea147d1747b6eccc1535..17519ca5165d7bab7450d2e9082e9ea8691f97d1 100644
--- a/chrome/browser/chromeos/audio/audio_mixer_cras.cc
+++ b/chrome/browser/chromeos/audio/audio_mixer_cras.cc
@@ -36,6 +36,9 @@ AudioMixerCras::AudioMixerCras()
client_connected_(false),
volume_percent_(kDefaultVolumePercent),
is_muted_(false),
+ is_mute_locked_(false),
+ is_capture_muted_(false),
+ is_capture_mute_locked_(false),
apply_is_pending_(true) {
}
@@ -85,13 +88,55 @@ bool AudioMixerCras::IsMuted() {
return is_muted_;
}
-void AudioMixerCras::SetMuted(bool muted) {
+void AudioMixerCras::SetMuted(bool mute) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::AutoLock lock(lock_);
- is_muted_ = muted;
- if (client_connected_ && !apply_is_pending_)
- thread_->message_loop()->PostTask(FROM_HERE,
- base::Bind(&AudioMixerCras::ApplyState, base::Unretained(this)));
+ if (is_mute_locked_) {
+ NOTREACHED() << "Mute has been locked!";
+ return;
+ }
+ is_muted_ = mute;
+ ApplyStateIfNeeded();
+}
+
+bool AudioMixerCras::IsMuteLocked() {
+ base::AutoLock lock(lock_);
+ return is_mute_locked_;
+}
+
+void AudioMixerCras::SetMuteLocked(bool locked) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ base::AutoLock lock(lock_);
+ is_mute_locked_ = locked;
+ ApplyStateIfNeeded();
+}
+
+bool AudioMixerCras::IsCaptureMuted() {
+ base::AutoLock lock(lock_);
+ return is_capture_muted_;
+}
+
+void AudioMixerCras::SetCaptureMuted(bool mute) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ base::AutoLock lock(lock_);
+ if (is_capture_mute_locked_) {
+ NOTREACHED() << "Capture mute has been locked!";
+ return;
+ }
+ is_capture_muted_ = mute;
+ ApplyStateIfNeeded();
+}
+
+bool AudioMixerCras::IsCaptureMuteLocked() {
+ base::AutoLock lock(lock_);
+ return is_capture_mute_locked_;
+}
+
+void AudioMixerCras::SetCaptureMuteLocked(bool locked) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ base::AutoLock lock(lock_);
+ is_capture_mute_locked_ = locked;
+ ApplyStateIfNeeded();
}
void AudioMixerCras::Connect() {
@@ -126,10 +171,16 @@ void AudioMixerCras::ApplyState() {
return;
bool should_mute = false;
+ bool should_lock_mute = false;
+ bool should_mute_capture = false;
+ bool should_lock_capture_mute = false;
size_t new_volume = 0;
{
base::AutoLock lock(lock_);
should_mute = is_muted_;
+ should_lock_mute = is_mute_locked_;
+ should_mute_capture = is_capture_muted_;
+ should_lock_capture_mute = is_capture_mute_locked_;
new_volume = floor(volume_percent_ + 0.5);
apply_is_pending_ = false;
}
@@ -142,6 +193,18 @@ void AudioMixerCras::ApplyState() {
cras_client_set_system_volume(client_, new_volume);
cras_client_set_system_mute(client_, should_mute);
}
+ cras_client_set_system_mute_locked(client_, should_lock_mute);
+ cras_client_set_system_capture_mute(client_, should_mute_capture);
+ cras_client_set_system_capture_mute_locked(client_, should_lock_capture_mute);
+}
+
+void AudioMixerCras::ApplyStateIfNeeded() {
+ lock_.AssertAcquired();
+ if (client_connected_ && !apply_is_pending_) {
+ thread_->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&AudioMixerCras::ApplyState, base::Unretained(this)));
+ }
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/audio/audio_mixer_cras.h ('k') | chrome/browser/policy/configuration_policy_handler_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698