void MediaObject::play() { if ((m_state == Phonon::PlayingState) && !m_paused && !m_stopped) return; if ((m_state == Phonon::LoadingState) || (m_state == Phonon::BufferingState) || (m_state == Phonon::ErrorState)) { setError(Phonon::FatalError, QLatin1String("illegale state for playback")); return; } if (m_state == Phonon::StoppedState) stop(); if (m_sourceIsValid) { setState(Phonon::PlayingState); if (!m_paused) { m_nextBufferIndex = true; m_stopped = false; playBuffer(m_soundBuffer1.waveHeader); playBuffer(m_soundBuffer2.waveHeader); } else { if (!(waveOutRestart(m_hWaveOut) == MMSYSERR_NOERROR)) setError(Phonon::NormalError, QLatin1String("cannot resume (system)")); } } else { setError(Phonon::FatalError, QLatin1String("cannot playback invalid source")); } m_paused = false; }
/* * Start stream. */ PJ_DEF(pj_status_t) pjmedia_snd_stream_start(pjmedia_snd_stream *stream) { MMRESULT mr; PJ_UNUSED_ARG(stream); if (stream->play_strm.hWave.Out != NULL) { mr = waveOutRestart(stream->play_strm.hWave.Out); if (mr != MMSYSERR_NOERROR) /* TODO: This macro is supposed to be used for HRESULT, fix. */ PJ_RETURN_OS_ERROR(mr); PJ_LOG(5,(THIS_FILE, "WMME playback stream started")); } if (stream->rec_strm.hWave.In != NULL) { mr = waveInStart(stream->rec_strm.hWave.In); if (mr != MMSYSERR_NOERROR) /* TODO: This macro is supposed to be used for HRESULT, fix. */ PJ_RETURN_OS_ERROR(mr); PJ_LOG(5,(THIS_FILE, "WMME capture stream started")); } return PJ_SUCCESS; }
void renderstart(void *hrender) { if (!hrender) return; RENDER *render = (RENDER*)hrender; waveOutRestart(render->hWaveOut); render->nRenderStatus &= ~RS_PAUSE; }
void SoundCardPMO::Resume(void) { if (m_initialized) waveOutRestart(m_hwo); PhysicalMediaOutput::Resume(); }
int Resume() { if (waveOutRestart(hWaveOut) != MMSYSERR_NOERROR) { MessageBox(NULL, L"Failed to Resume wave playback", L"MT32", MB_OK | MB_ICONEXCLAMATION); return 9; } return 0; }
static int set_pause(int flag) { static int paused; MMRESULT error; if (flag && !paused) { error = waveOutPause(wave_handle); if (error != MMSYSERR_NOERROR) { audio_error = error_text(error); return -1; } } else if (!flag && paused) { error = waveOutRestart(wave_handle); if (error != MMSYSERR_NOERROR) { audio_error = error_text(error); return -1; } } paused = flag; return 0; }
int EmuOutMod::Write(char *buf, int len) { ::WaitForSingleObject(m_mutex, INFINITE); int rest = m_buf_rest; ::ReleaseMutex(m_mutex); if(rest<len) return 1; waveOutSetVolume(m_hwo, (DWORD)(m_volume<<16)|m_volume); for(int i=0; i<len; i++) { m_buf[m_buf_idx%m_ring_size][m_buf_pos++] = buf[i]; rest--; if(m_buf_pos==m_buf_size) { waveOutPrepareHeader(m_hwo, &m_wh[m_buf_idx%m_ring_size], sizeof(WAVEHDR)) ; waveOutWrite(m_hwo, &m_wh[m_buf_idx%m_ring_size], sizeof(WAVEHDR)) ; if(m_playing) waveOutRestart(m_hwo); m_buf_pos = 0; m_buf_idx ++; //waveOutUnprepareHeader(m_hwo, &m_wh[m_buf_idx%m_ring_size], sizeof(WAVEHDR)); } } ::WaitForSingleObject(m_mutex, INFINITE); m_buf_rest -= len; ::ReleaseMutex(m_mutex); return 0; }
static int winwave_ctl_out (HWVoiceOut *hw, int cmd, ...) { MMRESULT mr; WaveVoiceOut *wave = (WaveVoiceOut *) hw; switch (cmd) { case VOICE_ENABLE: { va_list ap; int poll_mode; va_start (ap, cmd); poll_mode = va_arg (ap, int); va_end (ap); if (poll_mode && !wave->event) { wave->event = CreateEvent (NULL, TRUE, TRUE, NULL); if (!wave->event) { dolog ("DAC CreateEvent: %lx, poll mode will be disabled\n", GetLastError ()); } } if (wave->event) { int ret; ret = qemu_add_wait_object (wave->event, winwave_poll, wave); hw->poll_mode = (ret == 0); } else { hw->poll_mode = 0; } if (wave->paused) { mr = waveOutRestart (wave->hwo); if (mr != MMSYSERR_NOERROR) { winwave_logerr (mr, "waveOutRestart"); } wave->paused = 0; } } return 0; case VOICE_DISABLE: if (!wave->paused) { mr = waveOutPause (wave->hwo); if (mr != MMSYSERR_NOERROR) { winwave_logerr (mr, "waveOutPause"); } else { wave->paused = 1; } } if (wave->event) { qemu_del_wait_object (wave->event, winwave_poll, wave); } return 0; } return -1; }
void QAudioOutputPrivate::resume() { if(deviceState == QAudio::SuspendedState) { deviceState = QAudio::ActiveState; errorState = QAudio::NoError; waveOutRestart(hWaveOut); QTimer::singleShot(10, this, SLOT(feedback())); emit stateChanged(deviceState); } }
int EmuOutMod::Pause(int pause) { if(pause) { waveOutPause(m_hwo); m_playing = false; } else { waveOutRestart(m_hwo); m_playing = true; } return !pause; }
// Play audio, starting at a given frame/sample BOOL CALLBACK aviaudioPlay(HWND hwnd, PAVISTREAM pavi, LONG lStart, LONG lEnd, BOOL fWait) { if (audioPlayable <= 0) return FALSE; recalc = 1; //CString tx; //tx.Format("audioPlayable %d",audioPlayable); //MessageBox(NULL,tx,"Note",MB_OK); CString msx; if (lStart < 0) lStart = ::AVIStreamStart(pavi); if (lEnd < 0) lEnd = AVIStreamEnd(pavi); if (lStart >= lEnd) { return FALSE; } if (!aviaudioOpenDevice(hwnd, pavi)) { MessageBox(NULL,"AudioOpen failed","Note",MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (!sfPlaying) { // We're beginning play, so pause until we've filled the buffers // for a seamless start waveOutPause(shWaveOut); slBegin = lStart; slCurrent = lStart; slEnd = lEnd; sfPlaying = TRUE; } else { slEnd = lEnd; } aviaudioiFillBuffers(); // Now unpause the audio and away it goes! waveOutRestart(shWaveOut); // Caller wants us not to return until play is finished if (fWait) { while (swBuffersOut > 0) Yield(); } return TRUE; }
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) { HRESULT err = DS_OK; TRACE("(%p)\n", device); err = mmErr(waveOutRestart(device->hwo)); if (err != DS_OK) WARN("waveOutRestart failed\n"); return err; }
void audio_waveout::play(void) { MMRESULT err; unsigned int i; if (!main_buffer) { /* TODO; throw error, or assert */ return; } /* If the status is PAUSED, we have to resume the audio playing */ if (status == WAVEOUT_PAUSED) { /* Updates status */ status = WAVEOUT_PLAYING; /* Tells to the driver to resume audio playing */ waveOutRestart(waveout_handle); /* Wakeup playing thread */ SetEvent(wakeup_playthread); return; } /* if status == WAVEOUT_PAUSED */ if (status != WAVEOUT_READY) return; /* Prepares WAVEHDR structures */ prep_headers_(); /* Sets correct status */ status = WAVEOUT_PLAYING; /* Reads the audio from the start */ //audio_buf.set_position_start(); /* Reads the first N bytes from the audio buffer, where N = the total size of all little buffers */ audio_buf.read(main_buffer, mb_size); /* Wakeup the playing thread */ SetEvent(wakeup_playthread); /* Sends all the little buffers to the audio driver, so it can play the sound data */ for (i = 0; i < buffers; ++i) { err = waveOutWrite(waveout_handle, &wave_headers[i], sizeof(WAVEHDR)); if (err != MMSYSERR_NOERROR) { MessageBox(0, _T("waveOutWrite Error"), 0, 0); /* TODO: throw error */ } } }
MMRESULT TinyWaveOut::Restart() { if (hWaveOut == NULL) return S_FALSE; MMRESULT hRes = waveOutRestart(hWaveOut); if (hRes != MMSYSERR_NOERROR) { waveOutClose(hWaveOut); hWaveOut = NULL; return S_FALSE; } return S_OK; }
int cubeb_stream_start(cubeb_stream * stm) { MMRESULT r; r = waveOutRestart(stm->waveout); assert(r == MMSYSERR_NOERROR); stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STARTED); return CUBEB_OK; }
/** Resume playing after a pause */ int sa_stream_resume(sa_stream_t *s) { int status; ERROR_IF_NO_INIT(s); status = waveOutRestart(s->hWaveOut); HANDLE_WAVE_ERROR(status, "resuming audio playback"); s->playing = 1; return SA_SUCCESS; }
bool VDAudioOutputWaveOutW32::Start() { if (mCurState == kStateSilent) return true; if (mCurState < kStateOpened) return false; if (MMSYSERR_NOERROR != waveOutRestart(mhWaveOut)) return false; mCurState = kStatePlaying; return true; }
/*********************************************************************** * WaveLib_Pause * * Audio! * * Parameters * * * Return Value * Handle To This Audio Session * ***********************************************************************/ void WaveLib_Pause(HWAVELIB hWaveLib, BOOL bPause) { PWAVELIB pWaveLib = (PWAVELIB)hWaveLib; pWaveLib->bPaused = bPause; if(pWaveLib->bPaused) { waveOutPause(pWaveLib->hWaveOut); } else { waveOutRestart(pWaveLib->hWaveOut); } }
int WaveOut::Pause(int pause) { bool waspaused = _paused; if (pause) { if (!waspaused) waveOutPause(_device); _paused = true; } else { if (waspaused) waveOutRestart(_device); _paused = false; } return waspaused?1:0; }
void COutput::Pause(BOOL fPause) { if (!m_hwo) return; if (m_fDoubleBuf) m_fPaused = fPause; else { CAutoLock lock(&m_csecDevice); if (fPause) waveOutPause(m_hwo); else waveOutRestart(m_hwo); } }
static int winaudio_out_ctl (HWVoiceOut *hw, int cmd, ...) { WinAudioOut* s = (WinAudioOut*) hw; switch (cmd) { case VOICE_ENABLE: waveOutRestart( s->waveout ); break; case VOICE_DISABLE: waveOutPause( s->waveout ); break; } return 0; }
void native_midi_pause(int pauseon) //maks { static int pause = 0; if(hMidiStream) { if(pauseon && !pause) { waveOutPause(hMidiStream); pause = 1; } else if(!pauseon && pause) { waveOutRestart(hMidiStream); pause = 0; } } }
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) { HRESULT err = DS_OK; TRACE("(%p)\n", device); if (device->hwbuf) { err = IDsDriverBuffer_Play(device->hwbuf, 0, 0, DSBPLAY_LOOPING); if (err != DS_OK) WARN("IDsDriverBuffer_Play failed\n"); } else { err = mmErr(waveOutRestart(device->hwo)); if (err != DS_OK) WARN("waveOutRestart failed\n"); } return err; }
int cubeb_stream_start(cubeb_stream * stm) { MMRESULT r; EnterCriticalSection(&stm->lock); r = waveOutRestart(stm->waveout); LeaveCriticalSection(&stm->lock); if (r != MMSYSERR_NOERROR) { return CUBEB_ERROR; } stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STARTED); return CUBEB_OK; }
int playsound(AUDIO_t *audio) { if (audio->init == 0) { soundinit(audio); } else { int i,b; audio->PlayTime = tc_elapsed(audio->timer_c) - (BankTime * ((float)BufferBanks)); audio->PlayPnt = (audio->CurPnt-(PreferedSamples * BufferBanks)) % BufferSamples; for(b = 0; b < BufferBanks; b++) { for(i = 0; i < PreferedSamples; i++) { audio->playbuf[b][i].left = 0x80; audio->playbuf[b][i].right = 0x80; } } waveOutRestart(audio->hWaveOut); audio->enabled = 1; } return 0; }
int playsound(AUDIO_t *audio) { if (audio->init == 0) { soundinit(audio); } else { audio->PlayTime = audio->timer_c->elapsed - (BANK_TIME * ((float)BUFFER_BANKS)); audio->PlayPnt = (audio->CurPnt - (PREFERED_SAMPLES * BUFFER_BANKS)) % BUFFER_SMAPLES; for (int b = 0; b < BUFFER_BANKS; b++) { for (int i = 0; i < PREFERED_SAMPLES; i++) { audio->playbuf[b][i].left = 0x80; audio->playbuf[b][i].right = 0x80; } } #ifdef _WINDOWS waveOutRestart(audio->hWaveOut); #endif audio->enabled = TRUE; } return 0; }
static void WAV_Play(GF_AudioOutput *dr, u32 PlayType) { #if 0 u32 i; WAVCTX(); switch (PlayType) { case 0: waveOutPause(ctx->hwo); break; case 2: for (i=0; i<ctx->num_buffers; i++) { LPWAVEHDR hdr = &ctx->wav_hdr[i]; memset(&hdr->lpData, 0, sizeof(char)*ctx->buffer_size); } case 1: waveOutRestart(ctx->hwo); break; } #endif }
/*************************************************************************** * MCIAVI_mciResume [internal] */ static DWORD MCIAVI_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { WINE_MCIAVI *wma; TRACE("(%04x, %08X, %p)\n", wDevID, dwFlags, lpParms); wma = MCIAVI_mciGetOpenDev(wDevID); if (wma == NULL) return MCIERR_INVALID_DEVICE_ID; if (dwFlags & MCI_TEST) return 0; EnterCriticalSection(&wma->cs); if (wma->dwStatus == MCI_MODE_PAUSE) wma->dwStatus = MCI_MODE_PLAY; if (wma->lpWaveFormat) { LeaveCriticalSection(&wma->cs); return waveOutRestart(wma->hWave); } LeaveCriticalSection(&wma->cs); return 0; }
int pcm_submit() { if (!sound || !wout) { pcm.pos = 0; return 0; } if (pcm.pos) { hdr[curbuf].dwBufferLength = pcm.pos * cb_per_sample; hdr[curbuf].dwBytesRecorded = pcm.pos * cb_per_sample; waveOutPrepareHeader(wout, &hdr[curbuf], sizeof WAVEHDR); waveOutWrite(wout, &hdr[curbuf], sizeof WAVEHDR); total_bytes += pcm.pos * cb_per_sample; if (soundresume) waveOutRestart(wout); if (g_fThrottling) { int start = timer_time_in_msec(); if (WaitForSingleObject(semaph, WOUT_TIMEOUT) == WAIT_TIMEOUT) { waveOutReset(wout); while (ReleaseSemaphore(semaph, 1, NULL)); waveOutPause(wout); soundresume = 1; } last_wait_time += timer_time_in_msec() - start; } curbuf = (curbuf + 1) % buffers; pcm.buf = buf + pcm.len * curbuf * cb_per_sample; pcm.pos = 0; } return 0; }
void PauseStream(bool PauseOn) { UINT32 RetVal; if (! WaveOutOpen) return; // Thread is not active #ifdef WIN32 switch(PauseOn) { case true: RetVal = waveOutPause(hWaveOut); break; case false: RetVal = waveOutRestart(hWaveOut); break; } StreamPause = PauseOn; #else PauseThread = PauseOn; #endif return; }