static void sh_utmp_setutent(void) { int error; int fd; SL_ENTER(_("sh_utmp_setutent")); ASSERT((sh_utmppath != NULL), _("sh_utmppath != NULL")); if (sh_utmppath == NULL) SL_RET0(_("sh_utmp_setutent")); if (sh_utmpfile == NULL) { SH_MUTEX_LOCK(mutex_thread_nolog); fd = (int) aud_open (FIL__, __LINE__, SL_NOPRIV, sh_utmppath, O_RDONLY, 0); SH_MUTEX_UNLOCK(mutex_thread_nolog); if (fd >= 0) { sh_utmpfile = fdopen(fd, "r"); } /* -- If (sh_utmpfile == NULL) then either the open() or the fdopen() * has failed. */ if (sh_utmpfile == NULL) { error = errno; SH_MUTEX_LOCK(mutex_thread_nolog); sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_ACCESS, (long) sh.real.uid, sh_utmppath); SH_MUTEX_UNLOCK(mutex_thread_nolog); SL_RET0(_("sh_utmp_setutent")); } } (void) fseek (sh_utmpfile, 0L, SEEK_SET); if (-1 == fseek (sh_utmpfile, sh_utmp_feed_forward, SEEK_CUR)) { sh_utmp_feed_forward = 0; /* modified Apr 4, 2004 */ (void) fseek (sh_utmpfile, 0L, SEEK_SET); } clearerr (sh_utmpfile); SL_RET0(_("sh_utmp_setutent")); }
//#NT#2009/12/10#Philex -begin void KeyScan_HDMIAudioSetting(AUDIO_SETTING AudioSetting, BOOL bEnable) { if (aud_getLockStatus() == TASK_LOCKED) { aud_setI2SClockCtrl(bEnable); aud_setOutput(AudioSetting.Output); aud_setSamplingRate(AudioSetting.SamplingRate); } else { AUDIO_DEVICE_OBJ AudObj; aud_getDeviceObject(&AudObj); aud_open(&AudObj); aud_setI2SClockCtrl(bEnable); aud_setOutput(AudioSetting.Output); aud_setSamplingRate(AudioSetting.SamplingRate); aud_close(); } }
//#NT#2009/12/10#Philex -begin void KeyScan_HDMIAudioSetting(AUDIO_SETTING AudioSetting,BOOL bEnable) { if (aud_getLockStatus() == TASK_LOCKED) { aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, bEnable); aud_setOutput(AudioSetting.Output); aud_setSamplingRate(AudioSetting.SamplingRate); } else { AUDIO_DEVICE_OBJ AudObj; aud_getDeviceObject(&AudObj); aud_open(&AudObj); aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, bEnable); aud_setOutput(AudioSetting.Output); aud_setSamplingRate(AudioSetting.SamplingRate); aud_close(); } }
INT32 OnExe_MovieAudio(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { AUDIO_DEVICE_OBJ AudioDevObj; AUDIO_GAIN Gain; UINT32 uhSelect = 0; if(paramNum != 0) uhSelect= paramArray[0]; debug_ind(("OnExe_MovieAudio\n\r")); SysSetFlag(FL_MOVIE_AUDIO, uhSelect); switch(uhSelect) { case MOVIE_AUDIOENABLE_OFF: Gain = AUDIO_GAIN_MUTE; break; case MOVIE_AUDIOENABLE_ON: default: Gain = AUDIO_GAIN_7; break; } if (aud_getLockStatus() == TASK_LOCKED) { aud_setGain(Gain); } else { aud_getDeviceObject(&AudioDevObj); aud_open(&AudioDevObj); aud_setGain(Gain); aud_close(); } return NVTEVT_CONSUME; }
ER DrvSound_SetOutDevConfig(UINT32 outDevIdx) { ER retV = E_OK; UINT32 openAud = FALSE; DbgMsg_DrvSoundIO(("+%s:idx=%d\r\n",__func__,outDevIdx)); if (outDevIdx >= DRVSOUND_OUTDEV_CONFIG_CNT) { DBG_ERR("%s:idx=%d\r\n",__func__,outDevIdx); return retV; } gpCurDrvAudOutDev = &gDxSndAudOutDevConfigTbl[outDevIdx]; DrvSound_DmpOutDevConfig(); if (aud_getLockStatus() == NO_TASK_LOCKED) { aud_getDeviceObject(&gDrvSoundAudDev); retV = aud_open(&gDrvSoundAudDev); if (retV != E_OK) { DBG_ERR("%s: Aud open fail\r\n",__func__); return retV; } openAud = TRUE; } //[Config audio Codec & Output] //Speaker is connected to IC Speaker Output //TV Audio is connected to IC HP_R Output if(gpCurDrvAudOutDev->vidOutType == DRVSOUND_VOUT_LCD) { DBG_IND("video: device=LCD\r\n"); DBG_IND("audio: codec=DEFAULT device=SPK\r\n"); aud_switchCodec(AUDIO_CODECSEL_DEFAULT); aud_setOutput(AUDIO_OUTPUT_SPK); //or AUDIO_OUTPUT_MONO aud_setFeature(AUDIO_FEATURE_LINE_PWR_ALWAYSON, FALSE); aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, FALSE); aud_setFeature(AUDIO_FEATURE_DISCONNECT_HDMI, TRUE); aud_setFeature(AUDIO_FEATURE_PLAY2ALLCODEC, FALSE); } else if(gpCurDrvAudOutDev->vidOutType == DRVSOUND_VOUT_TV) { DBG_IND("video: device=TV\r\n"); DBG_IND("audio: codec=DEFAULT device=LINE\r\n"); aud_switchCodec(AUDIO_CODECSEL_DEFAULT); aud_setOutput(AUDIO_OUTPUT_LINE); //or AUDIO_OUTPUT_HP aud_setFeature(AUDIO_FEATURE_LINE_PWR_ALWAYSON, TRUE); aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, FALSE); aud_setFeature(AUDIO_FEATURE_DISCONNECT_HDMI, TRUE); aud_setFeature(AUDIO_FEATURE_PLAY2ALLCODEC, FALSE); } else if(gpCurDrvAudOutDev->vidOutType == DRVSOUND_VOUT_HDMI) { DBG_IND("video: device=HDMI\r\n"); DBG_IND("audio => codec=HDMI device=NONE\r\n"); aud_switchCodec(AUDIO_CODECSEL_HDMI); aud_setOutput(AUDIO_OUTPUT_NONE); aud_setFeature(AUDIO_FEATURE_LINE_PWR_ALWAYSON, FALSE); aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, TRUE); aud_setFeature(AUDIO_FEATURE_DISCONNECT_HDMI, FALSE); aud_setFeature(AUDIO_FEATURE_PLAY2ALLCODEC, FALSE); // 後續 aud_setSamplingRate() 設定的 sampling rate 須等同 HDMI display object 端設定的 sampling rate // 不然需要用 aud_setResampleInfo() 啟動 audio resample } else if(gpCurDrvAudOutDev->vidOutType == DRVSOUND_VOUT_LCDTV) { DBG_IND("video: device=LCD & TV\r\n"); DBG_IND("audio: codec=DEFAULT device=SPK\r\n"); aud_switchCodec(AUDIO_CODECSEL_DEFAULT); aud_setOutput(AUDIO_OUTPUT_LINE); aud_setFeature(AUDIO_FEATURE_LINE_PWR_ALWAYSON, TRUE); aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, FALSE); aud_setFeature(AUDIO_FEATURE_DISCONNECT_HDMI, TRUE); aud_setFeature(AUDIO_FEATURE_PLAY2ALLCODEC, FALSE); } else if(gpCurDrvAudOutDev->vidOutType == DRVSOUND_VOUT_LCDHDMI) { DBG_IND("video: device=LCD & HDMI\r\n"); DBG_IND("audio: codec=DEFAULT device=SPK\r\n"); aud_switchCodec(AUDIO_CODECSEL_DEFAULT); aud_setOutput(AUDIO_OUTPUT_SPK); aud_setFeature(AUDIO_FEATURE_LINE_PWR_ALWAYSON, FALSE); aud_setFeature(AUDIO_FEATURE_INTERFACE_ALWAYS_ACTIVE, TRUE); aud_setFeature(AUDIO_FEATURE_DISCONNECT_HDMI, FALSE); aud_setFeature(AUDIO_FEATURE_PLAY2ALLCODEC, TRUE); // 後續 aud_setSamplingRate() 設定的 sampling rate 須等同 HDMI display object 端設定的 sampling rate // 不然需要用 aud_setResampleInfo() 啟動 audio resample } //[Config audio Channel] //TODO ==> GxSound: // project can assign witch channel is for MONO sound play // project can assign if expend MONO sound play as STEREO if (AUDIO_CH_STEREO == gpCurDrvAudOutDev->audChannel) { aud_setChannel(AUDIO_CH_STEREO); aud_setFeature(AUDIO_FEATURE_PLAYBACK_PCM_EXPAND, FALSE); } else { aud_setChannel(gpCurDrvAudOutDev->audChannel); aud_setFeature(AUDIO_FEATURE_PLAYBACK_PCM_EXPAND, gpCurDrvAudOutDev->monoExpand); } if (openAud == TRUE) { aud_close(); } DbgMsg_DrvSoundIO(("-%s:idx=%d,audOpen=%d\r\n",__func__,outDevIdx,openAud)); return retV; }
void PlaySoundTsk(void) { FLGPTN uiFlag; AUDIO_DEVICE_OBJ AudioDevice; AUDIO_BUF_QUEUE AudioBufQueue; //#NT#2010/01/20#JustinLee -begin //#Add wav header parsing before playing sound data WAV_FILEINFO WAVFileInfo; //#NT#2010/01/20#JustinLee -end while (1) { wai_flg(&uiFlag, FLG_ID_SOUND, FLGSOUND_STOP | FLGSOUND_PLAY, TWF_ORW | TWF_CLR); if (uiFlag & FLGSOUND_STOP) { if (g_uiPlaySoundStatus == PLAYSOUND_STS_PLAYING) { aud_stop(); aud_close(); g_uiPlaySoundStatus = PLAYSOUND_STS_STOPPED; set_flg(FLG_ID_SOUND, FLGSOUND_STOPPED); } } if (uiFlag & FLGSOUND_PLAY) { //#NT#2009/06/24#Chris Chung -begin //#NT#avoid re-entry to audio driver. if(aud_isBusy()) continue; //#NT#2009/06/24#Chris Chung -end g_uiPlaySoundStatus = PLAYSOUND_STS_PLAYING; clr_flg(FLG_ID_SOUND, FLGSOUND_STOPPED); // Open audio driver aud_getDeviceObject(&AudioDevice); AudioDevice.pEventHandler = PlaySound_AudioHdl; aud_open(&AudioDevice); switch (g_uiPlaySoundSound) { case PLAYSOUND_SOUND_STARTUP: case PLAYSOUND_SOUND_SHUTDOWN: // Parse header before playing if(PlaySound_ParseWAVHeader((UINT32)g_PowerOn_SoundKey.puiData, &WAVFileInfo) == TRUE) { // Set sampling rate and channel based on parameter aud_setSamplingRate(WAVFileInfo.AudioSamplingRate); aud_setChannel(WAVFileInfo.AudioChannel); // Set audio buffer queue addr and size AudioBufQueue.uiAddress = ((UINT32)g_PowerOn_SoundKey.puiData) + (sizeof(WAV_PCMHEADER)); AudioBufQueue.uiSize = WAVFileInfo.uiDataSize; } else { // Set sampling rate and channel manually aud_setSamplingRate(AUDIO_SR_32000); aud_setChannel(AUDIO_CH_LEFT); // Set audio buffer queue addr and size AudioBufQueue.uiAddress = (UINT32)g_PowerOn_SoundKey.puiData; AudioBufQueue.uiSize = g_PowerOn_SoundKey.uiSize; } break; case PLAYSOUND_SOUND_KEY_SHUTTER2: // Parse header before playing if(PlaySound_ParseWAVHeader((UINT32)g_Shutter_SoundKey.puiData, &WAVFileInfo) == TRUE) { // Set sampling rate and channel based on parameter aud_setSamplingRate(WAVFileInfo.AudioSamplingRate); aud_setChannel(WAVFileInfo.AudioChannel); // Set audio buffer queue addr and size AudioBufQueue.uiAddress = ((UINT32)g_Shutter_SoundKey.puiData) + (sizeof(WAV_PCMHEADER)); AudioBufQueue.uiSize = WAVFileInfo.uiDataSize; } else { // Set sampling rate and channel manually aud_setSamplingRate(AUDIO_SR_32000); aud_setChannel(AUDIO_CH_LEFT); // Set audio buffer queue addr and size AudioBufQueue.uiAddress = (UINT32)g_Shutter_SoundKey.puiData; AudioBufQueue.uiSize = g_Shutter_SoundKey.uiSize; } break; case PLAYSOUND_SOUND_KEY_OTHERS: // Parse header before playing if(PlaySound_ParseWAVHeader((UINT32)g_SoundKey.puiData, &WAVFileInfo) == TRUE) { // Set sampling rate and channel based on parameter aud_setSamplingRate(WAVFileInfo.AudioSamplingRate); aud_setChannel(WAVFileInfo.AudioChannel); // Set audio buffer queue addr and size AudioBufQueue.uiAddress = ((UINT32)g_SoundKey.puiData) + (sizeof(WAV_PCMHEADER)); AudioBufQueue.uiSize = WAVFileInfo.uiDataSize; } else { // Set sampling rate and channel manually aud_setSamplingRate(AUDIO_SR_32000); aud_setChannel(AUDIO_CH_LEFT); // Set audio buffer queue addr and size AudioBufQueue.uiAddress = (UINT32)g_SoundKey.puiData; AudioBufQueue.uiSize = g_SoundKey.uiSize; } break; default: aud_close(); continue; } // Set time code offset and first time code trigger value aud_setTimecodeOffset(0); aud_setTimecodeTrigger(AudioBufQueue.uiSize >> 1); // Reset audio buffer queue and add buffer to queue aud_resetBufferQueue(); aud_addBufferToQueue(&AudioBufQueue); // Start to play aud_playback(FALSE, TRUE); } } }