bool Base::Start() //---------------- { if(!IsOpen()) return false; if(!IsPlaying()) { { Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } m_Clock.SetResolution(1); m_RequestFlags.fetch_and(~RequestFlagRestart); if(!InternalStart()) { m_Clock.SetResolution(0); return false; } m_IsPlaying = true; } return true; }
void COggStream::Update() { if (!stopped) { UpdateTimer(); if (!paused) { if (UpdateBuffers()) { if (!IsPlaying()) { // source state changed if (!StartPlaying()) { // stream stopped ReleaseBuffers(); } else { // stream interrupted ReleaseBuffers(); } } } else { // EOS, nothing left to do ReleaseBuffers(); } } } }
void wxAnimationCtrl::SetAnimation(const wxAnimation &anim) { if (IsPlaying()) Stop(); ResetAnim(); ResetIter(); // copy underlying GdkPixbuf object m_anim = anim.GetPixbuf(); // m_anim may be null in case wxNullAnimation has been passed if (m_anim) { // add a reference to the GdkPixbufAnimation g_object_ref(m_anim); if (!this->HasFlag(wxAC_NO_AUTORESIZE)) FitToAnimation(); } DisplayStaticImage(); }
void SoundSource::Update(float timeStep) { if (!audio_ || !IsEnabledEffective()) return; // If there is no actual audio output, perform fake mixing into a nonexistent buffer to check stopping/looping if (!audio_->IsInitialized()) MixNull(timeStep); // check for autoPlay if (autoPlay_ && sound_.NotNull() && !hasAutoPlayed_ && !context_->GetEditorContext()) { hasAutoPlayed_ = true; Play(sound_); } // Free the stream if playback has stopped if (soundStream_ && !position_) StopLockless(); // Check for autoremove if (autoRemove_) { if (!IsPlaying()) { autoRemoveTimer_ += timeStep; if (autoRemoveTimer_ > AUTOREMOVE_DELAY) { Remove(); // Note: this object is now deleted, so only returning immediately is safe return; } } else autoRemoveTimer_ = 0.0f; } }
void Base::Stop(bool force) //------------------------- { if(!IsOpen()) return; if(IsPlaying()) { if(force) { InternalStopForce(); } else { InternalStop(); } m_RequestFlags.fetch_and(~RequestFlagRestart); m_Clock.SetResolution(0); m_IsPlaying = false; { Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } } }
bool psEntity::Play(SoundControl* &ctrl, csVector3 entityPosition) { EntityState* entityState; // checking if a sound is still playing if(IsPlaying()) { return false; } // checking if the state is defined entityState = states.Get(state, 0); if(entityState == 0) { return false; } // picking up randomly among resources if(!entityState->resources.IsEmpty()) { int resourceNumber = SoundManager::randomGen.Get() * entityState->resources.GetSize(); Debug4(LOG_SOUND, 0, "psEntity::Play() %s PLAYS %s meshid: %u",entityName.GetData(),entityState->resources[resourceNumber],GetMeshID()); if(SoundSystemManager::GetSingleton().Play3DSound(entityState->resources[resourceNumber], DONT_LOOP, 0, 0, entityState->volume, ctrl, entityPosition, 0, minRange, maxRange, VOLUME_ZERO, CS_SND3D_ABSOLUTE, handle)) { when = entityState->delay; handle->SetCallback(this, &StopCallback); return true; } } return false; }
void nuiAnimationSequence::OnAnimStopped(const nuiEvent& rEvent) { if (IsPlaying()) { //NGL_LOG(_T("nuiAnimationSequence), NGL_LOG_DEBUG, _T("::OnAnimStopped\n")); nuiAnimation* pAnim = (nuiAnimation*)rEvent.mpUser; // Find the next anim in the sequence: std::list<nuiAnimation*>::iterator it = mpAnimations.begin(); std::list<nuiAnimation*>::iterator end = mpAnimations.end(); while (it != end) { if (pAnim == *it) { ++it; break; } ++it; } if (it != end) { // Launch the next anim in the sequence: pAnim = *it; pAnim->Play(); //NGL_LOG(_T("nuiAnimationSequence), NGL_LOG_DEBUG, _T("OnAnimStopped Launch next anim\n")); } else { // stop the sequence if this was the last in the chain: //NGL_LOG(_T("nuiAnimationSequence), NGL_LOG_DEBUG, _T("OnAnimStopped STOP\n")); mpAnimations.front()->Play(); } } }
void CAudioManager::Fadeout(int id, int targetVolume, float time){ if(m_bValidAudio == false) return; int currentVolume = 0; double timeStep = 0; double volumeStep = 0; for(int i = 0; i < m_AudioClip.size(); i++){ if(m_AudioClip[i].AudioID == id && IsPlaying(id) == true){ m_AudioClip[i].bFadeout = true; m_AudioClip[i].targetVolume = targetVolume; currentVolume = GetVolume(i); if(targetVolume < currentVolume && time > 0){ timeStep = time/ 0.1; volumeStep = (double)(currentVolume - targetVolume) / timeStep; m_AudioClip[i].fadeStep = volumeStep; m_AudioClip[i].bFadein = true; } } }//for }
void MapSidebar::UpdateSimButtons() { wxButton* button; button = wxDynamicCast(FindWindow(ID_SimPlay), wxButton); wxCHECK(button, ); button->Enable(m_SimState != SimPlaying); button = wxDynamicCast(FindWindow(ID_SimFast), wxButton); wxCHECK(button, ); button->Enable(m_SimState != SimPlayingFast); button = wxDynamicCast(FindWindow(ID_SimSlow), wxButton); wxCHECK(button, ); button->Enable(m_SimState != SimPlayingSlow); button = wxDynamicCast(FindWindow(ID_SimPause), wxButton); wxCHECK(button, ); button->Enable(IsPlaying(m_SimState)); button = wxDynamicCast(FindWindow(ID_SimReset), wxButton); wxCHECK(button, ); button->Enable(m_SimState != SimInactive); }
/// starts or continue playing, true if successfull virtual const bool Play(){ if(IsPlaying())return true; if(IsPaused()){ // unpause sound if(mpChannel){ result = FMOD_Channel_SetPaused(mpChannel,false); ERRCHECK(result); } } else { // start playing mpChannel = 0; // alloc channel if(mpSound && mSoundSystem && mSoundSystem->mpSystem){ result = FMOD_System_PlaySound(mSoundSystem->mpSystem, FMOD_CHANNEL_FREE, mpSound, true, &mpChannel); ERRCHECK(result); } // channel free and working? if(mpChannel){ if(mb3D){ // set 3d position and velocity data result = FMOD_Channel_Set3DAttributes(mpChannel, &mlPos, &mlVel); ERRCHECK(result); // set currently set minmax distances SetMinMaxDistance(mfMinDistance,mfMaxDistance); } result = FMOD_Channel_SetPaused(mpChannel,false); ERRCHECK(result); return true; } else return false; } return false; }
int SoundEvent::play(SoundLib soundlib, VESSEL *Vessel, char *names , double *offset, int *newbuffer, double simcomputert, double MissionTime, int mode, double timeremaining, double timeafterpdi, double timetoapproach, int flags, int volume) { int kk; char buffers[255]; double altitude; double vlon,vlat,vrad; double timetopdi; double timesincepdi; double deltaoffset =0.; if (!isValid()) return(false); // is Sound still playing ? // if yes let it play // TRACESETUP("SOUNDEVENT PLAY"); if(lastplayed >= 0) { if(soundevents[lastplayed].offset == -1) { if (IsPlaying()) { // TRACE("EN TRAIN DE JOUER"); return(false); } } else if (IsPlaying()) { if (soundevents[lastplayed+1].offset > soundevents[lastplayed].offset) { if(Finish((double) soundevents[lastplayed+1].offset - 0.1)) { } else return(false); } } } // no more sounds to be played just return if(soundevents[lastplayed+1].met == 0) return(false); // sprintf(buffers,"ENTREE PLAY MODE %d timeremaining %f timeafterpdi %f altitude %f", // mode,timeremaining,timeafterpdi,altitude); // TRACE(buffers); timetopdi = timeremaining -(MissionTime - simcomputert); timesincepdi = timeafterpdi +(MissionTime - simcomputert); timetoapproach = timetoapproach -(MissionTime -simcomputert); if (mode == 0) { /* sprintf(buffers,"AVANT PDI IGNIT %f %f %f ", timetopdi, MissionTime, simcomputert); sprintf(oapiDebugString(),"%s",buffers); */ } if (mode >= 1 && mode < 3) { OBJHANDLE hbody=Vessel->GetGravityRef(); double bradius=oapiGetSize(hbody); Vessel->GetEquPos(vlon, vlat, vrad); double cgelev=Vessel->GetCOG_elev(); altitude=vrad-bradius-cgelev; /* sprintf(buffers,"AFTER PDI : TIMEAFTER %f ALTITUDE %f", timesincepdi,altitude); sprintf(oapiDebugString(),"%s",buffers); */ } kk = lastplayed+1; sprintf(buffers,"%f",soundevents[kk].altitude); // TRACE (buffers); // sprintf(buffers,"%f",altitude); // TRACE (buffers); // if mode = 1 BRAKING it's altitude // if mode = 0 MONITOR it's time to ignition if (mode == 0) { // TRACE("TEST PDI IGNIT"); sprintf(buffers,"TEST PDI IGNIT NEXTEVENT %d %f %s VERSUS %f",kk, soundevents[kk].timetoignition,soundevents[kk].filenames, timetopdi); // sprintf(oapiDebugString(),"%s",buffers); // TRACE(buffers); /* skip too old sounds */ while ( (soundevents[kk].timetoignition > timetopdi) && (soundevents[kk+1].timetoignition > timetopdi) ) kk++; if (soundevents[kk].timetoignition < timetopdi) return 0; deltaoffset = soundevents[kk].timetoignition - timetopdi; } else if (mode == 1) { //sprintf(buffers,"TIME AFTER PDI %f", timesincepdi); //TRACE(buffers); if ((timeafterpdi < 160)) { // TRACE("TIME AFTER"); sprintf(buffers,"TIME AFTER %f %f",soundevents[kk].timeafterignition, timesincepdi); // TRACE(buffers); sprintf(buffers,"TEST AFTER PDI NEXTEVENT %d %f %s VERSUS %f",kk, soundevents[kk].timeafterignition,soundevents[kk].filenames, timesincepdi); // sprintf(oapiDebugString(),"%s",buffers); while ( (soundevents[kk].timeafterignition < timesincepdi) && (soundevents[kk+1].timeafterignition < timesincepdi) && (!soundevents[kk].mandatory) ) kk++; if (soundevents[kk].timeafterignition>timesincepdi) return 0; } else { // TRACE("TIME TO APPROACH"); sprintf(buffers,"TIME TO APP %f %f",soundevents[kk].timetoapproach, timetoapproach); // TRACE(buffers); sprintf(buffers,"TEST TO APPROACH NEXTEVENT %d %f %s VERSUS %f",kk, soundevents[kk].timetoapproach,soundevents[kk].filenames, timetoapproach); // sprintf(oapiDebugString(),"%s",buffers); while ( (soundevents[kk].timetoapproach > timetoapproach) && (soundevents[kk+1].timetoapproach > timetoapproach) && (!soundevents[kk].mandatory) ) kk++; if (soundevents[kk].timetoapproach<timetoapproach) return 0; } } else if (mode == 2) { // TRACE("TEST ALTITUDE"); sprintf(buffers,"ALT %d %f %f",mode,soundevents[kk].altitude,altitude); // TRACE(buffers); // sprintf(buffers,"TEST ALTI NEXTEVENT %d %f %s VERSUS %f MODE %d",kk, // soundevents[kk].altitude,soundevents[kk].filenames, // altitude,mode); // sprintf(oapiDebugString(),"%s",buffers); while (soundevents[kk].mode != mode) { kk++; } while ( (soundevents[kk].altitude > altitude) && (soundevents[kk+1].altitude > altitude) && (!soundevents[kk].mandatory) ) kk++; if (soundevents[kk].altitude<altitude) return 0; } else if (mode == 3) { if (soundevents[kk].met > MissionTime) return 0; deltaoffset = 0.0; } else return 0; // TRACE("ON VA JOUER "); // TRACE(soundevents[kk].filenames); strcpy(names,soundevents[kk].filenames); *offset = (double) soundevents[kk].offset + deltaoffset; *newbuffer = true; if(lastplayed >= 0) { if (!strcmp(soundevents[kk].filenames,soundevents[lastplayed].filenames)) *newbuffer = false; } lastplayed = kk; // sprintf(buffers,"SON %d NEW %d OFFSET %f", kk, *newbuffer,*offset); // TRACE(buffers); return 1; }
// -------------------------------------------------------------------------- // // Sound property functions // -------------------------------------------------------------------------- // void VFmodSoundObject::Play(float fStartTime, bool bAlsoInEditor) { if (m_spResource == NULL || IsPlaying()) return; if (!bAlsoInEditor && !Vision::Editor.IsAnimatingOrPlaying()) return; m_fStartTime = fStartTime; VFmodManager &manager = VFmodManager::GlobalManager(); if (manager.IsInitialized()) { const hkvVec3 &vPos = GetPosition(); // stop old playing if (m_pChannel) m_pChannel->stop(); VFmodSoundResource* pResource = (VFmodSoundResource*)GetResource(); if (pResource->m_pSound == NULL) // sound resource not loaded successfully return; FMOD_WARNINGCHECK(manager.m_pSystem->playSound(FMOD_CHANNEL_FREE, pResource->m_pSound, true, &m_pChannel)); if (!m_pChannel) return; FMOD_WARNINGCHECK(m_pChannel->getFrequency(&m_fInitialFreq)); // if this a music sound object assign it to the music channel group if (IsMusic()) m_pChannel->setChannelGroup(manager.m_pMusicGroup); // set everything m_pChannel->setUserData(this); // ...so that we can get from channel to VSoundObject m_pChannel->setCallback(ChannelCallback); m_pChannel->setMode(IsLooped() ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF); m_pChannel->setPriority(GetPriority()); m_pChannel->set3DMinMaxDistance(Get3DFadeMinDistance(), Get3DFadeMaxDistance()); m_pChannel->set3DAttributes((FMOD_VECTOR *)&vPos, NULL); // no speed (yet) m_pChannel->setVolume(GetVolume()); m_pChannel->setPan(GetPan()); SetPitch(GetPitch()); SetConeAngles(GetConeAngleInside(), GetConeAngleOutside()); // Initially the sound is left paused, then within the first RunTick it is unpaused. This is required since // the 3D listener attributes has to be set prior to playing a sound. Otherwise Fmod would perform // occlusion-raycasts without having initialized listener-attributes, which potentially results in a // wrong occlusion-behavior. m_bUnpause = true; m_bIsPlaying = true; m_bPlayedOnce = true; unsigned int ims = (int)(fStartTime*1000.f); // milliseconds m_pChannel->setPosition(ims,FMOD_TIMEUNIT_MS); m_pChannel->setMute(IsMuted()); } Helper_SetFlag(VFMOD_FLAG_PAUSED, !IsPlaying()); }
bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options) { if (m_currentlyCrossFading) CloseFileInternal(false); //user seems to be in a hurry m_crossFading = g_guiSettings.GetInt("musicplayer.crossfade"); //WASAPI doesn't support multiple streams, no crossfading for cdda, cd-reading goes mad and no crossfading for last.fm doesn't like two connections if (file.IsCDDA() || file.IsLastFM() || g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") != CStdString::npos) m_crossFading = 0; if (m_crossFading && IsPlaying()) { //do a short crossfade on trackskip //set to max 2 seconds for these prev/next transitions if (m_crossFading > 2) m_crossFading = 2; //queue for crossfading bool result = QueueNextFile(file, false); if (result) { //crossfading value may be update by QueueNextFile when nr of channels changed if (!m_crossFading) // swap to next track m_decoder[m_currentDecoder].SetStatus(STATUS_ENDED); else //force to fade to next track immediately m_forceFadeToNext = true; } return result; } // normal opening of file, nothing playing or crossfading not enabled // however no need to return to gui audio device CloseFileInternal(false); // always open the file using the current decoder m_currentDecoder = 0; if (!m_decoder[m_currentDecoder].Create(file, (__int64)(options.starttime * 1000), m_crossFading)) return false; m_iSpeed = 1; m_bPaused = false; m_bStopPlaying = false; m_bytesSentOut = 0; CLog::Log(LOGINFO, "PAPlayer: Playing %s", file.m_strPath.c_str()); m_timeOffset = (__int64)(options.starttime * 1000); unsigned int channel, sampleRate, bitsPerSample; m_decoder[m_currentDecoder].GetDataFormat(&channel, &sampleRate, &bitsPerSample); if (!CreateStream(m_currentStream, channel, sampleRate, bitsPerSample)) { m_decoder[m_currentDecoder].Destroy(); CLog::Log(LOGERROR, "PAPlayer::Unable to create audio stream"); } *m_currentFile = file; if (ThreadHandle() == NULL) Create(); m_startEvent.Set(); m_bIsPlaying = true; m_cachingNextFile = false; m_currentlyCrossFading = false; m_forceFadeToNext = false; m_bQueueFailed = false; m_decoder[m_currentDecoder].Start(); // start playback return true; }
bool CApplicationPlayer::IsPausedPlayback() const { return (IsPlaying() && IsPaused()); }
//======================================================================================== // /exit exit T-Clock 2010 // /prop show T-Clock 2010 properties // /SyncOpt SNTP options // /Sync synchronize the system clock with an NTP server // /start start the Stopwatch (open as needed) // /stop stop (pause really) the Stopwatch // /reset reset Stopwatch to 0 (stop as needed) // /lap record a (the current) lap time //================================================================================================ //---------------------------------------------//---------------+++--> T-Clock Command Line Option: void ProcessCommandLine(HWND hwndMain,const char* cmdline) //-----------------------------+++--> { int justElevated = 0; const char* p = cmdline; if(g_hwndTClockMain != hwndMain){ g_hwndTClockMain = CreateWindow("STATIC",NULL,0,0,0,0,0,HWND_MESSAGE_nowarn,0,0,0); SubclassWindow(g_hwndTClockMain, MsgOnlyProc); } while(*p != '\0') { if(*p == '/') { ++p; if(strncasecmp(p, "prop", 4) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_SHOWPROP, 0); p += 4; } else if(strncasecmp(p, "exit", 4) == 0) { SendMessage(hwndMain, MAINM_EXIT, 0, 0); p += 4; } else if(strncasecmp(p, "start", 5) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_START, 0); p += 5; } else if(strncasecmp(p, "stop", 4) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_STOP, 0); p += 4; } else if(strncasecmp(p, "reset", 5) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_RESET, 0); p += 5; } else if(strncasecmp(p, "pause", 5) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_PAUSE, 0); p += 5; } else if(strncasecmp(p, "resume", 6) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_RESUME, 0); p += 6; } else if(strncasecmp(p, "lap", 3) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_LAP, 0); p += 3; } else if(strncasecmp(p, "SyncOpt", 7) == 0) { if(HaveSetTimePermissions()){ if(!SendMessage(hwndMain, WM_COMMAND, MAKEWPARAM(IDM_SNTP,1), 0)){ NetTimeConfigDialog(justElevated); } }else{ SendMessage(hwndMain, WM_COMMAND, IDM_SNTP, 0); } p += 7; } else if(strncasecmp(p, "Sync", 4) == 0) { p += 4; SendMessage(hwndMain, WM_COMMAND, MAKEWPARAM(IDM_SNTP_SYNC,justElevated), 0); if(g_hwndTClockMain == hwndMain) SendMessage(hwndMain, MAINM_EXIT, 0, 0); } else if(strncmp(p, "Wc", 2) == 0) { // Win10 calendar "restore" if(p[2] == '1') // restore to previous api.SetSystemInt(HKEY_LOCAL_MACHINE, kSectionImmersiveShell, kKeyWin32Tray, 1); else // use the slow (new) one api.DelSystemValue(HKEY_LOCAL_MACHINE, kSectionImmersiveShell, kKeyWin32Tray); p += 2; } else if(strncmp(p, "UAC", 3) == 0) { justElevated = 1; p += 3; } continue; } ++p; } if(g_hwndTClockMain != hwndMain){ const DWORD kTimeout = 10000; const DWORD kStartTicks = GetTickCount(); DWORD timeout; MSG msg; msg.message = 0; for(;;){ int have_ui = IsWindow(g_hwndSheet) || IsWindow(g_hDlgTimer) || IsWindow(g_hDlgTimerWatch) || IsWindow(g_hDlgSNTP) || IsWindow(g_hDlgStopWatch); if(have_ui) timeout = INFINITE; else if(IsPlaying()) timeout = 200; else break; MsgWaitForMultipleObjectsEx(0, NULL, timeout, QS_ALLEVENTS, MWMO_INPUTAVAILABLE); while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ if(msg.message == WM_QUIT) break; if(!(g_hwndSheet && IsWindow(g_hwndSheet) && PropSheet_IsDialogMessage(g_hwndSheet,&msg)) && !(g_hDlgTimer && IsWindow(g_hDlgTimer) && IsDialogMessage(g_hDlgTimer,&msg)) && !(g_hDlgTimerWatch && IsWindow(g_hDlgTimerWatch) && IsDialogMessage(g_hDlgTimerWatch,&msg)) && !(g_hDlgSNTP && IsWindow(g_hDlgSNTP) && IsDialogMessage(g_hDlgSNTP,&msg)) && !(g_hDlgStopWatch && IsWindow(g_hDlgStopWatch) && IsDialogStopWatchMessage(g_hDlgStopWatch,&msg))){ TranslateMessage(&msg); DispatchMessage(&msg); } } if(msg.message == WM_QUIT) break; if(!have_ui) { DWORD elapsed = GetTickCount() - kStartTicks; if(elapsed >= kTimeout) break; } } DestroyWindow(g_hwndTClockMain); g_hwndTClockMain = NULL; } }
int AudioController::GetPlaybackPosition() { if (!IsPlaying()) return 0; return MillisecondsFromSamples(player->GetCurrentPosition()); }
bool CApplicationPlayer::IsPausedPlayback() { return (IsPlaying() && (GetPlaySpeed() == 0)); }
HRESULT FMediaContainer::PlayMT(ulong videoID, BOOL bPaused /* = FALSE */) { if (m_pStatusBar) m_pStatusBar->SetStatusText(0, "Loading video plug-in...", VIEW_PLAYER); m_bFullScreenAd = FALSE; m_MSLast = 0; m_MSPlayed = 0; HRESULT hr = m_pMediaPlayer.PlayMT(videoID, bPaused); BOOL bFullscreenAd = FALSE; for (size_t k =0 ; k < MAX_AD_WINDOWS; k++) { if (m_pAdWindows[k]) { m_pAdWindows[k]->ShowWindow(SW_HIDE); m_pAdWindows[k]->Clear(); } } m_CurVideoID = videoID; //No sync, let it burn! m_AdManager->Clear(); if (SUCCEEDED(hr) || hr == E_PENDING) { m_AdRequests.Push(videoID); m_bPlaying = !bPaused; FDownload &pDown = m_pMediaPlayer.m_pVideo; FIniConfig aConf = g_Objects._DownloadManager.GetDownloadConf(videoID); if (m_AdManager->LoadAds(aConf, TRUE)) { IAdWindowInit InitData; InitData.m_hWndParent = m_hWnd; InitData.m_pAdManager = m_AdManager.m_p; InitData.m_pNotify = this; IAdPosition pPos; pPos.m_PlaybackPosMS = pDown.m_Detail.m_PlaybackPosMS / DURATION_MULT; pPos.m_TotalDurationMS = pDown.m_Detail.m_TotalDurationMS; pPos.m_dwFlags = FLAG_PLAYBACK_START; for (size_t k = 0; k < MAX_AD_WINDOWS; k++) { InitData.m_AdType = (AdTypes)(k + 1); InitData.m_dwWinID = (DWORD)k; if (m_pAdWindows[k] == NULL) m_pAdWindows[k].Attach(new FAdWindow); if (m_pAdWindows[k]->Init(InitData)) { BOOL bHasAd = m_pAdWindows[k]->UpdatePosition(pPos); if (k == 0 && bHasAd) bFullscreenAd = TRUE; } } SetTimer(1, 500); } } m_pMediaPlayer.ShowWindow(SW_SHOW); if (bFullscreenAd) { Pause(); } if (g_MainFrame->IsFullScreen()) m_ControlBar.ShowWindow(SW_HIDE); UpdateLayout(); if (FAILED(hr)) { if (hr != E_PENDING) { if (m_pStatusBar) m_pStatusBar->SetStatusText(0, "Cannot play video.", VIEW_PLAYER); } } else { if (m_pStatusBar) { if (IsPlaying()) m_pStatusBar->SetStatusText(0, "Playing", VIEW_PLAYER); else m_pStatusBar->SetStatusText(0, "Paused", VIEW_PLAYER); } } return hr; }
void CGUISound::Wait(uint32_t millis/*=500*/) { millis /= 10; while (IsPlaying() && millis--) Sleep(10); }
void MsgAudioPreview::PlayL() { if( IsPlaying() ) { Stop(); return; } //sequence for playing a beep once sound _LIT8( KFileListBeepSequence, "\x00\x11\x06\x0A\x08\x73\x0A\x40\x28\x0A\xF7\ \x05\xFC\x40\x64\x0A\x08\x40\x32\x0A\xF7\x06\x0B" ); // rng mime type _LIT( KFileListRngMimeType, "application/vnd.nokia.ringing-tone" ); Cancel(); // stop previous play if ( !iFullName || iFullName->Des().Length() == 0 ) { User::Leave( KErrNotFound ); } TRAP_IGNORE( ReadActiveProfileL() ); TPtrC fileName( iFullName->Des() ); TDataType dataType; TInt err = GetDataType( fileName, dataType ); if ( err == KErrNotFound ) { fileName.Set( iDefaultTone ); if ( fileName.Length() == 0 ) { User::Leave( KErrNotFound ); } } else if ( err != KErrNone ) { User::Leave( err ); } TBool mimeTypeRng = EFalse; if ( err == KErrNone ) { if( dataType.Des().CompareF( KFileListRngMimeType ) == 0 ) { mimeTypeRng = ETrue; } } TInt ringingType = RingingType(); if ( ringingType == ERingingTypeBeepOnce ) { // Active profile ringing tone is set to Beep Once // Don't initialize a FileSequence but use DesSequence instead iTonePlayer = CMdaAudioToneUtility::NewL( *this ); iTonePlayer->PrepareToPlayDesSequence( KFileListBeepSequence() ); iTonePlayerStatus = EPlayerInitializing; } else { if( mimeTypeRng ) { //Ringingtone is a RNG-file iTonePlayer = CMdaAudioToneUtility::NewL( *this ); iTonePlayer->PrepareToPlayFileSequence( fileName ); iTonePlayerStatus = EPlayerInitializing; } else { delete iAudioPlayer; iAudioPlayer = 0; iAudioPlayer = CDrmPlayerUtility::NewFilePlayerL( fileName, *this, KAudioPriorityRingingTonePreview, ( TMdaPriorityPreference )KAudioPrefRingFilePreview ); iAudioPlayerStatus = EPlayerInitializing; } } DisableBackLight(); }
// game boot up stuff void init_mud(long hotreboot) { char buf[MAX_BUFFER]; MSOCKET *socket; extern CREATURE *hash_creature[HASH_KEY]; extern OBJECT *hash_object[HASH_KEY]; extern ROOM *hash_room[HASH_KEY]; extern char **connect_attempts; extern void backup_update(); #ifndef WIN32 struct itimerval itime; struct timeval time; #endif extern char * const months[]; extern char * const days[]; long x; for(x = 0; months[x]; x++) ; mudtime.months = x; for(x = 0; days[x]; x++) ; mudtime.days = x; // init hash tables memset(hash_creature, 0,sizeof(hash_creature)); memset(hash_object, 0,sizeof(hash_object)); memset(hash_room, 0,sizeof(hash_room)); memset(hash_reset, 0,sizeof(hash_reset)); // set up process signals to catch and deal with signal(SIGINT, signal_handler); signal(SIGILL, signal_handler); signal(SIGFPE, signal_handler); signal(SIGSEGV, signal_handler); signal(SIGPIPE, SIG_IGN); // ignore pipes! tx to unix socket faq for help // with this. http://http://www.developerweb.net/forum/ #ifndef WIN32 signal(SIGTRAP, signal_handler); signal(SIGVTALRM, signal_handler); // this code is to check for infinite looping time.tv_sec = 5; time.tv_usec = 0; itime.it_interval = time; itime.it_value = time; if( setitimer(ITIMER_VIRTUAL, &itime, 0) < 0 ) mudlog("Error starting setitimer."); #endif // initialize the random number generator init_rand(); // connect_attempts array, to keep people from spam connecting to slow down the mud connect_attempts = malloc(sizeof(char*)); connect_attempts[0] = 0; mysql = mysql_init(NULL); if (!mysql) { mudlog("Error initializing MySQL: %s", mysql_error(mysql)); abort(); } // connect to MySQL database if (!mysql_real_connect(mysql, DB_HOST, DB_LOGIN, DB_PASSWORD, DB_NAME, 0, NULL, 0)) { mudlog("Error opening mysql database: %s", mysql_error(mysql)); abort(); } if (mysql_select_db(mysql, DB_NAME)) { mudlog("Error opening main database: %s",mysql_error(mysql)); if (mysql) mysql_close(mysql); abort(); } // time of da mud ! fread_time(); // load areas/rooms/objects/creatures load_db(); // check if hotreboot and reconnect everything if(hotreboot) { MSOCKET *socket=0; char buf[MAX_BUFFER]; MYSQL_RES *result; MYSQL_ROW row; mysql_query(mysql, "SELECT * FROM player WHERE online='1'"); result = mysql_store_result(mysql); if (mysql_num_rows(result) < 0) { mudlog("hotreboot: mysql error is: %s",mysql_error(mysql)); exit(1); } while((row = mysql_fetch_row(result))) { strcpy(buf, row[P_NAME]); // check for "host" player.. holds control descriptor if(!strcasecmp("host", row[C_NAME])) { host = atoi(row[P_DESCRIPTOR]); } else { socket = init_socket(); fread_player(socket, buf); str_dup(&socket->host, row[P_HOST]); str_dup(&socket->ip, row[P_IP]); socket->desc = atoi(row[P_DESCRIPTOR]); socket->connected = CON_PLAYING; trans(socket->pc, socket->pc->in_room); sendcrit(socket->pc, "Hotreboot completed."); } } mysql_free_result(result); } // make sure nobody has non-existant connections, in the event of a crash + hotreboot // then go through and update people who are online // this is also a good time to get host address, as players will be expecting lag mysql_query(mysql, "UPDATE player SET online='0', descriptor='0'"); for(socket = socket_list; socket; socket = socket->next) { get_hostname(socket); sprintf(buf,"UPDATE player SET online='1', host=\"%s\" WHERE id='%li'", smash_quotes(socket->host), socket->id); mysql_query(mysql, buf); } // see how many players are in each area, to see if area should be 'alive' for(socket = socket_list; socket; socket = socket->next) { if(IsPlaying(socket->pc)) socket->pc->in_room->area->players++; } // check if we need to backup backup_update(); }
void CSoundBase::EnsurePlay() { if (m_ShouldBePlaying && !IsPlaying()) Play(); }
//============================================================================ bool plDSoundBuffer::StreamingFillBuffer(plAudioFileReader *stream) { if(!source) return false; ALenum error; ALuint bufferId; unsigned char data[STREAM_BUFFER_SIZE]; int buffersProcessed = BuffersProcessed(); hsBool finished = false; for(int i = 0; i < buffersProcessed; i++) { alSourceUnqueueBuffers( source, 1, &bufferId ); if( (error = alGetError()) != AL_NO_ERROR ) { plStatusLog::AddLineS("audio.log", "Failed to unqueue buffer %d", error); return false; } if(!finished) { if(stream->NumBytesLeft() == 0) { // if at anytime we run out of data, and we are looping, reset the data stream and continue to fill buffers if(IsLooping()) { stream->SetPosition(0); // we are looping, so reset data stream, and keep filling buffers } else { finished = true; // no more data, but we could still be playing, so we don't want to stop the sound yet } } if(!finished) { unsigned int size = stream->NumBytesLeft() < STREAM_BUFFER_SIZE ? stream->NumBytesLeft() : STREAM_BUFFER_SIZE; stream->Read(size, data); ALenum format = IGetALFormat(fBufferDesc->fBitsPerSample, fBufferDesc->fNumChannels); alBufferData( bufferId, format, data, size, fBufferDesc->fNumSamplesPerSec ); if( (error = alGetError()) != AL_NO_ERROR ) { plStatusLog::AddLineS("audio.log", "Failed to copy data to sound buffer %d", error); return false; } alSourceQueueBuffers( source, 1, &bufferId ); if( (error = alGetError()) != AL_NO_ERROR ) { plStatusLog::AddLineS("audio.log", "Failed to queue buffer %d", error); return false; } } } } if(!IsPlaying() && !finished) { alSourcePlay(source); } alGetError(); return true; }
bool CApplicationPlayer::IsPlayingVideo() const { return (IsPlaying() && HasVideo()); }
bool nuiSWF::Draw(nuiDrawContext* pContext) { gameswf::set_render_handler(mpRenderHandler); nglTime now; if (mLastTime <= 0) mLastTime = now; double lap = now - mLastTime; mLastTime = now; /* double advance = lap * mFPS; unused */ nuiRenderArray* pDummy = new nuiRenderArray(GL_POINTS); pContext->DrawArray(pDummy); glPushAttrib(GL_ALL_ATTRIB_BITS); float width, height; width = mpMovie->get_width_pixels(); height = mpMovie->get_height_pixels(); //glScalef(10/width, 10/height, 0); nuiSize x=0,y=0; LocalToGlobal(x,y); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_EDGE_FLAG_ARRAY); glDisableClientState(GL_INDEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); mpMovieInterface->set_display_viewport(ToBelow(x), ToBelow(y), ToBelow(mRect.GetWidth()), ToBelow(mRect.GetHeight())); //mpMovieInterface->set_display_viewport(50, 50, 1, 1); mpMovieInterface->set_background_alpha(GetAlpha()); if (IsPlaying()) mpMovieInterface->advance((float)lap); mpMovieInterface->display(); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_EDGE_FLAG_ARRAY); glDisableClientState(GL_INDEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); // Restore state that gameswf kills glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); // See if we should exit. if (mLoop == false && (mpMovieInterface->get_current_frame() + 1 == mpMovie->get_frame_count() || mpMovieInterface->get_play_state() == gameswf::character::STOP) ) { // We're reached the end of the movie; exit. Stop(); } glPopAttrib(); pContext->SetTexture(NULL); return true; }
bool CApplicationPlayer::IsPlayingGame() const { return (IsPlaying() && HasGame()); }
void AudioController::ResyncPlaybackPosition(int new_position) { if (!IsPlaying()) return; player->SetCurrentPosition(SamplesFromMilliseconds(new_position)); }
bool CApplicationPlayer::IsPlayingRDS() const { return (IsPlaying() && HasRDS()); }
//======================================================================================== // /exit exit T-Clock 2010 // /prop show T-Clock 2010 properties // /SyncOpt SNTP options // /Sync synchronize the system clock with an NTP server // /start start the Stopwatch (open as needed) // /stop stop (pause really) the Stopwatch // /reset reset Stopwatch to 0 (stop as needed) // /lap record a (the current) lap time //================================================================================================ //---------------------------------------------//---------------+++--> T-Clock Command Line Option: void ProcessCommandLine(HWND hwndMain,const char* cmdline) //-----------------------------+++--> { int justElevated = 0; const char* p = cmdline; if(g_hwndTClockMain != hwndMain){ g_hwndTClockMain = CreateWindow("STATIC",NULL,0,0,0,0,0,HWND_MESSAGE_nowarn,0,0,0); SubclassWindow(g_hwndTClockMain, MsgOnlyProc); } while(*p != '\0') { if(*p == '/') { ++p; if(strncasecmp(p, "prop", 4) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_SHOWPROP, 0); p += 4; } else if(strncasecmp(p, "exit", 4) == 0) { SendMessage(hwndMain, MAINM_EXIT, 0, 0); p += 4; } else if(strncasecmp(p, "start", 5) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_START, 0); p += 5; } else if(strncasecmp(p, "stop", 4) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_STOP, 0); p += 4; } else if(strncasecmp(p, "reset", 5) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_RESET, 0); p += 5; } else if(strncasecmp(p, "pause", 5) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_PAUSE, 0); p += 5; } else if(strncasecmp(p, "resume", 6) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_RESUME, 0); p += 6; } else if(strncasecmp(p, "lap", 3) == 0) { SendMessage(hwndMain, WM_COMMAND, IDM_STOPWATCH_LAP, 0); p += 3; } else if(strncasecmp(p, "SyncOpt", 7) == 0) { NetTimeConfigDialog(justElevated); p += 7; } else if(strncasecmp(p, "Sync", 4) == 0) { p += 4; if(HaveSetTimePermissions()){ SyncTimeNow(); } else if(!justElevated){ if(api.ExecElevated(GetClockExe(),"/UAC /Sync",NULL) != 0){ MessageBox(0,"T-Clock must be elevated to set your system time,\nbut elevation was cancled", "Time Sync Failed", MB_OK|MB_ICONERROR); } } if(g_hwndTClockMain == hwndMain) SendMessage(hwndMain, MAINM_EXIT, 0, 0); } else if(strncmp(p, "Wc", 2) == 0) { // Win10 calendar "restore" if(p[2] == '1') // restore to previous api.SetSystemInt(HKEY_LOCAL_MACHINE, kSectionImmersiveShell, kKeyWin32Tray, 1); else // use the slow (new) one api.DelSystemValue(HKEY_LOCAL_MACHINE, kSectionImmersiveShell, kKeyWin32Tray); p += 2; } else if(strncmp(p, "UAC", 3) == 0) { justElevated = 1; p += 3; } continue; } ++p; } if(g_hwndTClockMain != hwndMain){ int timeout = 100; /**< timeout in 1/10th seconds to allow sounds up to 10 seconds before terminating */ MSG msg; msg.message = 0; while(IsPlaying() && --timeout){ while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ if(msg.message==WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } if(msg.message==WM_QUIT) break; Sleep(100); } DestroyWindow(g_hwndTClockMain); g_hwndTClockMain = NULL; } }
/* ======================== idSoundVoice_OpenAL::Create ======================== */ void idSoundVoice_OpenAL::Create( const idSoundSample* leadinSample_, const idSoundSample* loopingSample_ ) { if( IsPlaying() ) { // This should never hit Stop(); return; } triggered = true; leadinSample = ( idSoundSample_OpenAL* )leadinSample_; loopingSample = ( idSoundSample_OpenAL* )loopingSample_; if( alIsSource( openalSource ) && CompatibleFormat( leadinSample ) ) { sampleRate = leadinSample->format.basic.samplesPerSec; } else { DestroyInternal(); formatTag = leadinSample->format.basic.formatTag; numChannels = leadinSample->format.basic.numChannels; sampleRate = leadinSample->format.basic.samplesPerSec; //soundSystemLocal.hardware.pXAudio2->CreateSourceVoice( &pSourceVoice, ( const WAVEFORMATEX* )&leadinSample->format, XAUDIO2_VOICE_USEFILTER, 4.0f, &streamContext ); CheckALErrors(); alGenSources( 1, &openalSource ); if( CheckALErrors() != AL_NO_ERROR ) //if( pSourceVoice == NULL ) { // If this hits, then we are most likely passing an invalid sample format, which should have been caught by the loader (and the sample defaulted) return; } alSourcef( openalSource, AL_ROLLOFF_FACTOR, 0.0f ); //if( ( loopingSample == NULL && leadinSample->openalBuffer != 0 ) || ( loopingSample != NULL && soundShader->entries[0]->hardwareBuffer ) ) if( leadinSample->openalBuffer != 0 ) { alSourcei( openalSource, AL_BUFFER, 0 ); // handle uncompressed (non streaming) single shot and looping sounds /* if( triggered ) { alSourcei( openalSource, AL_BUFFER, looping ? chan->soundShader->entries[0]->openalBuffer : leadinSample->openalBuffer ); } */ } else { //if( triggered ) // handle streaming sounds (decode on the fly) both single shot AND looping alSourcei( openalSource, AL_BUFFER, 0 ); alDeleteBuffers( 3, &lastopenalStreamingBuffer[0] ); lastopenalStreamingBuffer[0] = openalStreamingBuffer[0]; lastopenalStreamingBuffer[1] = openalStreamingBuffer[1]; lastopenalStreamingBuffer[2] = openalStreamingBuffer[2]; alGenBuffers( 3, &openalStreamingBuffer[0] ); /* if( soundSystemLocal.alEAXSetBufferMode ) { soundSystemLocal.alEAXSetBufferMode( 3, &chan->openalStreamingBuffer[0], alGetEnumValue( ID_ALCHAR "AL_STORAGE_ACCESSIBLE" ) ); } */ openalStreamingBuffer[0]; openalStreamingBuffer[1]; openalStreamingBuffer[2]; } if( s_debugHardware.GetBool() ) { if( loopingSample == NULL || loopingSample == leadinSample ) { idLib::Printf( "%dms: %i created for %s\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>" ); } else { idLib::Printf( "%dms: %i created for %s and %s\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>", loopingSample ? loopingSample->GetName() : "<null>" ); } } } sourceVoiceRate = sampleRate; //pSourceVoice->SetSourceSampleRate( sampleRate ); //pSourceVoice->SetVolume( 0.0f ); alSourcei( openalSource, AL_SOURCE_RELATIVE, AL_TRUE ); alSource3f( openalSource, AL_POSITION, 0.0f, 0.0f, 0.0f ); // RB: FIXME 0.0f ? alSourcef( openalSource, AL_GAIN, 1.0f ); //OnBufferStart( leadinSample, 0 ); }