OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/speech/tts_android.h" | 5 #include "chrome/browser/speech/tts_android.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 bool TtsPlatformImplAndroid::Speak( | 40 bool TtsPlatformImplAndroid::Speak( |
41 int utterance_id, | 41 int utterance_id, |
42 const std::string& utterance, | 42 const std::string& utterance, |
43 const std::string& lang, | 43 const std::string& lang, |
44 const VoiceData& voice, | 44 const VoiceData& voice, |
45 const UtteranceContinuousParameters& params) { | 45 const UtteranceContinuousParameters& params) { |
46 JNIEnv* env = AttachCurrentThread(); | 46 JNIEnv* env = AttachCurrentThread(); |
47 jboolean success = Java_TtsPlatformImpl_speak( | 47 jboolean success = Java_TtsPlatformImpl_speak( |
48 env, java_ref_.obj(), | 48 env, java_ref_.obj(), utterance_id, |
49 utterance_id, | 49 base::android::ConvertUTF8ToJavaString(env, utterance).obj(), |
50 base::android::ConvertUTF8ToJavaString(env, utterance).Release(), | 50 base::android::ConvertUTF8ToJavaString(env, lang).obj(), params.rate, |
51 base::android::ConvertUTF8ToJavaString(env, lang).Release(), | 51 params.pitch, params.volume); |
52 params.rate, params.pitch, params.volume); | |
53 if (!success) | 52 if (!success) |
54 return false; | 53 return false; |
55 | 54 |
56 utterance_ = utterance; | 55 utterance_ = utterance; |
57 utterance_id_ = utterance_id; | 56 utterance_id_ = utterance_id; |
58 return true; | 57 return true; |
59 } | 58 } |
60 | 59 |
61 bool TtsPlatformImplAndroid::StopSpeaking() { | 60 bool TtsPlatformImplAndroid::StopSpeaking() { |
62 JNIEnv* env = AttachCurrentThread(); | 61 JNIEnv* env = AttachCurrentThread(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // static | 136 // static |
138 TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() { | 137 TtsPlatformImplAndroid* TtsPlatformImplAndroid::GetInstance() { |
139 return Singleton<TtsPlatformImplAndroid, | 138 return Singleton<TtsPlatformImplAndroid, |
140 LeakySingletonTraits<TtsPlatformImplAndroid> >::get(); | 139 LeakySingletonTraits<TtsPlatformImplAndroid> >::get(); |
141 } | 140 } |
142 | 141 |
143 // static | 142 // static |
144 bool TtsPlatformImplAndroid::Register(JNIEnv* env) { | 143 bool TtsPlatformImplAndroid::Register(JNIEnv* env) { |
145 return RegisterNativesImpl(env); | 144 return RegisterNativesImpl(env); |
146 } | 145 } |
OLD | NEW |