From: <man...@us...> - 2015-02-11 14:36:17
|
Revision: 4750 http://sourceforge.net/p/modplug/code/4750 Author: manxorist Date: 2015-02-11 14:36:10 +0000 (Wed, 11 Feb 2015) Log Message: ----------- [Ref] sounddev: Remove redundant state in m_BufferAttributes. [Ref] sounddev: Merge GetCurrentLatency and GetCurrentUpdateInterval into GetStatistics. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.h trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.h trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp trunk/OpenMPT/sounddev/SoundDeviceWaveout.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -1164,7 +1164,7 @@ m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().GUIUpdateInterval, NULL); } else { - m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetBufferAttributes().UpdateInterval * 1000.0)), NULL); + m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetEffectiveBufferAttributes().UpdateInterval * 1000.0)), NULL); } } return true; Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -894,21 +894,20 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) { - const SoundDevice::BufferAttributes bufferAttributes = pMainFrm->gpSoundDevice->GetBufferAttributes(); - const double currentLatency = pMainFrm->gpSoundDevice->GetCurrentLatency(); - const double currentUpdateInterval = pMainFrm->gpSoundDevice->GetCurrentUpdateInterval(); + const SoundDevice::BufferAttributes bufferAttributes = pMainFrm->gpSoundDevice->GetEffectiveBufferAttributes(); + const SoundDevice::Statistics stats = pMainFrm->gpSoundDevice->GetStatistics(); const uint32 samplerate = pMainFrm->gpSoundDevice->GetSettings().Samplerate; mpt::ustring s; if(bufferAttributes.NumBuffers > 2) { - s += mpt::String::Print(MPT_USTRING("Buffer: %1%% (%2/%3)\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0, (currentUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / currentUpdateInterval) : 0, bufferAttributes.NumBuffers); + s += mpt::String::Print(MPT_USTRING("Buffer: %1%% (%2/%3)\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(stats.InstantaneousLatency / bufferAttributes.Latency * 100.0) : 0, (stats.LastUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / stats.LastUpdateInterval) : 0, bufferAttributes.NumBuffers); } else { - s += mpt::String::Print(MPT_USTRING("Buffer: %1%%\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0); + s += mpt::String::Print(MPT_USTRING("Buffer: %1%%\r\n"), (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(stats.InstantaneousLatency / bufferAttributes.Latency * 100.0) : 0); } - s += mpt::String::Print(MPT_USTRING("Latency: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.Latency * 1000.0), mpt::ufmt::f("%4.1f", currentLatency * 1000.0), Util::Round<int64>(currentLatency * samplerate)); - s += mpt::String::Print(MPT_USTRING("Period: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.UpdateInterval * 1000.0), mpt::ufmt::f("%4.1f", currentUpdateInterval * 1000.0), Util::Round<int64>(currentUpdateInterval * samplerate)); - s += pMainFrm->gpSoundDevice->GetStatistics(); + s += mpt::String::Print(MPT_USTRING("Latency: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.Latency * 1000.0), mpt::ufmt::f("%4.1f", stats.InstantaneousLatency * 1000.0), Util::Round<int64>(stats.InstantaneousLatency * samplerate)); + s += mpt::String::Print(MPT_USTRING("Period: %1 ms (current: %2 ms, %3 frames)\r\n"), mpt::ufmt::f("%4.1f", bufferAttributes.UpdateInterval * 1000.0), mpt::ufmt::f("%4.1f", stats.LastUpdateInterval * 1000.0), Util::Round<int64>(stats.LastUpdateInterval * samplerate)); + s += stats.text; m_EditStatistics.SetWindowText(mpt::ToCString(s)); } else { Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -142,10 +142,6 @@ m_DeviceUnavailableOnOpen = false; - m_BufferAttributes.Latency = m_Settings.Latency; - m_BufferAttributes.UpdateInterval = m_Settings.UpdateInterval; - m_BufferAttributes.NumBuffers = 0; - m_IsPlaying = false; m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; @@ -206,14 +202,6 @@ } -void Base::UpdateBufferAttributes(SoundDevice::BufferAttributes attributes) -//------------------------------------------------------------------------- -{ - MPT_TRACE(); - m_BufferAttributes = attributes; -} - - void Base::UpdateTimeInfo(SoundDevice::TimeInfo timeInfo) //------------------------------------------------------- { @@ -265,9 +253,6 @@ } m_Flags = SoundDevice::Flags(); m_DeviceUnavailableOnOpen = false; - m_BufferAttributes.Latency = m_Settings.Latency; - m_BufferAttributes.UpdateInterval = m_Settings.UpdateInterval; - m_BufferAttributes.NumBuffers = 0; m_RequestFlags.store(0); return InternalOpen(); } @@ -324,7 +309,7 @@ Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); timeInfo.StreamFrames = m_StreamPositionRenderFrames + numFrames; } - timeInfo.SystemTimestamp = Clock().NowNanoseconds() + Util::Round<int64>(m_BufferAttributes.Latency * 1000000000.0); + timeInfo.SystemTimestamp = Clock().NowNanoseconds() + Util::Round<int64>(GetEffectiveBufferAttributes().Latency * 1000000000.0); timeInfo.Speed = 1.0; UpdateTimeInfo(timeInfo); } @@ -339,7 +324,7 @@ { return; } - m_Source->AudioRead(m_Settings, m_Flags, m_BufferAttributes, m_TimeInfo, numFrames, buffer); + m_Source->AudioRead(m_Settings, m_Flags, GetEffectiveBufferAttributes(), m_TimeInfo, numFrames, buffer); } @@ -359,7 +344,7 @@ m_StreamPositionOutputFrames = m_StreamPositionRenderFrames - framesLatency; framesRendered = m_StreamPositionRenderFrames; } - m_Source->AudioDone(m_Settings, m_Flags, m_BufferAttributes, m_TimeInfo, numFrames, framesRendered); + m_Source->AudioDone(m_Settings, m_Flags, GetEffectiveBufferAttributes(), m_TimeInfo, numFrames, framesRendered); } @@ -427,8 +412,8 @@ } -double Base::GetCurrentUpdateInterval() const -//------------------------------------------- +double Base::GetLastUpdateInterval() const +//---------------------------------------- { MPT_TRACE(); Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); @@ -452,6 +437,18 @@ } +SoundDevice::Statistics Base::GetStatistics() const +//------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = m_Settings.Latency; + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + } // namespace SoundDevice Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -450,6 +450,20 @@ MPT_DECLARE_ENUM(RequestFlags) +struct Statistics +{ + double InstantaneousLatency; + double LastUpdateInterval; + mpt::ustring text; + Statistics() + : InstantaneousLatency(0.0) + , LastUpdateInterval(0.0) + { + return; + } +}; + + //========= class IBase //========= @@ -495,19 +509,15 @@ virtual SoundDevice::Settings GetSettings() const = 0; virtual SampleFormat GetActualSampleFormat() const = 0; + virtual SoundDevice::BufferAttributes GetEffectiveBufferAttributes() const = 0; - virtual SoundDevice::BufferAttributes GetBufferAttributes() const = 0; virtual SoundDevice::TimeInfo GetTimeInfo() const = 0; + virtual int64 GetStreamPositionFrames() const = 0; // Informational only, do not use for timing. // Use GetStreamPositionFrames() for timing - virtual double GetCurrentLatency() const = 0; - virtual double GetCurrentUpdateInterval() const = 0; + virtual SoundDevice::Statistics GetStatistics() const = 0; - virtual int64 GetStreamPositionFrames() const = 0; - - virtual mpt::ustring GetStatistics() const = 0; - virtual bool OpenDriverSettings() = 0; }; @@ -538,8 +548,6 @@ private: - SoundDevice::BufferAttributes m_BufferAttributes; - bool m_IsPlaying; Util::MultimediaClock m_Clock; @@ -579,7 +587,6 @@ const Util::MultimediaClock & Clock() const { return m_Clock; } - void UpdateBufferAttributes(SoundDevice::BufferAttributes attributes); void UpdateTimeInfo(SoundDevice::TimeInfo timeInfo); virtual bool InternalHasTimeInfo() const { return false; } @@ -597,6 +604,10 @@ virtual SoundDevice::Caps InternalGetDeviceCaps() = 0; + virtual SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const = 0; + + double GetLastUpdateInterval() const; + protected: Base(SoundDevice::Info info); @@ -630,16 +641,12 @@ SoundDevice::Settings GetSettings() const { return m_Settings; } SampleFormat GetActualSampleFormat() const { return IsOpen() ? m_Settings.sampleFormat : SampleFormatInvalid; } + SoundDevice::BufferAttributes GetEffectiveBufferAttributes() const { return (IsOpen() && IsPlaying()) ? InternalGetEffectiveBufferAttributes() : SoundDevice::BufferAttributes(); } - SoundDevice::BufferAttributes GetBufferAttributes() const { return m_BufferAttributes; } SoundDevice::TimeInfo GetTimeInfo() const { return m_TimeInfo; } - - virtual double GetCurrentLatency() const { return m_BufferAttributes.Latency; } - double GetCurrentUpdateInterval() const; - int64 GetStreamPositionFrames() const; - virtual mpt::ustring GetStatistics() const { return mpt::ustring(); } + virtual SoundDevice::Statistics GetStatistics() const; virtual bool OpenDriverSettings() { return false; }; Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -198,6 +198,7 @@ MPT_TRACE(); m_pAsioDrv = nullptr; + m_BufferLatency = 0.0; m_nAsioBufferLen = 0; m_BufferInfo.clear(); MemsetZero(m_Callbacks); @@ -475,7 +476,6 @@ //------------------------------- { MPT_TRACE(); - SoundDevice::BufferAttributes bufferAttributes; long inputLatency = 0; long outputLatency = 0; try @@ -489,15 +489,12 @@ } if(outputLatency >= (long)m_nAsioBufferLen) { - bufferAttributes.Latency = (double)(outputLatency + m_nAsioBufferLen) / (double)m_Settings.Samplerate; // ASIO and OpenMPT semantics of 'latency' differ by one chunk/buffer + m_BufferLatency = (double)(outputLatency + m_nAsioBufferLen) / (double)m_Settings.Samplerate; // ASIO and OpenMPT semantics of 'latency' differ by one chunk/buffer } else { // pointless value returned from asio driver, use a sane estimate - bufferAttributes.Latency = 2.0 * (double)m_nAsioBufferLen / (double)m_Settings.Samplerate; + m_BufferLatency = 2.0 * (double)m_nAsioBufferLen / (double)m_Settings.Samplerate; } - bufferAttributes.UpdateInterval = (double)m_nAsioBufferLen / (double)m_Settings.Samplerate; - bufferAttributes.NumBuffers = 2; - UpdateBufferAttributes(bufferAttributes); } @@ -654,6 +651,7 @@ MemsetZero(m_Callbacks); m_BufferInfo.clear(); m_nAsioBufferLen = 0; + m_BufferLatency = 0.0; CloseDriver(); @@ -1044,6 +1042,17 @@ } +SoundDevice::BufferAttributes CASIODevice::InternalGetEffectiveBufferAttributes() const +//------------------------------------------------------------------------------------- +{ + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_BufferLatency; + bufferAttributes.UpdateInterval = static_cast<double>(m_nAsioBufferLen) / static_cast<double>(m_Settings.Samplerate); + bufferAttributes.NumBuffers = 2; + return bufferAttributes; +} + + void CASIODevice::UpdateTimeInfo(AsioTimeInfo asioTimeInfo) //--------------------------------------------------------- { @@ -1070,7 +1079,7 @@ const uint64 asioNow = Clock().NowNanoseconds(); SoundDevice::TimeInfo timeInfo; timeInfo.StreamFrames = m_TotalFramesWritten + m_nAsioBufferLen - m_StreamPositionOffset; - timeInfo.SystemTimestamp = asioNow + Util::Round<int64>(GetBufferAttributes().Latency * 1000.0 * 1000.0 * 1000.0); + timeInfo.SystemTimestamp = asioNow + Util::Round<int64>(m_BufferLatency * 1000.0 * 1000.0 * 1000.0); timeInfo.Speed = 1.0; SoundDevice::Base::UpdateTimeInfo(timeInfo); } @@ -1190,24 +1199,31 @@ } -mpt::ustring CASIODevice::GetStatistics() const -//--------------------------------------------- +SoundDevice::Statistics CASIODevice::GetStatistics() const +//-------------------------------------------------------- { MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = m_BufferLatency; + result.LastUpdateInterval = static_cast<double>(m_nAsioBufferLen) / static_cast<double>(m_Settings.Samplerate); + result.text = mpt::ustring(); const FlagSet<AsioFeatures> unsupported(AsioFeatureNoDirectProcess | AsioFeatureOverload | AsioFeatureBufferSizeChange | AsioFeatureSampleRateChange); FlagSet<AsioFeatures> unsupportedFeatues = m_UsedFeatures; unsupportedFeatues &= unsupported; if(unsupportedFeatues.any()) { - return mpt::String::Print(MPT_USTRING("WARNING: unsupported features: %1"), AsioFeaturesToString(unsupportedFeatues)); + result.text = mpt::String::Print(MPT_USTRING("WARNING: unsupported features: %1"), AsioFeaturesToString(unsupportedFeatues)); } else if(m_UsedFeatures.any()) { - return mpt::String::Print(MPT_USTRING("OK, features used: %1"), AsioFeaturesToString(m_UsedFeatures)); + result.text = mpt::String::Print(MPT_USTRING("OK, features used: %1"), AsioFeaturesToString(m_UsedFeatures)); } else if(m_QueriedFeatures.any()) { - return mpt::String::Print(MPT_USTRING("OK, features queried: %1"), AsioFeaturesToString(m_QueriedFeatures)); + result.text = mpt::String::Print(MPT_USTRING("OK, features queried: %1"), AsioFeaturesToString(m_QueriedFeatures)); + } else + { + result.text = MPT_USTRING("OK."); } - return MPT_USTRING("OK."); + return result; } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -53,6 +53,7 @@ IASIO *m_pAsioDrv; + double m_BufferLatency; long m_nAsioBufferLen; std::vector<ASIOBufferInfo> m_BufferInfo; ASIOCallbacks m_Callbacks; @@ -117,7 +118,7 @@ bool OpenDriverSettings(); - mpt::ustring GetStatistics() const; + SoundDevice::Statistics GetStatistics() const; public: static std::vector<SoundDevice::Info> EnumerateDevices(); @@ -131,6 +132,8 @@ bool InternalHasGetStreamPosition() const; int64 InternalGetStreamPositionFrames() const; + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + protected: long AsioMessage(long selector, long value, void* message, double* opt); void SampleRateDidChange(ASIOSampleRate sRate); Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -301,11 +301,6 @@ m_dwWritePos = 0xFFFFFFFF; SetWakeupInterval(std::min(m_Settings.UpdateInterval, m_nDSoundBufferSize / (2.0 * m_Settings.GetBytesPerSecond()))); m_Flags.NeedsClippedFloat = mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista); - SoundDevice::BufferAttributes bufferAttributes; - bufferAttributes.Latency = m_nDSoundBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); - bufferAttributes.UpdateInterval = std::min(m_Settings.UpdateInterval, m_nDSoundBufferSize / (2.0 * m_Settings.GetBytesPerSecond())); - bufferAttributes.NumBuffers = 1; - UpdateBufferAttributes(bufferAttributes); return true; } @@ -486,6 +481,29 @@ } +SoundDevice::BufferAttributes CDSoundDevice::InternalGetEffectiveBufferAttributes() const +//--------------------------------------------------------------------------------------- +{ + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_nDSoundBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); + bufferAttributes.UpdateInterval = std::min(m_Settings.UpdateInterval, m_nDSoundBufferSize / (2.0 * m_Settings.GetBytesPerSecond())); + bufferAttributes.NumBuffers = 1; + return bufferAttributes; +} + + +SoundDevice::Statistics CDSoundDevice::GetStatistics() const +//---------------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = 1.0 * m_dwLatency / m_Settings.GetBytesPerSecond(); + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + #endif // NO_DIRECTSOUND Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -53,7 +53,8 @@ void StartFromSoundThread(); void StopFromSoundThread(); bool InternalIsOpen() const { return (m_pMixBuffer != NULL); } - double GetCurrentLatency() const { return 1.0 * m_dwLatency / m_Settings.GetBytesPerSecond(); } + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + SoundDevice::Statistics GetStatistics() const; SoundDevice::Caps InternalGetDeviceCaps(); SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -131,11 +131,6 @@ m_Stream = 0; return false; } - SoundDevice::BufferAttributes bufferAttributes; - bufferAttributes.Latency = m_StreamInfo->outputLatency; - bufferAttributes.UpdateInterval = m_Settings.UpdateInterval; - bufferAttributes.NumBuffers = 1; - UpdateBufferAttributes(bufferAttributes); return true; } @@ -145,11 +140,12 @@ { if(m_Stream) { + const SoundDevice::BufferAttributes bufferAttributes = GetEffectiveBufferAttributes(); Pa_AbortStream(m_Stream); Pa_CloseStream(m_Stream); if(Pa_GetDeviceInfo(m_StreamParameters.device)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWDMKS)) { - Pa_Sleep(Util::Round<long>(GetBufferAttributes().Latency * 2.0 * 1000.0 + 0.5)); // wait for broken wdm drivers not closing the stream immediatly + Pa_Sleep(Util::Round<long>(bufferAttributes.Latency * 2.0 * 1000.0 + 0.5)); // wait for broken wdm drivers not closing the stream immediatly } MemsetZero(m_StreamParameters); m_StreamInfo = 0; @@ -193,13 +189,29 @@ } -double CPortaudioDevice::GetCurrentLatency() const -//------------------------------------------------ +SoundDevice::BufferAttributes CPortaudioDevice::InternalGetEffectiveBufferAttributes() const +//------------------------------------------------------------------------------------------ { - return m_CurrentRealLatency; + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_StreamInfo->outputLatency; + bufferAttributes.UpdateInterval = m_Settings.UpdateInterval; + bufferAttributes.NumBuffers = 1; + return bufferAttributes; } +SoundDevice::Statistics CPortaudioDevice::GetStatistics() const +//------------------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = m_CurrentRealLatency; + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + SoundDevice::Caps CPortaudioDevice::InternalGetDeviceCaps() //------------------------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -56,9 +56,10 @@ bool InternalStart(); void InternalStop(); bool InternalIsOpen() const { return m_Stream ? true : false; } - double GetCurrentLatency() const; bool InternalHasGetStreamPosition() const { return false; } int64 InternalGetStreamPositionFrames() const; + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + SoundDevice::Statistics GetStatistics() const; SoundDevice::Caps InternalGetDeviceCaps(); SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); bool OpenDriverSettings(); Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.cpp 2015-02-11 14:36:10 UTC (rev 4750) @@ -191,11 +191,6 @@ SetWakeupEvent(m_ThreadWakeupEvent); SetWakeupInterval(m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond()); m_Flags.NeedsClippedFloat = mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista); - SoundDevice::BufferAttributes bufferAttributes; - bufferAttributes.Latency = m_nWaveBufferSize * m_nPreparedHeaders * 1.0 / m_Settings.GetBytesPerSecond(); - bufferAttributes.UpdateInterval = m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); - bufferAttributes.NumBuffers = m_nPreparedHeaders; - UpdateBufferAttributes(bufferAttributes); return true; } @@ -331,6 +326,29 @@ } +SoundDevice::BufferAttributes CWaveDevice::InternalGetEffectiveBufferAttributes() const +//------------------------------------------------------------------------------------- +{ + SoundDevice::BufferAttributes bufferAttributes; + bufferAttributes.Latency = m_nWaveBufferSize * m_nPreparedHeaders * 1.0 / m_Settings.GetBytesPerSecond(); + bufferAttributes.UpdateInterval = m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); + bufferAttributes.NumBuffers = m_nPreparedHeaders; + return bufferAttributes; +} + + +SoundDevice::Statistics CWaveDevice::GetStatistics() const +//-------------------------------------------------------- +{ + MPT_TRACE(); + SoundDevice::Statistics result; + result.InstantaneousLatency = InterlockedExchangeAdd(&m_nBuffersPending, 0) * m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); + result.LastUpdateInterval = GetLastUpdateInterval(); + result.text = mpt::ustring(); + return result; +} + + std::vector<SoundDevice::Info> CWaveDevice::EnumerateDevices() //---------------------------------------------------------- { Modified: trunk/OpenMPT/sounddev/SoundDeviceWaveout.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2015-02-11 14:35:32 UTC (rev 4749) +++ trunk/OpenMPT/sounddev/SoundDeviceWaveout.h 2015-02-11 14:36:10 UTC (rev 4750) @@ -54,10 +54,12 @@ void StartFromSoundThread(); void StopFromSoundThread(); bool InternalIsOpen() const { return (m_hWaveOut != NULL); } - double GetCurrentLatency() const { return InterlockedExchangeAdd(&m_nBuffersPending, 0) * m_nWaveBufferSize * 1.0 / m_Settings.GetBytesPerSecond(); } bool InternalHasGetStreamPosition() const { return true; } int64 InternalGetStreamPositionFrames() const; + SoundDevice::BufferAttributes InternalGetEffectiveBufferAttributes() const; + SoundDevice::Statistics GetStatistics() const; + SoundDevice::Caps InternalGetDeviceCaps(); SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |