static int ogg_play_file(char *filename, mp_callback_func cb) { OSAL_T_CTSK ogg_engine_play_task_attribute; unsigned long ogg_engine_flag; PE_DBG_PRINTF("MusicEngine: ==> ogg_play_file()! \n"); //check parameters if ((!filename) || (!cb) || (!ogg_file)) { PE_DBG_PRINTF("MusicEngine: ogg_play_file() invalid parameter filename or cb or ogg_file! \n"); return -1; } //init ogg_file #ifdef ENABLE_PE_CACHE ogg_cache_id = pe_cache_open(filename, NULL, OGG_CACHE_SIZE, OGG_BLOCK_SIZE); if(ogg_cache_id < 0) { PE_DBG_PRINTF("MusicEngine: ogg_play_file() pe_cache_open failed! \n"); return -1; } ogg_file->file = (FILE *)((UINT32)ogg_cache_id | PE_CACHE_ID_TAG); //只有在作了这个操作之后,以后的文件系统函数才是pe_cache接口 #else ogg_file->file = fopen(filename, "rb"); if (!ogg_file->file) { PE_DBG_PRINTF("MusicEngine: ogg_play_file() fopen failed! \n"); return -1; } #endif ogg_file->seek_to = 0; ogg_file->command = 0; ogg_file->stop_imm = TRUE; ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID; ogg_engine.ogg_engine_task_id = OSAL_INVALID_ID; deca_io_control((struct deca_device *)dev_get_by_id(HLD_DEV_TYPE_DECA, 0), DECA_SET_STR_TYPE, AUDIO_OGG ); prev_sp_l = 0; prev_sp_r = 0; g_pcm_sample_num = 0; g_pcm_current_using = 0; g_temp_pcm_buff = (char *)(ogg_file->processed_pcm_buff+ON_PCM_BUFF_LEN*8); //code to create flag ogg_engine_flag = OGG_ENGINE_FLAG_INITIALIZE; ogg_engine.ogg_engine_flag_id = osal_flag_create(ogg_engine_flag); if ( ogg_engine.ogg_engine_flag_id == OSAL_INVALID_ID) { PE_DBG_PRINTF("MusicEngine: ogg_play_file() osal_flag_create failure! \n"); #ifdef ENABLE_PE_CACHE pe_cache_close(ogg_cache_id); ogg_cache_id = -1; #else fclose(ogg_file->file); #endif return -1; } //start thread ogg_engine_play_task_attribute.stksz = OGG_ENGINE_PLAY_TASK_STACKSIZE*8; ogg_engine_play_task_attribute.quantum = OGG_ENGINE_PLAY_TASK_QUANTUM; ogg_engine_play_task_attribute.itskpri = OSAL_PRI_HIGH;//OSAL_PRI_NORMAL ; ogg_engine_play_task_attribute.para1 = (unsigned long)cb; //ogg_engine_play_task_attribute.para2 =; ogg_engine_play_task_attribute.name[0] = 'O'; ogg_engine_play_task_attribute.name[1] = 'G'; ogg_engine_play_task_attribute.name[2] = 'G'; ogg_engine_play_task_attribute.task = (FP)ogg_play_task; ogg_engine.ogg_engine_task_id = osal_task_create(&ogg_engine_play_task_attribute); if(ogg_engine.ogg_engine_task_id == OSAL_INVALID_ID) { PE_DBG_PRINTF("MusicEngine: ogg_play_file() osal_task_create failed! \n"); osal_flag_delete(ogg_engine.ogg_engine_flag_id); ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID; #ifdef ENABLE_PE_CACHE pe_cache_close(ogg_cache_id); ogg_cache_id = -1; #else fclose(ogg_file->file); #endif return -1; } //code to sync osal_flag_wait(&ogg_engine_flag, ogg_engine.ogg_engine_flag_id, OGG_ENGINE_FLAG_MASK, OSAL_TWF_ORW | OSAL_TWF_CLR, OSAL_WAIT_FOREVER_TIME); if (ogg_engine_flag != OGG_ENGINE_FLAG_SUCCESS) { osal_flag_delete(ogg_engine.ogg_engine_flag_id); ogg_engine.ogg_engine_flag_id = OSAL_INVALID_ID; //fclose(ogg_file->file); return -1; } PE_DBG_PRINTF("MusicEngine: <== ogg_play_file()! \n"); return 0; }
int ipanel_porting_dvb_select_av(int pcr_pid, int emm_pid, int vpid, int apid, int audio_ecm_pid, int video_ecm_pid,int servicetype) { RET_CODE ret_code = 0; Service_Info tmp_service; dprintf("[ipanel_porting_dvb_select_av] V/A/Pcr = %d/%d/%d video_status = %d \n",vpid,apid,pcr_pid, video_status); //return 0; if((apid==0)&&(vpid==0)&&(pcr_pid==0)) { return -1; } if((audioPid==apid) && (videoPid==vpid) && (pcrPid==pcr_pid)) { return 0; } else if((audioPid||videoPid||pcrPid)&&(video_status==1)) { ipanel_porting_av_stop(); } /*here the program PID, audio PID video PID were fixed , so this demo code was banded with a specified ts. just modify these related marco when you use this demo code. */ io_parameter.io_buff_in = (UINT8 *)PID_list; PID_list[0] = vpid;//pCmd->pids.video_id; PID_list[1] = apid;//pCmd->pids.audio_id; PID_list[2] = pcr_pid;//pCmd->pids.pcr_id; pcrPid = pcr_pid; //if(ipanel_get_run_mode()==1) //if mode is flash mode,search by vid or aid { int ret=0; tmp_service.video_pid = vpid; tmp_service.audio_pid = apid; tmp_service.pcr_pid=pcr_pid; tmp_service.service_type=servicetype; if(ipanel_get_run_mode()!=1) { *((volatile UINT8 *)0xb800002C) &= ~0x10; //set pin-mux to S-Flash osal_task_sleep(2000); } ret = ipanel_get_service_ByPID(&tmp_service); if(ipanel_get_run_mode()!=1) { *((volatile UINT8 *)0xb800002C) |= 0x10; //set pin-mux to Ethernet osal_task_sleep(2000); //for not crash quickly } if(ret == SUCCESS) { PID_list[2] = pcrPid = tmp_service.pcr_pid; if(tmp_service.frequency != cur_freq ) { my_ts_id = tmp_service.ts_id; ipanel_porting_delivery_tune(tmp_service.frequency*100,tmp_service.symbol_rate*10,(tmp_service.modulation-3)); osal_task_sleep(300); ipanel_porting_dprintf("[ipanel_porting_dvb_select_av] ts_id : 0x%x ,tune %d.\n",tmp_service.ts_id,tmp_service.frequency); } } else { ipanel_porting_dprintf("[ipanel_porting_dvb_select_av] can't get the service.but still play av by pid\n"); //return -1; } } UINT32 create_stream = 0; UINT32 enable_stream = 0; if(vpid && apid) { create_stream = IO_CREATE_AV_STREAM; enable_stream = IO_STREAM_ENABLE; } else if((vpid==0) && apid) { create_stream = IO_CREATE_AUDIO_STREAM; enable_stream = AUDIO_STREAM_ENABLE; } else if((apid==0) && vpid) { create_stream = IO_CREATE_VIDEO_STREAM; enable_stream = VIDEO_STREAM_ENABLE; } if(create_stream!=0) ret_code = dmx_io_control(g_dmx_dev,create_stream,(UINT32)&io_parameter); if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] dmx create stream fail\n"); return -1; } if(vpid) { ret_code = vdec_start(g_decv_dev); if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] cc2: VDec_Decode() fail\n"); return -1; } else { dprintf("[ipanel_porting_av_start] cc2: vdec_start() OK\n"); } videoPid = vpid; } if(apid) { deca_io_control(g_deca_dev, DECA_SET_STR_TYPE, AUDIO_MPEG2); ret_code = deca_start(g_deca_dev,0); /* open the audio device */ if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] cc2: deca_start() fail \n"); return -1; } else { dprintf("[ipanel_porting_av_start] cc2: deca_start() OK \n"); } audioPid = apid; } if(enable_stream!=0) ret_code = dmx_io_control(g_dmx_dev,enable_stream,(UINT32)&io_parameter); if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] cc2: dmx enable stream fail\n"); return -1; } else { dprintf("[ipanel_porting_av_start] cc2: dmx enable stream OK\n"); } video_status = 1; if(progpos!=0xffff){ api_mcas_start_service(0); api_mcas_start_transponder(); si_monitor_on(progpos); } dprintf("[ipanel_porting_av_start] cc2: V/A/Pcr = %d/%d/%d\n",PID_list[0],PID_list[1],PID_list[2]); return 0; }