summaryrefslogtreecommitdiffstats
path: root/opensles
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2010-09-27 17:13:09 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-27 17:13:09 -0700
commit0673981b5807e901fc8f025052bcac0ac3654a7f (patch)
tree9f0d7aa168d36035377216c9c795d5e65f7f9371 /opensles
parent6e31131dc148be814134987404c89ee946e432ca (diff)
parentcc484cd4b7ede364e95209eb0468df3bc51f50e5 (diff)
downloadandroid_system_media-0673981b5807e901fc8f025052bcac0ac3654a7f.tar.gz
android_system_media-0673981b5807e901fc8f025052bcac0ac3654a7f.tar.bz2
android_system_media-0673981b5807e901fc8f025052bcac0ac3654a7f.zip
Merge "Destroy for an unrealized engine was hanging" into gingerbread
Diffstat (limited to 'opensles')
-rw-r--r--opensles/libopensles/CEngine.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/opensles/libopensles/CEngine.c b/opensles/libopensles/CEngine.c
index 0bc00c00..f58e3b5c 100644
--- a/opensles/libopensles/CEngine.c
+++ b/opensles/libopensles/CEngine.c
@@ -73,14 +73,21 @@ void CEngine_Destroy(void *self)
}
}
- // Announce to the sync thread that engine is shutting down; it polls so should see it soon
- this->mEngine.mShutdown = SL_BOOLEAN_TRUE;
- // Wait for the sync thread to acknowledge the shutdown
- while (!this->mEngine.mShutdownAck) {
- object_cond_wait(&this->mObject);
+ // If engine was created but not realized, there will be no sync thread yet
+ pthread_t zero;
+ memset(&zero, 0, sizeof(pthread_t));
+ if (0 != memcmp(&zero, &this->mSyncThread, sizeof(pthread_t))) {
+
+ // Announce to the sync thread that engine is shutting down; it polls so should see it soon
+ this->mEngine.mShutdown = SL_BOOLEAN_TRUE;
+ // Wait for the sync thread to acknowledge the shutdown
+ while (!this->mEngine.mShutdownAck) {
+ object_cond_wait(&this->mObject);
+ }
+ // The sync thread should have exited by now, so collect it by joining
+ (void) pthread_join(this->mSyncThread, (void **) NULL);
+
}
- // The sync thread should have exited by now, so collect it by joining
- (void) pthread_join(this->mSyncThread, (void **) NULL);
// Shutdown the thread pool used for asynchronous operations (there should not be any)
ThreadPool_deinit(&this->mEngine.mThreadPool);