If pcm_open() fails with -EBUSY, t->cond is never signaled and
tfa_clock_on() stalls the driver in its while (!tfa_dev->writing) loop
where it waits for the signal to be delivered.
Avoid this by always signaling the calling thread.
Change-Id: I4fd81080e77d5f37963714a5d6b4556c387f5a33
(cherry picked from commit
07b6fbed54c84e8e83f4e3f6ceb89fef81038536)
uint8_t *buffer;
int size;
struct pcm *pcm;
+ bool signaled = false;
+
struct pcm_config config = {
.channels = 2,
.rate = 48000,
goto err_close_pcm;
}
- bool signaled = false;
do {
if (pcm_write(pcm, buffer, size)) {
ALOGE("%s: pcm_write failed", __func__);
err_close_pcm:
pcm_close(pcm);
exit:
+ if (!signaled) {
+ pthread_mutex_lock(&t->mutex);
+ t->writing = true;
+ pthread_cond_signal(&t->cond);
+ pthread_mutex_unlock(&t->mutex);
+ }
+
return NULL;
}