bool SFXSound::_releaseVoice() { if( !mVoice ) return true; // Refuse to release a voice for a streaming buffer that // is not coming from a profile. For streaming buffers, we will // have to release the buffer, too, and without a profile we don't // know how to recreate the stream. if( isStreaming() && !mTrack ) return false; // If we're currently playing, transfer our playback position // to the playtimer so we can virtualize playback while not // having a voice. SFXStatus status = getLastStatus(); if( status == SFXStatusPlaying || status == SFXStatusBlocked ) { // Sync up the play timer with the voice's current position to make // sure we handle any lag that's cropped up. mPlayTimer.setPosition( mVoice->getPosition() ); if( status == SFXStatusBlocked ) status = SFXStatusPlaying; } mVoice = NULL; // If this is a streaming source, release our buffer, too. // Otherwise the voice will stick around as it is uniquely assigned to // the buffer. When we get reassigned a voice, we will have to do // a full stream seek anyway, so it's no real loss here. if( isStreaming() ) mBuffer = NULL; #ifdef DEBUG_SPEW Platform::outputDebugString( "[SFXSound] release voice for source '%i' (status: %s)", getId(), SFXStatusToString( status ) ); #endif return true; }
void Webcam::close_device() { if( isStreaming() ) stop_capturing(); if( fd != -1 ) close(fd); //assure fd=-1; }
DriverFrame* Camera::grabTemporaryFrame() { if(!isStreaming() && !streamOn()) { fprintf(stderr, "Camera could not grab frame: streaming could not be turned on.\n"); return NULL; } if(buffers == NULL) { setupBuffers(); } return buffers->grabTemporaryFrame(); }
void WpiClient::stop() { if (isStreaming()) { m_stopReceive = true; // Cancel any currently blocking operations send(m_cancelfdw, "U", 1, 0); } // Close the receive thread if (m_recvThread.joinable()) { m_recvThread.join(); } }
void WpiClient::start() { if (!isStreaming()) { // if stream is closed, reopen it // Join previous thread before making a new one if (m_recvThread.joinable()) { m_recvThread.join(); } // Mark the thread as running m_stopReceive = false; m_recvThread = std::thread(&WpiClient::recvFunc, this); } }
SFXWrapAroundBuffer::SFXWrapAroundBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description ) : Parent( stream, description ), mWriteOffset( 0 ) { // Determine the device buffer metrics. const U32 maxQueuedPackets = isStreaming() ? SFXAsyncQueue::DEFAULT_STREAM_QUEUE_LENGTH : 1; const U32 packetSize = mAsyncState->mStream->getPacketSize(); mBufferSize = maxQueuedPackets * packetSize; #ifdef DEBUG_SPEW Platform::outputDebugString( "[SFXWrapAroundBuffer] size=%i, packets=%i", mBufferSize, maxQueuedPackets ); #endif // For streaming buffers that are not looping, add a packet of silence to the // source stream. if( isStreaming() && !description->mIsLooping ) mAsyncState->mStream->setReadSilenceAtEnd( true ); }