bool DecodedStream::IsPlaying() const { AssertOwnerThread(); return IsStarted() && mPlaying; }
void Config::SetSocketPort(unsigned short port) { BEHAVIAC_ASSERT(!IsStarted(), "please call Config::SetSocketPort at the very beginning before behaviac::Start!"); ms_socketPort = port; }
void Config::SetHotReload(bool bHotReload) { BEHAVIAC_ASSERT(!IsStarted(), "please call Config::SetSocketBlocking at the very beginning before behaviac::Start!"); ms_bHotReload = bHotReload; }
void Config::SetSocketBlocking(bool bBlocking) { BEHAVIAC_ASSERT(!IsStarted(), "please call Config::SetSocketBlocking at the very beginning before behaviac::Start!"); ms_bSocketIsBlocking = bBlocking; }
void C4PortraitSelDlg::LoaderThread::AddLoadItem(ListItem *pItem) { // not to be called when thread is running! assert(!IsStarted()); LoadItems.push_back(pItem); }
bool AudioSinkWrapper::IsPlaying() const { AssertOwnerThread(); return IsStarted() && !mPlayStartTime.IsNull(); }
long AudioCallbackDriver::DataCallback(AudioDataValue* aBuffer, long aFrames) { bool stillProcessing; if (mPauseRequested) { PodZero(aBuffer, aFrames * mGraphImpl->AudioChannelCount()); return aFrames; } DebugOnly<AutoInCallback> aic(AutoInCallback(this)); if (mStateComputedTime == 0) { MonitorAutoLock mon(mGraphImpl->GetMonitor()); // Because this function is called during cubeb_stream_init (to prefill the // audio buffers), it can be that we don't have a message here (because this // driver is the first one for this graph), and the graph would exit. Simply // return here until we have messages. if (!mGraphImpl->MessagesQueued()) { PodZero(aBuffer, aFrames * mGraphImpl->AudioChannelCount()); return aFrames; } mGraphImpl->SwapMessageQueues(); } uint32_t durationMS = aFrames * 1000 / mSampleRate; // For now, simply average the duration with the previous // duration so there is some damping against sudden changes. if (!mIterationDurationMS) { mIterationDurationMS = durationMS; } else { mIterationDurationMS += durationMS; mIterationDurationMS /= 2; } mBuffer.SetBuffer(aBuffer, aFrames); mScratchBuffer.Empty(mBuffer); mStateComputedTime = mNextStateComputedTime; // State computed time is decided by the audio callback's buffer length. We // compute the iteration start and end from there, trying to keep the amount // of buffering in the graph constant. mNextStateComputedTime = mGraphImpl->RoundUpToNextAudioBlock(mStateComputedTime + mBuffer.Available()); mIterationStart = mIterationEnd; // inGraph is the number of audio frames there is between the state time and // the current time, i.e. the maximum theoretical length of the interval we // could use as [mIterationStart; mIterationEnd]. GraphTime inGraph = mStateComputedTime - mIterationStart; // We want the interval [mIterationStart; mIterationEnd] to be before the // interval [mStateComputedTime; mNextStateComputedTime]. We also want // the distance between these intervals to be roughly equivalent each time, to // ensure there is no clock drift between current time and state time. Since // we can't act on the state time because we have to fill the audio buffer, we // reclock the current time against the state time, here. mIterationEnd = mIterationStart + 0.8 * inGraph; STREAM_LOG(PR_LOG_DEBUG, ("interval[%ld; %ld] state[%ld; %ld] (frames: %ld) (durationMS: %u) (duration ticks: %ld)\n", (long)mIterationStart, (long)mIterationEnd, (long)mStateComputedTime, (long)mNextStateComputedTime, (long)aFrames, (uint32_t)durationMS, (long)(mNextStateComputedTime - mStateComputedTime))); mCurrentTimeStamp = TimeStamp::Now(); if (mStateComputedTime < mIterationEnd) { STREAM_LOG(PR_LOG_WARNING, ("Media graph global underrun detected")); mIterationEnd = mStateComputedTime; } stillProcessing = mGraphImpl->OneIteration(mIterationStart, mIterationEnd, mStateComputedTime, mNextStateComputedTime); mBuffer.BufferFilled(); if (mNextDriver && stillProcessing) { { // If the audio stream has not been started by the previous driver or // the graph itself, keep it alive. MonitorAutoLock mon(mGraphImpl->GetMonitor()); if (!IsStarted()) { return aFrames; } } STREAM_LOG(PR_LOG_DEBUG, ("Switching to system driver.")); mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd, mStateComputedTime, mNextStateComputedTime); mGraphImpl->SetCurrentDriver(mNextDriver); mNextDriver->Start(); // Returning less than aFrames starts the draining and eventually stops the // audio thread. This function will never get called again. return aFrames - 1; } if (!stillProcessing) { LIFECYCLE_LOG("Stopping audio thread for MediaStreamGraph %p", this); return aFrames - 1; } return aFrames; }
CString CDownload::GetDownloadStatus() const { CString strText; if ( m_bClearing ) // Briefly marked for removal { LoadString( strText, IDS_STATUS_CLEARING ); } else if ( IsPaused() ) { if ( GetFileError() == ERROR_SUCCESS || IsSeeding() ) LoadString( strText, IDS_STATUS_PAUSED ); else LoadString( strText, IsMoving() ? IDS_STATUS_CANTMOVE : IDS_STATUS_FILEERROR ); } else if ( IsCompleted() ) { if ( IsSeeding() ) LoadString( strText, m_bTorrentTrackerError ? IDS_STATUS_TRACKERDOWN : IDS_STATUS_SEEDING ); else LoadString( strText, IDS_STATUS_COMPLETED ); } else if ( IsMoving() ) { LoadString( strText, IDS_STATUS_MOVING ); } else if ( IsStarted() && GetProgress() == 100.0f ) { LoadString( strText, IDS_STATUS_VERIFYING ); } else if ( ! IsTrying() ) { LoadString( strText, IDS_STATUS_QUEUED ); } else if ( IsDownloading() ) { const DWORD nTime = GetTimeRemaining(); if ( nTime == 0xFFFFFFFF ) LoadString( strText, IDS_STATUS_ACTIVE ); // IDS_STATUS_DOWNLOADING else if ( nTime == 0 ) LoadString( strText, IDS_STATUS_DOWNLOADING ); else if ( nTime > 86400 ) strText.Format( L"%u:%.2u:%.2u:%.2u", nTime / 86400, ( nTime / 3600 ) % 24, ( nTime / 60 ) % 60, nTime % 60 ); else strText.Format( L"%u:%.2u:%.2u", nTime / 3600, ( nTime / 60 ) % 60, nTime % 60 ); } else if ( GetEffectiveSourceCount() > 0 ) { LoadString( strText, IDS_STATUS_PENDING ); } else if ( IsTorrent() ) { if ( GetTaskType() == dtaskAllocate ) LoadString( strText, IDS_STATUS_CREATING ); else if ( m_bTorrentTrackerError ) LoadString( strText, IDS_STATUS_TRACKERDOWN ); else LoadString( strText, IDS_STATUS_TORRENT ); } else // Inactive { LoadString( strText, IDS_STATUS_QUEUED ); } return strText; }