OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/audio/audio_mixer_alsa.h" | 5 #include "chrome/browser/chromeos/audio/audio_mixer_alsa.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include <alsa/asoundlib.h> | 9 #include <alsa/asoundlib.h> |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 if (disconnected_event_.IsSignaled()) | 154 if (disconnected_event_.IsSignaled()) |
155 return; | 155 return; |
156 | 156 |
157 // Do not attempt to connect if we're not on the device. | 157 // Do not attempt to connect if we're not on the device. |
158 if (!base::chromeos::IsRunningOnChromeOS()) | 158 if (!base::chromeos::IsRunningOnChromeOS()) |
159 return; | 159 return; |
160 | 160 |
161 if (!ConnectInternal()) { | 161 if (!ConnectInternal()) { |
162 thread_->message_loop()->PostDelayedTask(FROM_HERE, | 162 thread_->message_loop()->PostDelayedTask(FROM_HERE, |
163 base::Bind(&AudioMixerAlsa::Connect, base::Unretained(this)), | 163 base::Bind(&AudioMixerAlsa::Connect, base::Unretained(this)), |
164 kConnectionRetrySleepSec * 1000); | 164 base::TimeDelta::FromSeconds(kConnectionRetrySleepSec)); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 bool AudioMixerAlsa::ConnectInternal() { | 168 bool AudioMixerAlsa::ConnectInternal() { |
169 DCHECK(MessageLoop::current() == thread_->message_loop()); | 169 DCHECK(MessageLoop::current() == thread_->message_loop()); |
170 num_connection_attempts_++; | 170 num_connection_attempts_++; |
171 int err; | 171 int err; |
172 snd_mixer_t* handle = NULL; | 172 snd_mixer_t* handle = NULL; |
173 | 173 |
174 if ((err = snd_mixer_open(&handle, 0)) < 0) { | 174 if ((err = snd_mixer_open(&handle, 0)) < 0) { |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 (max_volume_db_ - min_volume_db_), 1/kVolumeBias); | 434 (max_volume_db_ - min_volume_db_), 1/kVolumeBias); |
435 } | 435 } |
436 | 436 |
437 double AudioMixerAlsa::PercentToDb(double percent) const { | 437 double AudioMixerAlsa::PercentToDb(double percent) const { |
438 lock_.AssertAcquired(); | 438 lock_.AssertAcquired(); |
439 return pow(percent / 100.0, kVolumeBias) * | 439 return pow(percent / 100.0, kVolumeBias) * |
440 (max_volume_db_ - min_volume_db_) + min_volume_db_; | 440 (max_volume_db_ - min_volume_db_) + min_volume_db_; |
441 } | 441 } |
442 | 442 |
443 } // namespace chromeos | 443 } // namespace chromeos |
OLD | NEW |