This commit is contained in:
Reece H. Dunn
2012-12-10 16:49:26 +00:00
parent 4eff8623d5
commit f9b7bbab1c
120 changed files with 4132 additions and 2583 deletions
+23 -10
View File
@@ -745,19 +745,32 @@ size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSiz
int wave_close(void* theHandler)
{
SHOW_TIME("wave_close > ENTER");
static int aStopStreamCount = 0;
int a_status = pthread_mutex_lock(&pulse_mutex);
if (a_status) {
SHOW("Error: pulse_mutex lock=%d (%s)\n", a_status, __FUNCTION__);
return PULSE_ERROR;
}
drain();
// Avoid race condition by making sure this function only
// gets called once at a time
aStopStreamCount++;
if (aStopStreamCount != 1)
{
SHOW_TIME("wave_close > LEAVE (stopStreamCount)");
return 0;
}
pthread_mutex_unlock(&pulse_mutex);
SHOW_TIME("wave_close (ret)");
int a_status = pthread_mutex_lock(&pulse_mutex);
if (a_status)
{
SHOW("Error: pulse_mutex lock=%d (%s)\n", a_status, __FUNCTION__);
aStopStreamCount = 0; // last action
return PULSE_ERROR;
}
return PULSE_OK;
drain();
pthread_mutex_unlock(&pulse_mutex);
SHOW_TIME("wave_close (ret)");
aStopStreamCount = 0; // last action
return PULSE_OK;
}
//>