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

Side by Side Diff: chrome/browser/chromeos/audio_mixer_alsa.cc

Issue 8511026: Don't start speech synthesis until after the audio mixer is initialized. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_mixer_alsa.h" 5 #include "chrome/browser/chromeos/audio_mixer_alsa.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 11
12 #include <alsa/asoundlib.h> 12 #include <alsa/asoundlib.h>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/task.h" 16 #include "base/task.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/extensions/extension_tts_api_chromeos.h"
20 #include "chrome/browser/prefs/pref_service.h" 21 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_types.h"
23 27
24 typedef long alsa_long_t; // 'long' is required for ALSA API calls. 28 typedef long alsa_long_t; // 'long' is required for ALSA API calls.
25 29
26 using content::BrowserThread; 30 using content::BrowserThread;
27 using std::max; 31 using std::max;
28 using std::min; 32 using std::min;
29 using std::string; 33 using std::string;
30 34
31 namespace chromeos { 35 namespace chromeos {
32 36
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 { 299 {
296 base::AutoLock lock(lock_); 300 base::AutoLock lock(lock_);
297 alsa_mixer_ = handle; 301 alsa_mixer_ = handle;
298 master_element_ = master_element; 302 master_element_ = master_element;
299 pcm_element_ = pcm_element; 303 pcm_element_ = pcm_element;
300 min_volume_db_ = min_volume_db; 304 min_volume_db_ = min_volume_db;
301 max_volume_db_ = max_volume_db; 305 max_volume_db_ = max_volume_db;
302 volume_db_ = min(max(volume_db_, min_volume_db_), max_volume_db_); 306 volume_db_ = min(max(volume_db_, min_volume_db_), max_volume_db_);
303 } 307 }
304 308
309 // The speech synthesis service shouldn't be initialized until after
310 // we get to this point, so we call this function to tell it that it's
311 // safe to do TTS now. NotificationService would be cleaner,
312 // but it's not available at this point.
313 EnableChromeOsTts();
314
305 ApplyState(); 315 ApplyState();
306 return true; 316 return true;
307 } 317 }
308 318
309 void AudioMixerAlsa::Disconnect() { 319 void AudioMixerAlsa::Disconnect() {
310 DCHECK(MessageLoop::current() == thread_->message_loop()); 320 DCHECK(MessageLoop::current() == thread_->message_loop());
311 if (alsa_mixer_) { 321 if (alsa_mixer_) {
312 snd_mixer_close(alsa_mixer_); 322 snd_mixer_close(alsa_mixer_);
313 alsa_mixer_ = NULL; 323 alsa_mixer_ = NULL;
314 } 324 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (alsa_result != 0) { 450 if (alsa_result != 0) {
441 LOG(WARNING) << "snd_mixer_selem_set_playback_switch_all() failed: " 451 LOG(WARNING) << "snd_mixer_selem_set_playback_switch_all() failed: "
442 << snd_strerror(alsa_result); 452 << snd_strerror(alsa_result);
443 } else { 453 } else {
444 VLOG(1) << "Set playback switch " << snd_mixer_selem_get_name(element) 454 VLOG(1) << "Set playback switch " << snd_mixer_selem_get_name(element)
445 << " to " << mute; 455 << " to " << mute;
446 } 456 }
447 } 457 }
448 458
449 } // namespace chromeos 459 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698