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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 base::AutoLock lock(initialization_lock_); | 109 base::AutoLock lock(initialization_lock_); |
110 | 110 |
111 if (!libspeechd_loader_.Load("libspeechd.so.2")) | 111 if (!libspeechd_loader_.Load("libspeechd.so.2")) |
112 return; | 112 return; |
113 | 113 |
114 { | 114 { |
115 // spd_open has memory leaks which are hard to suppress. | 115 // spd_open has memory leaks which are hard to suppress. |
116 // http://crbug.com/317360 | 116 // http://crbug.com/317360 |
117 ANNOTATE_SCOPED_MEMORY_LEAK; | 117 ANNOTATE_SCOPED_MEMORY_LEAK; |
118 conn_ = libspeechd_loader_.spd_open( | 118 conn_ = libspeechd_loader_.spd_open( |
119 "chrome", "extension_api", NULL, SPD_MODE_SINGLE); | 119 "chrome", "extension_api", NULL, SPD_MODE_THREADED); |
120 } | 120 } |
121 if (!conn_) | 121 if (!conn_) |
122 return; | 122 return; |
123 | 123 |
124 // Register callbacks for all events. | 124 // Register callbacks for all events. |
125 conn_->callback_begin = | 125 conn_->callback_begin = |
126 conn_->callback_end = | 126 conn_->callback_end = |
127 conn_->callback_cancel = | 127 conn_->callback_cancel = |
128 conn_->callback_pause = | 128 conn_->callback_pause = |
129 conn_->callback_resume = | 129 conn_->callback_resume = |
(...skipping 14 matching lines...) Expand all Loading... |
144 libspeechd_loader_.spd_close(conn_); | 144 libspeechd_loader_.spd_close(conn_); |
145 conn_ = NULL; | 145 conn_ = NULL; |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 void TtsPlatformImplLinux::Reset() { | 149 void TtsPlatformImplLinux::Reset() { |
150 base::AutoLock lock(initialization_lock_); | 150 base::AutoLock lock(initialization_lock_); |
151 if (conn_) | 151 if (conn_) |
152 libspeechd_loader_.spd_close(conn_); | 152 libspeechd_loader_.spd_close(conn_); |
153 conn_ = libspeechd_loader_.spd_open( | 153 conn_ = libspeechd_loader_.spd_open( |
154 "chrome", "extension_api", NULL, SPD_MODE_SINGLE); | 154 "chrome", "extension_api", NULL, SPD_MODE_THREADED); |
155 } | 155 } |
156 | 156 |
157 bool TtsPlatformImplLinux::PlatformImplAvailable() { | 157 bool TtsPlatformImplLinux::PlatformImplAvailable() { |
158 if (!initialization_lock_.Try()) | 158 if (!initialization_lock_.Try()) |
159 return false; | 159 return false; |
160 bool result = libspeechd_loader_.loaded() && (conn_ != NULL); | 160 bool result = libspeechd_loader_.loaded() && (conn_ != NULL); |
161 initialization_lock_.Release(); | 161 initialization_lock_.Release(); |
162 return result; | 162 return result; |
163 } | 163 } |
164 | 164 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // static | 347 // static |
348 TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() { | 348 TtsPlatformImplLinux* TtsPlatformImplLinux::GetInstance() { |
349 return Singleton<TtsPlatformImplLinux, | 349 return Singleton<TtsPlatformImplLinux, |
350 LeakySingletonTraits<TtsPlatformImplLinux> >::get(); | 350 LeakySingletonTraits<TtsPlatformImplLinux> >::get(); |
351 } | 351 } |
352 | 352 |
353 // static | 353 // static |
354 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { | 354 TtsPlatformImpl* TtsPlatformImpl::GetInstance() { |
355 return TtsPlatformImplLinux::GetInstance(); | 355 return TtsPlatformImplLinux::GetInstance(); |
356 } | 356 } |
OLD | NEW |