PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER should only
be used for statically allocated mutexes - not doing it here breaks
building on 64-bit Android.
class MutexWithCondition {
public:
class MutexWithCondition {
public:
- MutexWithCondition() { pthread_mutex_lock(&mutex); }
+ MutexWithCondition() {
+ pthread_mutex_init(&mutex, NULL);
+ pthread_cond_init(&condition, NULL);
+ pthread_mutex_lock(&mutex);
+ }
~MutexWithCondition() { pthread_mutex_unlock(&mutex); }
void waitFor() { while (!occurred) pthread_cond_wait(&condition, &mutex); }
/** From waking thread. */
~MutexWithCondition() { pthread_mutex_unlock(&mutex); }
void waitFor() { while (!occurred) pthread_cond_wait(&condition, &mutex); }
/** From waking thread. */
}
private:
volatile bool occurred{false};
}
private:
volatile bool occurred{false};
- pthread_mutex_t mutex{PTHREAD_MUTEX_INITIALIZER};
- pthread_cond_t condition{PTHREAD_COND_INITIALIZER};
+ pthread_mutex_t mutex;
+ pthread_cond_t condition;
};
AudioPlayer::AudioPlayer() {
};
AudioPlayer::AudioPlayer() {