audio: qahw_api: Remove pthread_cancel api
Remove pthread_cancel api, as it is not defined android standard library. Adding pthread_kill api to handle input command thread. Change-Id: Ia9d7f3939f1f7a5851f6aa22fe0894acb814a902
This commit is contained in:
parent
df39d4fb3a
commit
0d2b1e411e
|
@ -34,6 +34,7 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "qahw_api.h"
|
||||
#include "qahw_defs.h"
|
||||
|
@ -111,6 +112,12 @@ const char * effect_str[EFFECT_MAX] = {
|
|||
#define NUM_EQ_BANDS 5
|
||||
const uint16_t qahw_equalizer_band_freqs[NUM_EQ_BANDS] = {60, 230, 910, 3600, 14000}; /* frequencies in HZ */
|
||||
|
||||
/* Handler to handle input command_thread_func signal */
|
||||
void stop_effect_command_thread_handler(int signal __unused)
|
||||
{
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
/* THREAD BODY OF BASSBOOST */
|
||||
void *bassboost_thread_func(void* data) {
|
||||
thread_data_t *thr_ctxt = (thread_data_t *)data;
|
||||
|
@ -489,6 +496,12 @@ void *command_thread_func(void* data) {
|
|||
qahw_effect_param_t *param = (qahw_effect_param_t *)buf32;
|
||||
qahw_effect_param_t *param_2 = (qahw_effect_param_t *)buf32_2;
|
||||
|
||||
/* Register the SIGUSR1 to close this thread properly
|
||||
as it is waiting for input in while loop */
|
||||
if (signal(SIGUSR1, stop_effect_command_thread_handler) == SIG_ERR) {
|
||||
fprintf(stderr, "Failed to register SIGUSR1:%d\n",errno);
|
||||
}
|
||||
|
||||
while(!thr_ctxt->exit) {
|
||||
if (fgets(cmd_str, sizeof(cmd_str), stdin) == NULL) {
|
||||
fprintf(stderr, "read error\n");
|
||||
|
|
|
@ -854,10 +854,12 @@ void *start_stream_playback (void* stream_data)
|
|||
// destory effect command thread
|
||||
params->cmd_data.exit = true;
|
||||
usleep(100000); // give a chance for thread to exit gracefully
|
||||
rc = pthread_cancel(params->cmd_data.cmd_thread);
|
||||
|
||||
//Send signal for input command_thread_func to stop
|
||||
rc = pthread_kill(params->cmd_data.cmd_thread, SIGUSR1);
|
||||
if (rc != 0) {
|
||||
fprintf(log_file, "Fail to cancel thread!\n");
|
||||
fprintf(stderr, "Fail to cancel thread!\n");
|
||||
fprintf(log_file, "Fail to kill effect command thread!\n");
|
||||
fprintf(stderr, "Fail to kill effect command thread!\n");
|
||||
}
|
||||
rc = pthread_join(params->cmd_data.cmd_thread, NULL);
|
||||
if (rc < 0) {
|
||||
|
|
Loading…
Reference in New Issue