static void pcm_play_demo(void) { struct deca_feature_config deca_config; struct snd_feature_config snd_config; UINT32 i, j; struct pcm_output pcm; INT32 *p_pcm_sp; g_decv_dev = dev_get_by_id(HLD_DEV_TYPE_DECV, 0); g_deca_dev = dev_get_by_id(HLD_DEV_TYPE_DECA, 0); if (RET_SUCCESS != deca_open(g_deca_dev, 0, 0, 0, 0, 0)) { PRINTF("deca_open failed!!\n"); ASSERT(0); } if (RET_SUCCESS != snd_open(g_snd_dev)) { PRINTF("snd_open failed!!\n"); ASSERT(0); } MEMSET(&pcm, 0, sizeof(struct pcm_output)); pcm.ch_num = 2; pcm.ch_mod = DUAL_CHANNEL; pcm.ch_left = pcm_left_ch; pcm.ch_right = pcm_right_ch; pcm.samp_num = 1152; snd_set_spdif_type(g_snd_dev, SND_OUT_SPDIF_PCM); snd_set_volume(g_snd_dev, SND_SUB_OUT, 100); snd_set_duplicate(g_snd_dev, SND_DUP_NONE); /*assumes PCM data is in address __MM_AUDIO_PATTERN_ADDR, 400*4608 samples, Preset PCM sample rate is 48000, each sample occupy 1 double word (32 bits)*/ while (1) { p_pcm_sp = (INT32 *)__MM_AUDIO_PATTERN_ADDR; for (i = 0;i < PCM_FRM_NUM;i++) { for (j = 0;j < pcm.samp_num;j++) { /*for dual channel mode, 2 channels should have different samples, herel fills the same samples to 2 channels for demo. If only have 1 channel PCM, you can only fill 1 channel (left or right), but you should call snd_set_duplicate(g_snd_dev, SND_DUP_L); or snd_set_duplicate(g_snd_dev, SND_DUP_R); before play.*/ pcm_left_ch[j] = (*p_pcm_sp) << 5; pcm_right_ch[j] = (*p_pcm_sp) << 5; p_pcm_sp++; } libc_demo_pcm_output(&pcm); } } }
// ************************************************************** // Summary: // play file. // Description: // This function call play-engine to play media file. // Returns: // returns RET_SUCCESS if play file successfully // returns RET_FAILURE if not. // Parameters: // idx :[IN] dest file's idx in filelist, start with 1 // type :[IN] file type // fromPL :[IN] whether play playlist // mode_rotate :[IN] play mode and rotate mode, only used for pictrue play // See Also: // file_pause, file_resume, file_jump, file_stop RET_CODE file_play(UINT16 idx, file_type type, UINT8 fromPL, UINT8 mode_rotate) { mp_type mptype = _filetype2mptype(type); UDISK_ID id = _udisk_get_diskid(); char path[FILE_NAME_SIZE]; int ret_val; ENTER_FUNCTION; switch(mptype) { case MP_MUSIC: if(fromPL) { p_list_playlist playlist = NULL; playlist = _udisk_get_playlist(id, mptype); if(RET_SUCCESS != _playlist_getpath_byidx(playlist, idx, path)) { return RET_FAILURE; } playlist->info.playidx = idx; playlist->info.playednum++; MP_DEBUG("play file:%d\t %s\n", idx, path); ret_val = music_play(path); if(ret_val < 0) { MP_DEBUG("CH error, return\n"); return RET_FAILURE; } } else { if (temp_music_playlist_available) { if(RET_SUCCESS != _playlist_getpath_byidx(temp_music_playlist, idx, path)) { return RET_FAILURE; } temp_music_playlist->info.playidx = idx; temp_music_playlist->info.playednum++; MP_DEBUG("play file:%d\t %s\n", idx, path); ret_val = music_play(path); if(ret_val < 0) { MP_DEBUG("CH error, return\n"); return RET_FAILURE; } return RET_SUCCESS; } p_list_filelist filelist = NULL; filelist = _udisk_get_filelist(id, mptype); if(filelist == NULL) { return RET_FAILURE; } if(RET_SUCCESS != _filelist_getpath_byidx(filelist, idx, path)) { return RET_FAILURE; } MP_DEBUG("play file:%d\t %s\n", idx, path); snd_set_spdif_type((struct snd_device * )dev_get_by_id(HLD_DEV_TYPE_SND, 0), SND_OUT_SPDIF_PCM); ret_val = music_play(path); if(ret_val < 0) { MP_DEBUG("CH error, return\n"); return RET_FAILURE; } } break; case MP_PICTURE: if(fromPL&0x7f) { p_list_playlist playlist = NULL; int mode; unsigned char rotate; playlist = _udisk_get_playlist(id, mptype); if(RET_SUCCESS != _playlist_getpath_byidx(playlist, idx, path)) { return RET_FAILURE; } playlist->info.playidx = idx; playlist->info.playednum++; MP_DEBUG("play file:%d\t %s\n", idx, path); mode = mode_rotate & IMAGE_DIS_MODE_MASK; rotate = (mode_rotate & IMAGE_ANGLE_MASK)>>4; //ret_val = image_decode(path, mode, 0, 0, 720, 576, rotate); //the following is shown how to use the image_decode_ex function with slideshow effect { struct image_slideshow_effect effect; if(fromPL&0x80) effect.mode = M_NORMAL; else effect.mode = osal_get_tick() % 5 + 1; switch(effect.mode) { case M_SHUTTERS: effect.mode_param.shuttles_param.direction = osal_get_tick() % 2; effect.mode_param.shuttles_param.time = 100; break; case M_BRUSH: effect.mode_param.brush_param.direction = osal_get_tick() % 2; effect.mode_param.brush_param.time = 3; break; case M_SLIDE: effect.mode_param.slide_param.direction = osal_get_tick() % 2; effect.mode_param.slide_param.time = 10; break; case M_RANDOM: effect.mode_param.random_param.type = osal_get_tick() % 3; effect.mode_param.random_param.time = 1; break; case M_FADE: effect.mode_param.fade_param.type = 0; effect.mode_param.fade_param.time = 0; break; default: break; } ret_val = image_decode_ex(path, mode, 0, 0, 720, 576, rotate, &effect); } if(ret_val < 0) { MP_DEBUG("CH error, return\n"); return RET_FAILURE; } } else {