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;
}
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.10.93
+Version: 0.10.94
Release: 0
Group: System/Libraries
License: Apache-2.0
static int (*g_thread_pool_func)(void*, void (*)(void*)) = NULL;
+static void _reset_ogg_decoder(ogg_info_t *p)
+{
+ int err, used_size, skipsize;
+ OGG_DEC_INFO ogg_info;
+
+ err = OGGDEC_ResetDecode(p->decoder);
+ if (err != OGGDEC_SUCCESS) {
+ debug_error("Failed to RESET decoder!");
+ return;
+ }
+
+ err = OGGDEC_InitDecode(p->decoder, (unsigned char*)p->source->ptr, p->BufferSize, &skipsize);
+ if (err != OGGDEC_SUCCESS) {
+ debug_error("Failed to INIT decoder!");
+ return;
+ }
+
+ err = OGGDEC_InfoDecode(p->decoder, p->source->ptr + skipsize, &used_size, &ogg_info);
+ if (err != OGGDEC_SUCCESS) {
+ debug_error("Failed to INFO decoder!");
+ return;
+ }
+}
+
void _pcm_out_func(void *data)
{
- ogg_info_t *p = (ogg_info_t*) data;
- int used_size;
- int decoded_len;
- unsigned char* ogg_buf;
- unsigned int ogg_remain;
- int err;
+ ogg_info_t *p = (ogg_info_t *)data;
+ int used_size = 0;
+ int decoded_len = 0;
+ unsigned char* ogg_buf = NULL;
+ int err = 0;
- debug_enter("\n");
+ debug_enter();
+
+ if (!p) {
+ debug_error("Invalid ogg_info_t...");
+ return;
+ }
sem_wait(&p->start_wave_signal);
- ogg_buf = MMSourceGetPtr(p->source);
- ogg_remain = MMSourceGetCurSize(p->source);
- while (p->state == STATE_PLAY) {
- err = OGGDEC_FrameDecode(p->decoder, ogg_buf+p->offset, &used_size, p->pcm_out_buf, &decoded_len);
- if (decoded_len > 0) {
+ while (((p->repeat_count == -1) ? (1) : (p->repeat_count--)) && p->state == STATE_PLAY) {
+ ogg_buf = MMSourceGetPtr(p->source) + p->offset;
+
+ while (p->state == STATE_PLAY) {
+ decoded_len = 0;
+ err = OGGDEC_FrameDecode(p->decoder, ogg_buf, &used_size, p->pcm_out_buf, &decoded_len);
+ if (decoded_len <= 0) {
+ debug_error("decoded len = %d", decoded_len);
+ break;
+ }
+
mm_sound_pa_write(p->handle, p->pcm_out_buf, decoded_len);
ogg_buf += used_size;
- ogg_remain -= used_size;
- if(err != OGGDEC_SUCCESS) {
- MMSoundPlugCodecOggStop((MMHandleType)p);
- debug_error("Decode done :: %d\n", err);
+
+ if (err != OGGDEC_SUCCESS)
break;
- }
- } else {
- MMSoundPlugCodecOggStop((MMHandleType)p);
- break;
}
+
+ debug_error("decode done = [%d], repeat_count = [%d]", err, p->repeat_count);
+ if (err == OGGDEC_FAIL || p->repeat_count == 0)
+ MMSoundPlugCodecOggStop((MMHandleType)p);
+ else
+ _reset_ogg_decoder(p);
}
mm_sound_pa_drain(p->handle);
/* Notice */
/* OggDestory is called by stop_cb func */
/* INDEED the stop_cb must be called, after end of all progress */
- if(p->stop_cb) {
+ if (p->stop_cb)
p->stop_cb(p->cb_param);
- }
- debug_leave("\n");
+
+ debug_leave();
}
int MMSoundPlugCodecOggSetThreadPool(int (*func)(void*, void (*)(void*)))
#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) {