mm-audio: omx: Fix handling of flush error on session not found
If the current session is not found in the driver, a special
error code is returned. On observing this error, stop waiting for a
response from the current (presumably) dead session to avoid
stalling indefinitely.
Change-Id: Ife1ace9c34178d15eff723a5634b4514cd1e1545
diff --git a/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp b/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp
index 6154e0c..d2dd1d0 100644
--- a/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp
+++ b/mm-audio/aenc-aac/qdsp6/src/omx_aac_aenc.cpp
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
+Copyright (c) 2010-2016, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -145,7 +145,7 @@
=============================================================================*/
void omx_aac_aenc::wait_for_event()
{
- int rc;
+ int rc = 0;
struct timespec ts;
pthread_mutex_lock(&m_event_lock);
while (0 == m_is_event_done)
@@ -155,10 +155,19 @@
ts.tv_nsec += ((SLEEP_MS%1000) * 1000000);
rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts);
if (rc == ETIMEDOUT && !m_is_event_done) {
- DEBUG_PRINT("Timed out waiting for flush");
- if (ioctl( m_drv_fd, AUDIO_FLUSH, 0) == -1)
- DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed %d\n",
- errno);
+ DEBUG_PRINT("Timed out waiting for flush");
+ rc = ioctl(m_drv_fd, AUDIO_FLUSH, 0);
+ if (rc == -1)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ }
+ else if (rc < 0)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl failed error: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ break;
+ }
}
}
m_is_event_done = 0;
diff --git a/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp b/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp
index 5e9ee4e..ba66d1b 100644
--- a/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp
+++ b/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved.
+Copyright (c) 2010, 2014, 2016, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -144,7 +144,7 @@
=============================================================================*/
void omx_amr_aenc::wait_for_event()
{
- int rc;
+ int rc = 0;
struct timespec ts;
pthread_mutex_lock(&m_event_lock);
while (0 == m_is_event_done)
@@ -154,10 +154,19 @@
ts.tv_nsec += ((SLEEP_MS%1000) * 1000000);
rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts);
if (rc == ETIMEDOUT && !m_is_event_done) {
- DEBUG_PRINT("Timed out waiting for flush");
- if (ioctl( m_drv_fd, AUDIO_FLUSH, 0) == -1)
- DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed %d\n",
- errno);
+ DEBUG_PRINT("Timed out waiting for flush");
+ rc = ioctl(m_drv_fd, AUDIO_FLUSH, 0);
+ if (rc == -1)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ }
+ else if (rc < 0)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl failed error: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ break;
+ }
}
}
m_is_event_done = 0;
diff --git a/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp b/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp
index af9f785..84bb774 100644
--- a/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp
+++ b/mm-audio/aenc-evrc/qdsp6/src/omx_evrc_aenc.cpp
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved.
+Copyright (c) 2010, 2014-2016, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -144,7 +144,7 @@
=============================================================================*/
void omx_evrc_aenc::wait_for_event()
{
- int rc;
+ int rc = 0;
struct timespec ts;
pthread_mutex_lock(&m_event_lock);
while (0 == m_is_event_done)
@@ -154,10 +154,19 @@
ts.tv_nsec += ((SLEEP_MS%1000) * 1000000);
rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts);
if (rc == ETIMEDOUT && !m_is_event_done) {
- DEBUG_PRINT("Timed out waiting for flush");
- if (ioctl( m_drv_fd, AUDIO_FLUSH, 0) == -1)
- DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed %d\n",
- errno);
+ DEBUG_PRINT("Timed out waiting for flush");
+ rc = ioctl(m_drv_fd, AUDIO_FLUSH, 0);
+ if (rc == -1)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ }
+ else if (rc < 0)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl failed error: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ break;
+ }
}
}
m_is_event_done = 0;
diff --git a/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp b/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp
index d25eb7f..1d7962b 100644
--- a/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp
+++ b/mm-audio/aenc-qcelp13/qdsp6/src/omx_qcelp13_aenc.cpp
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
-Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved.
+Copyright (c) 2010, 2014-2016, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -144,7 +144,7 @@
=============================================================================*/
void omx_qcelp13_aenc::wait_for_event()
{
- int rc;
+ int rc = 0;
struct timespec ts;
pthread_mutex_lock(&m_event_lock);
while (0 == m_is_event_done)
@@ -154,10 +154,19 @@
ts.tv_nsec += ((SLEEP_MS%1000) * 1000000);
rc = pthread_cond_timedwait(&cond, &m_event_lock, &ts);
if (rc == ETIMEDOUT && !m_is_event_done) {
- DEBUG_PRINT("Timed out waiting for flush");
- if (ioctl( m_drv_fd, AUDIO_FLUSH, 0) == -1)
- DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed %d\n",
- errno);
+ DEBUG_PRINT("Timed out waiting for flush");
+ rc = ioctl( m_drv_fd, AUDIO_FLUSH, 0);
+ if (rc == -1)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl flush failed: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ }
+ else if (rc < 0)
+ {
+ DEBUG_PRINT_ERROR("Flush:Input port, ioctl failed error: rc:%d, %s, no:%d \n",
+ rc, strerror(errno), errno);
+ break;
+ }
}
}
m_is_event_done = 0;