GList *list = NULL;
focus_node_t *node = NULL;
- debug_log("================================================ focus node list : start ===================================================\n");
+ debug_msg("================================================ focus node list : start ===================================================\n");
for (list = g_focus_node_list; list != NULL; list = list->next) {
if ((node = (focus_node_t *)list->data) && !node->is_for_watch) {
- debug_log("*** pid[%5d]/handle_id[%2d]/[%14s]:priority[%2d],status[%s],taken_by[P(%5d/%2d/%2d)C(%5d/%2d/%2d)],session[%d],option[0x%x/0x%x],ext_info[%s/%s]\n",
+ debug_msg("*** pid[%5d]/handle_id[%2d]/[%14s]:priority[%2d],status[%s],taken_by[P(%5d/%2d/%2d)C(%5d/%2d/%2d)],session[%d],option[0x%x/0x%x],ext_info[%s/%s]\n",
node->pid, node->handle_id, node->stream_type, node->priority, focus_status_str[node->status],
node->taken_by_id[0].pid, node->taken_by_id[0].handle_id, node->taken_by_id[0].by_session, node->taken_by_id[1].pid,
node->taken_by_id[1].handle_id, node->taken_by_id[1].by_session, node->is_for_session, node->option[0], node->option[1], node->ext_info[0], node->ext_info[1]);
}
}
- debug_log("================================================ focus node list : end =====================================================\n");
+ debug_msg("================================================ focus node list : end =====================================================\n");
return ret;
}
GList *list = NULL;
focus_node_t *node = NULL;
- debug_log("============================================= focus watch node list : start =================================================\n");
+ debug_msg("============================================= focus watch node list : start =================================================\n");
for (list = g_focus_node_list; list != NULL; list = list->next) {
if ((node = (focus_node_t *)list->data) && node->is_for_watch)
- debug_log("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]/for_session[%d]\n", node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session);
+ debug_msg("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]/for_session[%d]\n", node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session);
}
- debug_log("============================================= focus watch node list : end ===================================================\n");
+ debug_msg("============================================= focus watch node list : end ===================================================\n");
return ret;
}
#define CHANNELS 1
#define MAX_DURATION 100
#define TONE_COLUMN 6
+#define WAIT_THREAD_WAIT_CNT 100
+#define WAIT_THREAD_WAIT_TIME 10 /* ms */
typedef enum {
- STATE_NONE = 0,
- STATE_READY,
- STATE_BEGIN,
- STATE_PLAY,
- STATE_STOP,
+ STATE_NONE = 0,
+ STATE_READY,
+ STATE_BEGIN,
+ STATE_PLAY,
+ STATE_STOP,
} state_e;
typedef enum {
+ THREAD_STATE_NONE = 0,
+ THREAD_STATE_START,
+ THREAD_STATE_STOP,
+} thread_state_e;
+
+
+typedef enum {
CONTROL_STOPPED,
CONTROL_READY,
CONTROL_STARTING,
typedef struct {
/* AMR Buffer */
int size; /* sizeof hole amr data */
+ pthread_mutex_t mutex;
/* Audio Infomations */
int handle;
int time;
int pid;
+ int thread_state;
} tone_info_t;
typedef enum
int size;
int result = MM_ERROR_NONE;
+ int wait_count = 0;
debug_enter("\n");
memset(toneInfo, 0, sizeof(tone_info_t));
+ pthread_mutex_init(&toneInfo->mutex, NULL);
+ pthread_mutex_lock(&toneInfo->mutex);
toneInfo->state = STATE_READY;
+ toneInfo->thread_state = THREAD_STATE_NONE;
+ pthread_mutex_unlock(&toneInfo->mutex);
ss.rate = SAMPLERATE;
ss.channels = CHANNELS;
*handle = (MMHandleType)toneInfo;
+ debug_msg("wait until thread_stare THREAD_STATE_START");
+ while((toneInfo->thread_state == THREAD_STATE_NONE) && (wait_count < WAIT_THREAD_WAIT_CNT)) {
+ usleep(WAIT_THREAD_WAIT_TIME * 1000);
+ wait_count++;
+ }
+
+ if (wait_count >= WAIT_THREAD_WAIT_CNT) {
+ debug_error("timeout for thread pool. wait_count: %d ms ", WAIT_THREAD_WAIT_CNT * WAIT_THREAD_WAIT_TIME);
+ } else {
+ debug_msg("_running_tone thread is started");
+ }
+
debug_leave("\n");
return MM_ERROR_NONE;
debug_enter("(handle %x)\n", handle);
+ pthread_mutex_destroy(&toneInfo->mutex);
if (toneInfo)
free (toneInfo);
tone_info_t *toneInfo = (tone_info_t *) handle;
debug_enter("(handle %x)\n", handle);
-
+ pthread_mutex_lock(&toneInfo->mutex);
toneInfo->state = STATE_BEGIN;
+ pthread_mutex_unlock(&toneInfo->mutex);
debug_msg("sent start signal\n");
debug_leave("\n");
gboolean is_cycle_ended = FALSE;
debug_enter("\n");
+ pthread_mutex_lock(&toneInfo->mutex);
+ toneInfo->thread_state = THREAD_STATE_START;
+ debug_msg("set thread_state as THREAD_STATE_START");
+ pthread_mutex_unlock(&toneInfo->mutex);
double sample = 0;
toneTime = toneInfo->time;
if(toneTime != 0) {
while(toneInfo->state == STATE_READY)
usleep(10);
debug_msg("Recv start signal\n");
- toneInfo->state = STATE_PLAY;
+ pthread_mutex_lock(&toneInfo->mutex);
+
+ if ((toneInfo->state == STATE_STOP)||(toneInfo->thread_state == THREAD_STATE_STOP)) {
+ debug_msg("state is stop. state(%d) thread_state(%d) goto exit.\n", toneInfo->state, toneInfo->thread_state );
+ pthread_mutex_unlock(&toneInfo->mutex);
+ goto exit;
+ } else {
+ debug_msg("set state STATE_PLAY\n");
+ toneInfo->state = STATE_PLAY;
+ }
+ pthread_mutex_unlock(&toneInfo->mutex);
+
} else {
return;
}
- while (1) {
+ while (toneInfo->thread_state == THREAD_STATE_START) {
TONE _TONE = _mm_get_tone(toneKey, CurIndex); /*Pop one of Tone Set */
if(_mm_get_waveCnt_PlayingTime(toneTime, _TONE, &numWave, &waveRestPlayTime) != MM_ERROR_NONE) {
debug_error("_mm_get_waveCnt_PlayingTime return value error\n");
#endif
debug_msg("Play end\n");
+ pthread_mutex_lock(&toneInfo->mutex);
toneInfo->state = STATE_NONE;
+ pthread_mutex_unlock(&toneInfo->mutex);
if (toneInfo->stop_cb)
toneInfo->stop_cb(toneInfo->cb_param);
tone_info_t *toneInfo = (tone_info_t*) handle;
debug_enter("(handle %x)\n", handle);
+ pthread_mutex_lock(&toneInfo->mutex);
+ /*If stopped why stop again*/
+ if (toneInfo->state == STATE_NONE || toneInfo->state == STATE_STOP) {
+ pthread_mutex_unlock(&toneInfo->mutex);
+ debug_msg("state(%d) is already STOP or NONE. return\n", toneInfo->state);
+ return MM_ERROR_NONE;
+ }
toneInfo->state = STATE_STOP;
+ toneInfo->thread_state = THREAD_STATE_STOP;
+ pthread_mutex_unlock(&toneInfo->mutex);
debug_msg("sent stop signal\n");
while(toneInfo->state != STATE_NONE) {