mm-audio: Avoid command thread loop if omx component is stopped

When omx init and deinit are called in short duration,there
is a possibility that deinit is called before command thread
is started. omx_thread_stop closes respective pipe and waits
for the command thread to exit.
In a specific scenario, same pipe fd is allocated in another
module and command thread in omx continues to read from the
same pipe although it is closed by the main omx thread.
omx_thread_stop is blocked infinitely due to this reason

Fix is to set a flag in omx_thread_stop to avoid command
thread to go into the read loop if it is started after
omx_thread_stop is called

Change-Id: I4b9c4909c7178010568219fddcd05eaafdddc769
diff --git a/mm-audio/aenc-aac/qdsp6/src/aenc_svr.c b/mm-audio/aenc-aac/qdsp6/src/aenc_svr.c
index 9a8448a..53e371e 100644
--- a/mm-audio/aenc-aac/qdsp6/src/aenc_svr.c
+++ b/mm-audio/aenc-aac/qdsp6/src/aenc_svr.c
@@ -1,5 +1,5 @@
 /*--------------------------------------------------------------------------
-Copyright (c) 2010, 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:
@@ -189,6 +189,7 @@
 
 void omx_aac_thread_stop(struct aac_ipc_info *aac_info) {
     DEBUG_DETAIL("%s stop server\n", __FUNCTION__);
+    aac_info->dead = 1;
     close(aac_info->pipe_in);
     close(aac_info->pipe_out);
     pthread_join(aac_info->thr,NULL);
diff --git a/mm-audio/aenc-amrnb/qdsp6/src/aenc_svr.c b/mm-audio/aenc-amrnb/qdsp6/src/aenc_svr.c
index dea7c7f..f283c32 100644
--- a/mm-audio/aenc-amrnb/qdsp6/src/aenc_svr.c
+++ b/mm-audio/aenc-amrnb/qdsp6/src/aenc_svr.c
@@ -1,5 +1,5 @@
 /*--------------------------------------------------------------------------
-Copyright (c) 2010, 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:
@@ -189,6 +189,7 @@
 
 void omx_amr_thread_stop(struct amr_ipc_info *amr_info) {
     DEBUG_DETAIL("%s stop server\n", __FUNCTION__);
+    amr_info->dead = 1;
     close(amr_info->pipe_in);
     close(amr_info->pipe_out);
     pthread_join(amr_info->thr,NULL);
diff --git a/mm-audio/aenc-evrc/qdsp6/src/aenc_svr.c b/mm-audio/aenc-evrc/qdsp6/src/aenc_svr.c
index 4f828fc..feda0a5 100644
--- a/mm-audio/aenc-evrc/qdsp6/src/aenc_svr.c
+++ b/mm-audio/aenc-evrc/qdsp6/src/aenc_svr.c
@@ -1,5 +1,5 @@
 /*--------------------------------------------------------------------------
-Copyright (c) 2010, 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:
@@ -189,6 +189,7 @@
 
 void omx_evrc_thread_stop(struct evrc_ipc_info *evrc_info) {
     DEBUG_DETAIL("%s stop server\n", __FUNCTION__);
+    evrc_info->dead = 1;
     close(evrc_info->pipe_in);
     close(evrc_info->pipe_out);
     pthread_join(evrc_info->thr,NULL);
diff --git a/mm-audio/aenc-qcelp13/qdsp6/src/aenc_svr.c b/mm-audio/aenc-qcelp13/qdsp6/src/aenc_svr.c
index bdc96ac..6304918 100644
--- a/mm-audio/aenc-qcelp13/qdsp6/src/aenc_svr.c
+++ b/mm-audio/aenc-qcelp13/qdsp6/src/aenc_svr.c
@@ -1,5 +1,5 @@
 /*--------------------------------------------------------------------------
-Copyright (c) 2010, 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:
@@ -191,6 +191,7 @@
 
 void omx_qcelp13_thread_stop(struct qcelp13_ipc_info *qcelp13_info) {
     DEBUG_DETAIL("%s stop server\n", __FUNCTION__);
+    qcelp13_info->dead = 1;
     close(qcelp13_info->pipe_in);
     close(qcelp13_info->pipe_out);
     pthread_join(qcelp13_info->thr,NULL);