int dtsenc_init() { return 0; int ret; memset(&dtsenc_info,0,sizeof(dtsenc_info_t)); dtsenc_info.dts_flag = get_dts_format(); if(!dtsenc_info.dts_flag) return -1; dtsenc_info.raw_mode=get_dts_mode(); //dtsenc_info.raw_mode=1;//default open if(!dtsenc_info.raw_mode) return -1; if(!get_cpu_type()) //if cpu !=m6 ,skip return -1; //adec_print("====dts_flag:%d raw_mode:%d \n",dtsenc_info.dts_flag,dtsenc_info.raw_mode); ret=dts_transenc_init(); if(ret!=1) { adec_print("====dts_trancenc init failed \n"); return -1; } dtsenc_info.state=INITTED; pthread_t tid; ret = pthread_create(&tid, NULL, (void *)dts_enc_loop, NULL); if (ret != 0) { dtsenc_release(); return -1; } pthread_setname_np(tid,"AmadecDtsEncLP"); dtsenc_info.thread_pid = tid; adec_print("====dts_enc init success \n"); return 0; }
static void *adec_message_loop(void *args) { int ret; aml_audio_dec_t *audec; audio_out_operations_t *aout_ops; adec_cmd_t *msg = NULL; audec = (aml_audio_dec_t *)args; aout_ops = &audec->aout_ops; while (!audec->need_stop) { audec->state = INITING; ret = feeder_init(audec); if (ret == 0) { ret = aout_ops->init(audec); if (ret) { adec_print("Audio out device init failed!"); feeder_release(audec); continue; } audec->state = INITTED; adec_print("Audio out device init ok!"); start_adec(audec); if(dtsenc_init()!=-1) dtsenc_start(); break; } if(!audec->need_stop){ usleep(100000); } } do { //if(message_pool_empty(audec)) //{ //adec_print("there is no message !\n"); // usleep(100000); // continue; //} adec_reset_track(audec); adec_flag_check(audec); msg = adec_get_message(audec); if (!msg) { usleep(100000); continue; } switch (msg->ctrl_cmd) { case CMD_START: adec_print("Receive START Command!\n"); start_adec(audec); dtsenc_start(); break; case CMD_PAUSE: adec_print("Receive PAUSE Command!"); pause_adec(audec); dtsenc_pause(); break; case CMD_RESUME: adec_print("Receive RESUME Command!"); resume_adec(audec); dtsenc_resume(); break; case CMD_STOP: adec_print("Receive STOP Command!"); adec_print("audec->state=%d (INITING/3) when Rec_STOP_CMD\n",audec->state); stop_adec(audec); dtsenc_stop(); break; case CMD_MUTE: adec_print("Receive Mute Command!"); if (msg->has_arg) { mute_adec(audec, msg->value.en); } break; case CMD_SET_VOL: adec_print("Receive Set Vol Command!"); if (msg->has_arg) { adec_set_volume(audec, msg->value.volume); } break; case CMD_SET_LRVOL: adec_print("Receive Set LRVol Command!"); if (msg->has_arg) { adec_set_lrvolume(audec, msg->value.volume,msg->value_ext.volume); } break; case CMD_CHANL_SWAP: adec_print("Receive Channels Swap Command!"); audio_hardware_ctrl(HW_CHANNELS_SWAP); break; case CMD_LEFT_MONO: adec_print("Receive Left Mono Command!"); audio_hardware_ctrl(HW_LEFT_CHANNEL_MONO); break; case CMD_RIGHT_MONO: adec_print("Receive Right Mono Command!"); audio_hardware_ctrl(HW_RIGHT_CHANNEL_MONO); break; case CMD_STEREO: adec_print("Receive Stereo Command!"); audio_hardware_ctrl(HW_STEREO_MODE); break; case CMD_RELEASE: adec_print("Receive RELEASE Command!"); release_adec(audec); dtsenc_release(); break; default: adec_print("Unknow Command!"); break; } if (msg) { adec_message_free(msg); msg = NULL; } } while (audec->state != TERMINATED); adec_print("Exit Message Loop Thread!"); pthread_exit(NULL); return NULL; }