📄 process_key.c
字号:
if (keyflags & SET_KEY_AUDIO) { if (handle_audio_keys(dcc_info, &actions, key)) { RMDBGLOG((DISABLE, "goto after audioKeys!\n")); goto out_key; } } if (keyflags & SET_KEY_DISPLAY) { err = handle_display_keys(dcc_info, &actions, key); if (err == RM_OK) { RMDBGLOG((DISABLE, "goto after playbackKeys!\n")); goto out_key; } else if (err != RM_NOTIMPLEMENTED) { RMDBGLOG((DISABLE, "handle_playback_keys returned error!\n")); return err; } } if (keyflags & SET_KEY_SPI) { if (handle_spi_keys(dcc_info, &actions, key)) { RMDBGLOG((DISABLE, "goto after spiKeys!\n")); goto out_key; } } if (key == KEY_CMD_QUIT) { actions.cmd = RM_QUIT; goto out_key; } out_key: *cmd = actions.cmd; return (actions.cmdProcessed || (actions.cmd != RM_UNKNOWN)) ? RM_OK : RM_PENDING;}enum RM_PSM_State RM_PSM_GetState(struct RM_PSM_Context *PSMcontext, struct dcc_context *dcc_info_array[]) { struct dcc_context *dcc_info; if ((PSMcontext->currentActivePSMContext <= PSMcontext->validPSMContexts) && (PSMcontext->currentActivePSMContext != 0)) { RMDBGLOG((DISABLE, "GetState for context %lu\n", PSMcontext->currentActivePSMContext)); dcc_info = dcc_info_array[PSMcontext->currentActivePSMContext - 1]; switch (dcc_info->FSMstate) { case RM_PSM_IPaused: return RM_PSM_Paused; case RM_PSM_INextPic: return RM_PSM_NextPic; default: return dcc_info->FSMstate; } } RMDBGLOG((DISABLE, "GetState for defaut context\n")); dcc_info = dcc_info_array[0]; switch (dcc_info->FSMstate) { case RM_PSM_IPaused: return RM_PSM_Paused; case RM_PSM_INextPic: return RM_PSM_NextPic; default: return dcc_info->FSMstate; } }void RM_PSM_SetState(struct RM_PSM_Context *PSMcontext, struct dcc_context *dcc_info_array[], enum RM_PSM_State newstate){ RMascii buffer[256]; enum RM_PSM_State oldstate; struct dcc_context *dcc_info; if ((PSMcontext->currentActivePSMContext <= PSMcontext->validPSMContexts) && (PSMcontext->currentActivePSMContext != 0)) { RMDBGLOG((DISABLE, "SetState for context %lu\n", PSMcontext->currentActivePSMContext)); dcc_info = dcc_info_array[PSMcontext->currentActivePSMContext - 1]; } else { RMDBGLOG((DISABLE, "SetState for defaut context\n")); dcc_info = dcc_info_array[0]; } oldstate = dcc_info->FSMstate; dcc_info->FSMstate = newstate; switch (dcc_info->FSMstate) { case RM_PSM_Playing: sprintf(buffer, "playing"); break; case RM_PSM_Stopped: sprintf(buffer, "stopped"); break; case RM_PSM_Paused: sprintf(buffer, "paused"); break; case RM_PSM_NextPic: sprintf(buffer, "nextpic"); break; case RM_PSM_Slow: sprintf(buffer, "slow"); break; case RM_PSM_Fast: sprintf(buffer, "fast"); break; case RM_PSM_IForward: sprintf(buffer, "ifwd"); break; case RM_PSM_IRewind: sprintf(buffer, "irwd"); break; case RM_PSM_Prebuffering: sprintf(buffer, "prebuf"); break; case RM_PSM_IPaused: sprintf(buffer, "ipaused"); break; case RM_PSM_INextPic: sprintf(buffer, "inextpic"); break; case RM_PSM_Rewind: sprintf(buffer, "rewind"); break; } if (dcc_info->FSMstate == oldstate) sprintf(buffer+strlen(buffer), " (unchanged)"); RMDBGLOG((ENABLE, "set_PlaybackState to: %s\n", buffer)); }/* NOTES: Sending audio while in trickmodes. Instead of stopping the audio decoder, we mute the output and reconfigure the audio decoder to read the value of the displayPTS as it's "stc". Currently only works for WMV9 files because the timeScale for audio and video is the same This works for FFwd and SFwd, it doesnt work for IFrame modes because IFrame mode involves seeking muteAudio, unMuteAudio and routeAudioTimer are the functions implementing this functionality*/void muteAudio(struct dcc_context *dcc_info){ RMstatus err; RMDBGLOG((ENABLE, ">>> mute audio\n")); if (dcc_info->pAudioSource) { err = DCCSetAudioSourceVolume(dcc_info->pAudioSource, 0); if (err != RM_OK) fprintf(stderr, "error setting volume\n"); } else if (dcc_info->pMultipleAudioSource) { err = DCCSetMultipleAudioSourceVolume(dcc_info->pMultipleAudioSource, 0); if (err != RM_OK) fprintf(stderr, "error setting multiple source volume\n"); } return;}void unMuteAudio(struct dcc_context *dcc_info){ RMstatus err; RMuint32 volume; RMDBGLOG((ENABLE, ">>> unmute audio\n")); volume = VolumeTable[VOLUME_INDEX_0DB+dcc_info->volume_index]; if (dcc_info->pAudioSource) { err = DCCSetAudioSourceVolume(dcc_info->pAudioSource, volume); if (err != RM_OK) fprintf(stderr, "error setting volume\n"); } else if (dcc_info->pMultipleAudioSource) { err = DCCSetMultipleAudioSourceVolume(dcc_info->pMultipleAudioSource, volume); if (err != RM_OK) fprintf(stderr, "error setting multiple source volume\n"); } return;}void routeAudioTimerToDisplayPTS(struct dcc_context *dcc_info, RMbool enable){ if (dcc_info->pVideoSource) { struct AudioDecoder_SynchroniseAudioWithDisplayPTS_type syncProp; RMuint32 audioTIR; RMstatus err; if (enable) { RMDBGLOG((ENABLE, "********************* rerouting audio timer to display\n")); DCCSTCGetTimeResolution(dcc_info->pStcSource, DCC_Audio, &audioTIR); //RUAGetProperty(dcc_info->pRUA, dcc_info->pStcSource->StcModuleId, RMSTCPropertyID_AudioTimeResolution, &audioTIR, sizeof(RMuint32)); } else { RMDBGLOG((ENABLE, "********************* rerouting audio timer to STC\n")); audioTIR = 0; } syncProp.ModuleID = dcc_info->SurfaceID; syncProp.Enable = enable; if (dcc_info->pAudioSource) { err = RUASetProperty(dcc_info->pRUA, dcc_info->audio_decoder, RMAudioDecoderPropertyID_SynchroniseAudioWithDisplayPTS, &syncProp, sizeof(syncProp), 0); } else if (dcc_info->pMultipleAudioSource) { RMuint32 i; RMuint32 instances; struct DCCAudioSourceHandle audioHandle; DCCMultipleAudioSourceGetNumberOfInstances(dcc_info->pMultipleAudioSource, &instances); for (i = 0; i < instances; i++) { RMDBGLOG((ENABLE, "routing instance %lu\n", i)); err = DCCMultipleAudioSourceGetSingleDecoderHandleForInstance(dcc_info->pMultipleAudioSource, i, &audioHandle); if (err != RM_OK) break; err = RUASetProperty(dcc_info->pRUA, audioHandle.moduleID, RMAudioDecoderPropertyID_SynchroniseAudioWithDisplayPTS, &syncProp, sizeof(syncProp), 0); } } } return;}/* process_command, Finite State Machine */RMstatus process_command(struct RM_PSM_Context *PSMcontext, struct dcc_context *dcc_info_array[], struct RM_PSM_Actions *actions){ RMascii key; RMstatus err; RMbool keyProcessed; //RMbool processAllDecoders = FALSE; RMuint32 keyflags = PSMcontext->keyflags; RMbool getKey = FALSE; RMbool gotKey = FALSE; RMint32 i = 0, stopped = 0; struct dcc_context *dcc_info;#ifdef _DEBUG enum RM_PSM_State oldstate;#endif for ( i = 0; i < PSMcontext->validPSMContexts; i++) { if(dcc_info_array[i]->scc) refresh_soft_cc(dcc_info_array[i]); } /* verify decoder status */ for ( i = 0; i < PSMcontext->validPSMContexts; i++) { if ((dcc_info_array[i]->FSMstate == RM_PSM_Stopped) || (dcc_info_array[i]->FSMstate == RM_PSM_Paused) || (dcc_info_array[i]->FSMstate == RM_PSM_IPaused)) { RMDBGLOG((DISABLE, "decoder %ld is %s\n", i+1, dcc_info_array[i]->FSMstate == RM_PSM_Stopped ? "stopped":"paused")); stopped++; } } if (stopped == PSMcontext->validPSMContexts) { RMDBGLOG((ENABLE, "all decoders are stopped or paused, awaiting command\n")); getKey = TRUE; } get_key: key = 0; /* init FSM outputs */ /* because async commands are application specific and due to their asynchronous nature, they must survive succesive calls to process_command, that's why they are not initialized here */ actions->performedActions = 0; actions->toDoActions = 0; actions->cmd = RM_NONE; actions->cmdProcessed = FALSE; if (mono_auto_mode) { if (key_cmd_count == sizeof mono_auto_playback_sequence / (sizeof (mono_auto_playback_sequence[0][0]) *2)) gotKey = FALSE; else if (globalTimeout) { key = mono_auto_playback_sequence[key_cmd_count][0]; setEventTimeout(mono_auto_playback_sequence[key_cmd_count++][1]); gotKey = TRUE; printf("------ send AUTO PLAYBACK key = 0x%x ----------------\n", key); } } else { if ((getKey) || (RMKeyAvailable())){ key = RMGetKey(); gotKey = TRUE; RMDBGLOG((ENABLE, "--------- key = 0x%x gotKey=0x%x----------------\n", key, gotKey)); } } if (!gotKey) return RM_OK;#ifdef _DEBUG else { if ((key == KEY_CMD_NONE1) || (key == KEY_CMD_NONE2)) RMDBGLOG((DISABLE, "key none\n")); }#endif keyProcessed = TRUE; //we assume the key will be treated /* the selection key shall be treated outside the for() */ if (key == KEY_CMD_SELECT_DECODER){ RMint32 decoder; actions->cmdProcessed = TRUE; actions->cmd = RM_DECODER_CHANGE; fprintf(stderr, "select decoder [0: all]: "); RMTermGetUint32((RMuint32 *)&decoder); if (decoder > PSMcontext->validPSMContexts) { fprintf(stderr, "invalid decoder(%lu), valid decoders 1...%lu or 0 for all decoders\n", decoder, PSMcontext->validPSMContexts); actions->cmdProcessed = FALSE; return RM_OK; } if (decoder != 0) fprintf(stderr, "selecting decoder %lu\n", decoder); else fprintf(stderr, "selecting all decoders\n"); PSMcontext->currentActivePSMContext = decoder; return RM_OK; } if (PSMcontext->currentActivePSMContext == 0) { RMDBGLOG((DISABLE, "all decoders selected\n")); PSMcontext->selectedPSMContextMask = 0xF; } else if (PSMcontext->currentActivePSMContext <= PSMcontext->validPSMContexts) { PSMcontext->selectedPSMContextMask = (1<< (PSMcontext->currentActivePSMContext - 1)); RMDBGLOG((ENABLE, "selecting single decoder, mask 0x%08lx\n", PSMcontext->selectedPSMContextMask)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -