hal:qap: Fix to avoid hang at the end of playback
-Testapp not handling the EOS if it comes synchronously.
-Adding an eos flag to identify if EOS is received.
CRs-Fixed: 2134740
Change-Id: Ia040f022bbcd27dd40e143178d5bd747359e9ce3
diff --git a/qahw_api/test/qap_wrapper_extn.c b/qahw_api/test/qap_wrapper_extn.c
index 0f24412..050796c 100644
--- a/qahw_api/test/qap_wrapper_extn.c
+++ b/qahw_api/test/qap_wrapper_extn.c
@@ -105,6 +105,8 @@
pthread_mutex_t main_eos_lock;
pthread_cond_t sec_eos_cond;
pthread_mutex_t sec_eos_lock;
+bool main_eos_received = false;
+bool sec_eos_received = false;
dlb_ms12_session_param_t dlb_param;
dlb_ms12_session_param_t dlb_param_hp;
@@ -802,6 +804,7 @@
stream_cnt--;
pthread_mutex_lock(&main_eos_lock);
pthread_cond_signal(&main_eos_cond);
+ main_eos_received = true;
pthread_mutex_unlock(&main_eos_lock);
ALOGE("%s %d Received Main Input EOS ", __func__, __LINE__);
@@ -820,6 +823,7 @@
ALOGV("%s %d Received Secondary Input EOS", __func__, __LINE__);
pthread_mutex_lock(&sec_eos_lock);
pthread_cond_signal(&sec_eos_cond);
+ sec_eos_received = true;
pthread_mutex_unlock(&sec_eos_lock);
}
if (!stream_cnt)
@@ -1580,16 +1584,22 @@
wait_for_eos:
if (stream_info->sec_input) {
- pthread_mutex_lock(&sec_eos_lock);
- pthread_cond_wait(&sec_eos_cond, &sec_eos_lock);
- pthread_mutex_unlock(&sec_eos_lock);
+ if (!sec_eos_received) {
+ pthread_mutex_lock(&sec_eos_lock);
+ pthread_cond_wait(&sec_eos_cond, &sec_eos_lock);
+ pthread_mutex_unlock(&sec_eos_lock);
+ }
+ sec_eos_received = false;
fprintf(stdout, "Received EOS event for secondary input\n");
ALOGV("Received EOS event for secondary input\n");
}
if (!(stream_info->system_input || stream_info->sec_input)){
- pthread_mutex_lock(&main_eos_lock);
- pthread_cond_wait(&main_eos_cond, &main_eos_lock);
- pthread_mutex_unlock(&main_eos_lock);
+ if (!main_eos_received) {
+ pthread_mutex_lock(&main_eos_lock);
+ pthread_cond_wait(&main_eos_cond, &main_eos_lock);
+ pthread_mutex_unlock(&main_eos_lock);
+ }
+ main_eos_received = false;
fprintf(stdout, "Received EOS event for main input\n");
ALOGV("Received EOS event for main input\n");
}