From: <man...@us...> - 2013-11-19 23:54:20
|
Revision: 3273 http://sourceforge.net/p/modplug/code/3273 Author: manxorist Date: 2013-11-19 23:54:14 +0000 (Tue, 19 Nov 2013) Log Message: ----------- [Fix] sounddev: Allow ISoundDevice::Start to fail. This allows IsPlaying() to return false after Start failed which causes the using code to not be confused about the actual playback state. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h trunk/OpenMPT/sounddev/SoundDevices.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-19 23:54:14 UTC (rev 3273) @@ -1180,7 +1180,7 @@ { if(!m_pSndFile) return false; // nothing to play if(!IsAudioDeviceOpen()) return false; - gpSoundDevice->Start(); + if(!gpSoundDevice->Start()) return false; if(!m_NotifyTimer) { m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().m_UpdateIntervalMS, NULL); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-19 23:54:14 UTC (rev 3273) @@ -184,10 +184,10 @@ } -void ISoundDevice::Start() +bool ISoundDevice::Start() //------------------------ { - if(!IsOpen()) return; + if(!IsOpen()) return false; if(!IsPlaying()) { { @@ -196,9 +196,13 @@ m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } - InternalStart(); + if(!InternalStart()) + { + return false; + } m_IsPlaying = true; } + return true; } @@ -632,10 +636,11 @@ } -void CSoundDeviceWithThread::InternalStart() +bool CSoundDeviceWithThread::InternalStart() //------------------------------------------ { m_AudioThread.Activate(); + return true; } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-19 23:54:14 UTC (rev 3273) @@ -277,7 +277,7 @@ virtual bool InternalIsOpen() const = 0; virtual bool InternalOpen() = 0; - virtual void InternalStart() = 0; + virtual bool InternalStart() = 0; virtual void InternalStop() = 0; virtual bool InternalClose() = 0; @@ -300,7 +300,7 @@ bool Open(const SoundDeviceSettings &settings); bool Close(); - void Start(); + bool Start(); void Stop(); bool IsOpen() const { return InternalIsOpen(); } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-11-19 23:54:14 UTC (rev 3273) @@ -383,7 +383,7 @@ } -void CASIODevice::InternalStart() +bool CASIODevice::InternalStart() //------------------------------- { ALWAYS_ASSERT_WARN_MESSAGE(!CriticalSection::IsLocked(), "AudioCriticalSection locked while starting ASIO"); @@ -402,11 +402,13 @@ { CASIODevice::ReportASIOException("ASIO crash in start()\n"); m_bMixRunning = FALSE; + return false; } } else { SetRenderSilence(false, true); } + return true; } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-11-19 23:54:14 UTC (rev 3273) @@ -57,7 +57,7 @@ bool InternalOpen(); bool InternalClose(); void FillAudioBuffer(); - void InternalStart(); + bool InternalStart(); void InternalStop(); bool InternalIsOpen() const { return (m_pAsioDrv != nullptr); } Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-19 23:54:14 UTC (rev 3273) @@ -122,10 +122,10 @@ } -void CPortaudioDevice::InternalStart() +bool CPortaudioDevice::InternalStart() //------------------------------------ { - Pa_StartStream(m_Stream); + return Pa_StartStream(m_Stream) == paNoError; } Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2013-11-19 23:54:14 UTC (rev 3273) @@ -47,7 +47,7 @@ bool InternalOpen(); bool InternalClose(); void FillAudioBuffer(); - void InternalStart(); + bool InternalStart(); void InternalStop(); bool InternalIsOpen() const { return m_Stream ? true : false; } double GetCurrentLatency() const; Modified: trunk/OpenMPT/sounddev/SoundDevices.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevices.h 2013-11-19 23:31:49 UTC (rev 3272) +++ trunk/OpenMPT/sounddev/SoundDevices.h 2013-11-19 23:54:14 UTC (rev 3273) @@ -69,7 +69,7 @@ public: CSoundDeviceWithThread(SoundDeviceID id, const std::wstring &internalID) : ISoundDevice(id, internalID), m_AudioThread(*this) {} virtual ~CSoundDeviceWithThread() {} - void InternalStart(); + bool InternalStart(); void InternalStop(); virtual void StartFromSoundThread() = 0; virtual void StopFromSoundThread() = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |