diff options
| -rw-r--r-- | include/tts/TtsEngine.h | 23 | ||||
| -rw-r--r-- | include/utils/threads.h | 19 | ||||
| -rw-r--r-- | libs/binder/IPCThreadState.cpp | 39 | ||||
| -rw-r--r-- | libs/surfaceflinger_client/SharedBufferStack.cpp | 2 |
4 files changed, 48 insertions, 35 deletions
diff --git a/include/tts/TtsEngine.h b/include/tts/TtsEngine.h index 28b0d2ff9a..998e35322c 100644 --- a/include/tts/TtsEngine.h +++ b/include/tts/TtsEngine.h @@ -26,6 +26,12 @@ namespace android { +#define ANDROID_TTS_ENGINE_PROPERTY_CONFIG "engineConfig" +#define ANDROID_TTS_ENGINE_PROPERTY_PITCH "pitch" +#define ANDROID_TTS_ENGINE_PROPERTY_RATE "rate" +#define ANDROID_TTS_ENGINE_PROPERTY_VOLUME "volume" + + enum tts_synth_status { TTS_SYNTH_DONE = 0, TTS_SYNTH_PENDING = 1 @@ -85,7 +91,7 @@ public: // Initialize the TTS engine and returns whether initialization succeeded. // @param synthDoneCBPtr synthesis callback function pointer // @return TTS_SUCCESS, or TTS_FAILURE - virtual tts_result init(synthDoneCB_t synthDoneCBPtr); + virtual tts_result init(synthDoneCB_t synthDoneCBPtr, const char *engineConfig); // Shut down the TTS engine and releases all associated resources. // @return TTS_SUCCESS, or TTS_FAILURE @@ -122,7 +128,7 @@ public: // @param variant pointer to the variant code // @return TTS_SUCCESS, or TTS_FAILURE virtual tts_result loadLanguage(const char *lang, const char *country, const char *variant); - + // Load the resources associated with the specified language, country and Locale variant. // The loaded language will only be used once a call to setLanguageFromLocale() with the same // language value is issued. Language and country values are coded according to the ISO three @@ -220,19 +226,6 @@ public: virtual tts_result synthesizeText(const char *text, int8_t *buffer, size_t bufferSize, void *userdata); - // Synthesize IPA text. - // As the synthesis is performed, the engine invokes the callback to notify - // the TTS framework that it has filled the given buffer, and indicates how - // many bytes it wrote. The callback is called repeatedly until the engine - // has generated all the audio data corresponding to the IPA data. - // @param ipa the IPA data to synthesize - // @param userdata pointer to be returned when the call is invoked - // @param buffer the location where the synthesized data must be written - // @param bufferSize the number of bytes that can be written in buffer - // @return TTS_FEATURE_UNSUPPORTED if IPA is not supported, - // otherwise TTS_SUCCESS or TTS_FAILURE - virtual tts_result synthesizeIpa(const char *ipa, int8_t *buffer, - size_t bufferSize, void *userdata); }; } // namespace android diff --git a/include/utils/threads.h b/include/utils/threads.h index 130d83c0d5..5ac0c5ee19 100644 --- a/include/utils/threads.h +++ b/include/utils/threads.h @@ -209,7 +209,7 @@ inline thread_id_t getThreadId() { class Mutex { public: enum { - NORMAL = 0, + PRIVATE = 0, SHARED = 1 }; @@ -305,7 +305,13 @@ typedef Mutex::Autolock AutoMutex; */ class Condition { public: + enum { + PRIVATE = 0, + SHARED = 1 + }; + Condition(); + Condition(int type); ~Condition(); // Wait on the condition variable. Lock the mutex before calling. status_t wait(Mutex& mutex); @@ -329,6 +335,17 @@ private: inline Condition::Condition() { pthread_cond_init(&mCond, NULL); } +inline Condition::Condition(int type) { + if (type == SHARED) { + pthread_condattr_t attr; + pthread_condattr_init(&attr); + pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_cond_init(&mCond, &attr); + pthread_condattr_destroy(&attr); + } else { + pthread_cond_init(&mCond, NULL); + } +} inline Condition::~Condition() { pthread_cond_destroy(&mCond); } diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 473f58090b..0016503186 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -935,17 +935,27 @@ status_t IPCThreadState::executeCommand(int32_t cmd) mCallingPid = tr.sender_pid; mCallingUid = tr.sender_euid; - bool doBackground = !gDisableBackgroundScheduling && - getpriority(PRIO_PROCESS, mMyThreadId) - >= ANDROID_PRIORITY_BACKGROUND; - if (doBackground) { - // We have inherited a background priority from the caller. - // Ensure this thread is in the background scheduling class, - // since the driver won't modify scheduling classes for us. - androidSetThreadSchedulingGroup(mMyThreadId, - ANDROID_TGROUP_BG_NONINTERACT); + int curPrio = getpriority(PRIO_PROCESS, mMyThreadId); + if (gDisableBackgroundScheduling) { + if (curPrio > ANDROID_PRIORITY_NORMAL) { + // We have inherited a reduced priority from the caller, but do not + // want to run in that state in this process. The driver set our + // priority already (though not our scheduling class), so bounce + // it back to the default before invoking the transaction. + setpriority(PRIO_PROCESS, mMyThreadId, ANDROID_PRIORITY_NORMAL); + } + } else { + if (curPrio >= ANDROID_PRIORITY_BACKGROUND) { + // We want to use the inherited priority from the caller. + // Ensure this thread is in the background scheduling class, + // since the driver won't modify scheduling classes for us. + // The scheduling group is reset to default by the caller + // once this method returns after the transaction is complete. + androidSetThreadSchedulingGroup(mMyThreadId, + ANDROID_TGROUP_BG_NONINTERACT); + } } - + //LOGI(">>>> TRANSACT from pid %d uid %d\n", mCallingPid, mCallingUid); Parcel reply; @@ -982,14 +992,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd) mCallingPid = origPid; mCallingUid = origUid; - - if (doBackground) { - // We moved to the background scheduling group to execute - // this transaction, so now that we are done go back in the - // foreground. - androidSetThreadSchedulingGroup(mMyThreadId, ANDROID_TGROUP_DEFAULT); - } - + IF_LOG_TRANSACTIONS() { TextOutput::Bundle _b(alog); alog << "BC_REPLY thr " << (void*)pthread_self() << " / obj " diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp index 65ce1c1cff..a17e8acc57 100644 --- a/libs/surfaceflinger_client/SharedBufferStack.cpp +++ b/libs/surfaceflinger_client/SharedBufferStack.cpp @@ -34,7 +34,7 @@ namespace android { // ---------------------------------------------------------------------------- SharedClient::SharedClient() - : lock(Mutex::SHARED) + : lock(Mutex::SHARED), cv(Condition::SHARED) { } |