void PauseTrack (void) { if (!sound_sample) return; // nothing to pause LockMutex (soundSource[SPEECH_SOURCE].stream_mutex); PauseStream (SPEECH_SOURCE); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); }
void PLRPause (MUSIC_REF MusicRef) { if (MusicRef == curMusicRef || MusicRef == (MUSIC_REF)~0) { LockMutex (soundSource[MUSIC_SOURCE].stream_mutex); PauseStream (MUSIC_SOURCE); UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex); } }
//播放功能接口 unsigned long GS_PauseStream(unsigned long nPort) { //线程暂停 ,清空音频播放缓冲区 PSTREAMCONFIG pm = GetStream(nPort); if(pm==NULL) { return S_FALSE; } if(PauseStream(pm->pContrlConfig)) { return S_OK; } return 0; }
void cSoundStreamRenderer::UpdateStreams() { RemoveUnmarkedBindings(); for(unsigned int i = 0; i < m_DataBindings.size(); ++i) { sStreamBinding &str = m_DataBindings[i]; if(!str.m_Source || !str.m_Stream) { ClearBinding(str); continue; } while(OpenAL::Get().GetProcessedBuffersCount(str.m_Source->Get()) > 0) { ALuint buffer = OpenAL::Get().PopBufferQueue(str.m_Source->Get()); str.m_RawBuffers.Return(buffer); } vSoundStreamProperties *props = dynamic_cast<vSoundStreamProperties*>(str.m_Stream->GetRenderingProperties()); if(!props) continue; switch(props->GetWantedState()) { case ESourceState::Playing: PlayStream(str); break; case ESourceState::Stopped: StopStream(str); break; case ESourceState::Paused: PauseStream(str); break; default: break; } } for(unsigned int i = 0; i < m_DataBindings.size(); ++i) { sStreamBinding &str = m_DataBindings[i]; vSoundStreamProperties *props = dynamic_cast<vSoundStreamProperties*>(str.m_Stream->GetRenderingProperties()); props->SetState(OpenAL::Get().GetSourceState(str.m_Source->Get())); str.m_Stream->Synchronize(props); } };
STDMETHODIMP CSampleMSPStream::SelectTerminal( IN ITTerminal * pTerminal ) { LOG((MSP_TRACE, "CSampleMSPStream::SelectTerminal - enter")); // // We are going to access the terminal list -- grab the lock // CLock lock(m_lock); // // Reject if we already have a terminal selected. // if ( 0 != m_Terminals.GetSize() ) { LOG((MSP_ERROR, "CSampleMSPStream::SelectTerminal - " "exit TAPI_E_MAXTERMINALS")); return TAPI_E_MAXTERMINALS; } // // Use base class method to add it to our list of terminals. // HRESULT hr = CMSPStream::SelectTerminal(pTerminal); if ( FAILED(hr) ) { LOG((MSP_ERROR, "CSampleMSPStream::SelectTerminal - " "base class method failed - exit 0x%08x", hr)); return hr; } // // Re-pause or re-start the stream if needed. // if ( m_DesiredGraphState == State_Paused ) { hr = PauseStream(); } else if ( m_DesiredGraphState == State_Running ) { hr = StartStream(); } else { _ASSERTE( m_DesiredGraphState == State_Stopped ); hr = S_OK; } if ( FAILED(hr) ) { LOG((MSP_TRACE, "CSampleMSPStream::SelectTerminal - " "can't regain old graph state - unselecting terminal - " "exit 0x%08x", hr)); // // Unselect it to undo all of the above. // UnselectTerminal(pTerminal); return hr; } LOG((MSP_TRACE, "CSampleMSPStream::SelectTerminal - exit S_OK")); return S_OK; }