Loading media/libstagefright/LPAPlayer.cpp +34 −1 Original line number Diff line number Diff line Loading @@ -743,10 +743,13 @@ void LPAPlayer::decoderThreadEntry() { audio_register_memory(); while (1) { LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); if (killDecoderThread) { LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); break; } Loading @@ -760,22 +763,30 @@ void LPAPlayer::decoderThreadEntry() { mReachedEOS, bIsA2DPEnabled, mAudioSinkOpen, asyncReset, mIsDriverStarted); LOGV("decoderThreadEntry: waiting on decoder_cv"); pthread_cond_wait(&decoder_cv, &mem_request_mutex); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("decoderThreadEntry: received a signal to wake up"); LOGV("mem_request_mutex unlocked: %d", __LINE__); continue; } List<BuffersAllocated>::iterator it = memBuffersRequestQueue.begin(); BuffersAllocated buf = *it; memBuffersRequestQueue.erase(it); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); //Queue the buffers back to Request queue if (mReachedEOS || (bIsA2DPEnabled && !mAudioSinkOpen) || asyncReset || a2dpDisconnectPause) { LOGV("%s: mReachedEOS %d bIsA2DPEnabled %d ", __func__, mReachedEOS, bIsA2DPEnabled); LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); } //Queue up the buffers for writing either for A2DP or LPA Driver else { Loading Loading @@ -817,9 +828,13 @@ void LPAPlayer::decoderThreadEntry() { } } else { /* Put the buffer back into requestQ */ LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); /* This is zero byte buffer - no need to put in response Q*/ if (mObserver && mReachedEOS && memBuffersResponseQueue.empty()) { LOGV("Posting EOS event to AwesomePlayer"); Loading Loading @@ -975,9 +990,13 @@ void LPAPlayer::eventThreadEntry() { pthread_mutex_unlock(&mem_response_mutex); // Post buffer to request Q LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); pthread_cond_signal(&decoder_cv); } Loading Loading @@ -1086,7 +1105,9 @@ void LPAPlayer::A2DPThreadEntry() { LOGV("A2DPThreadEntry:: received signal to wake up"); // A2DP got disabled -- Queue up everything back to Request Queue if (!bIsA2DPEnabled) { LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); while (!memBuffersResponseQueue.empty()) { LOGV("BUF transfer"); List<BuffersAllocated>::iterator it = memBuffersResponseQueue.begin(); Loading @@ -1094,7 +1115,9 @@ void LPAPlayer::A2DPThreadEntry() { memBuffersRequestQueue.push_back(buf); memBuffersResponseQueue.erase(it); } LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); } pthread_mutex_unlock(&mem_response_mutex); } Loading Loading @@ -1178,10 +1201,14 @@ void LPAPlayer::A2DPThreadEntry() { LOGV("Posting EOS event to AwesomePlayer"); mObserver->postAudioEOS(); } LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); if (killA2DPThread) { LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); break; } //flush out old buffer Loading @@ -1197,7 +1224,9 @@ void LPAPlayer::A2DPThreadEntry() { } pthread_mutex_unlock(&mem_response_mutex); } LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); // Signal decoder thread when a buffer is put back to request Q pthread_cond_signal(&decoder_cv); } Loading Loading @@ -1557,10 +1586,14 @@ void LPAPlayer::requestAndWaitForDecoderThreadExit() { if (!decoderThreadAlive) return; LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); killDecoderThread = true; pthread_cond_signal(&decoder_cv); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); pthread_join(decoderThread,NULL); LOGV("decoder thread killed"); Loading Loading
media/libstagefright/LPAPlayer.cpp +34 −1 Original line number Diff line number Diff line Loading @@ -743,10 +743,13 @@ void LPAPlayer::decoderThreadEntry() { audio_register_memory(); while (1) { LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); if (killDecoderThread) { LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); break; } Loading @@ -760,22 +763,30 @@ void LPAPlayer::decoderThreadEntry() { mReachedEOS, bIsA2DPEnabled, mAudioSinkOpen, asyncReset, mIsDriverStarted); LOGV("decoderThreadEntry: waiting on decoder_cv"); pthread_cond_wait(&decoder_cv, &mem_request_mutex); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("decoderThreadEntry: received a signal to wake up"); LOGV("mem_request_mutex unlocked: %d", __LINE__); continue; } List<BuffersAllocated>::iterator it = memBuffersRequestQueue.begin(); BuffersAllocated buf = *it; memBuffersRequestQueue.erase(it); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); //Queue the buffers back to Request queue if (mReachedEOS || (bIsA2DPEnabled && !mAudioSinkOpen) || asyncReset || a2dpDisconnectPause) { LOGV("%s: mReachedEOS %d bIsA2DPEnabled %d ", __func__, mReachedEOS, bIsA2DPEnabled); LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); } //Queue up the buffers for writing either for A2DP or LPA Driver else { Loading Loading @@ -817,9 +828,13 @@ void LPAPlayer::decoderThreadEntry() { } } else { /* Put the buffer back into requestQ */ LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); /* This is zero byte buffer - no need to put in response Q*/ if (mObserver && mReachedEOS && memBuffersResponseQueue.empty()) { LOGV("Posting EOS event to AwesomePlayer"); Loading Loading @@ -975,9 +990,13 @@ void LPAPlayer::eventThreadEntry() { pthread_mutex_unlock(&mem_response_mutex); // Post buffer to request Q LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); pthread_cond_signal(&decoder_cv); } Loading Loading @@ -1086,7 +1105,9 @@ void LPAPlayer::A2DPThreadEntry() { LOGV("A2DPThreadEntry:: received signal to wake up"); // A2DP got disabled -- Queue up everything back to Request Queue if (!bIsA2DPEnabled) { LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); while (!memBuffersResponseQueue.empty()) { LOGV("BUF transfer"); List<BuffersAllocated>::iterator it = memBuffersResponseQueue.begin(); Loading @@ -1094,7 +1115,9 @@ void LPAPlayer::A2DPThreadEntry() { memBuffersRequestQueue.push_back(buf); memBuffersResponseQueue.erase(it); } LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); } pthread_mutex_unlock(&mem_response_mutex); } Loading Loading @@ -1178,10 +1201,14 @@ void LPAPlayer::A2DPThreadEntry() { LOGV("Posting EOS event to AwesomePlayer"); mObserver->postAudioEOS(); } LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); memBuffersRequestQueue.push_back(buf); if (killA2DPThread) { LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); break; } //flush out old buffer Loading @@ -1197,7 +1224,9 @@ void LPAPlayer::A2DPThreadEntry() { } pthread_mutex_unlock(&mem_response_mutex); } LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); // Signal decoder thread when a buffer is put back to request Q pthread_cond_signal(&decoder_cv); } Loading Loading @@ -1557,10 +1586,14 @@ void LPAPlayer::requestAndWaitForDecoderThreadExit() { if (!decoderThreadAlive) return; LOGV("mem_request_mutex locking: %d", __LINE__); pthread_mutex_lock(&mem_request_mutex); LOGV("mem_request_mutex locked: %d", __LINE__); killDecoderThread = true; pthread_cond_signal(&decoder_cv); LOGV("mem_request_mutex unlocking: %d", __LINE__); pthread_mutex_unlock(&mem_request_mutex); LOGV("mem_request_mutex unlocked: %d", __LINE__); pthread_join(decoderThread,NULL); LOGV("decoder thread killed"); Loading