From: <man...@us...> - 2013-11-17 17:35:02
|
Revision: 3251 http://sourceforge.net/p/modplug/code/3251 Author: manxorist Date: 2013-11-17 17:34:53 +0000 (Sun, 17 Nov 2013) Log Message: ----------- [Ref] sounddev: Provide accurate current update interval statistics for all sound devices. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-17 16:02:07 UTC (rev 3250) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-17 17:34:53 UTC (rev 3251) @@ -543,16 +543,15 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm->gpSoundDevice && pMainFrm->IsPlaying()) { - CHAR s[256]; const SoundBufferAttributes bufferAttributes = pMainFrm->gpSoundDevice->GetBufferAttributes(); const double currentLatency = pMainFrm->gpSoundDevice->GetCurrentLatency(); - _snprintf(s, 255, "Buffers: %d (%d%%)\r\nUpdate interval: %4.1f ms\r\nLatency: %4.1f ms\r\nCurrent Latency: %4.1f ms", - (int)bufferAttributes.NumBuffers, (bufferAttributes.Latency > 0.0) ? Util::Round<int>(currentLatency / bufferAttributes.Latency * 100.0) : 0, - (float)(bufferAttributes.UpdateInterval * 1000.0f), - (float)(bufferAttributes.Latency * 1000.0f), - (float)(currentLatency * 1000.0f) - ); - m_EditStatistics.SetWindowText(s); + const double currentUpdateInterval = pMainFrm->gpSoundDevice->GetCurrentUpdateInterval(); + std::string s; + s += mpt::String::Print("Buffer: %1%%\r\n", (bufferAttributes.Latency > 0.0) ? Util::Round<int64>(currentLatency / bufferAttributes.Latency * 100.0) : 0); + s += mpt::String::Print("Buffers: %1 (current: %2)\r\n", bufferAttributes.NumBuffers, (currentUpdateInterval > 0.0) ? Util::Round<int64>(bufferAttributes.Latency / currentUpdateInterval) : 0); + s += mpt::String::Print("Latency: %1 ms (current: %2 ms)\r\n", mpt::Format("%4.1f").ToString(bufferAttributes.Latency * 1000.0), mpt::Format("%4.1f").ToString(currentLatency * 1000.0)); + s += mpt::String::Print("Update Interval: %1 ms (current: %2 ms)\r\n", mpt::Format("%4.1f").ToString(bufferAttributes.UpdateInterval * 1000.0), mpt::Format("%4.1f").ToString(currentUpdateInterval * 1000.0)); + m_EditStatistics.SetWindowText(s.c_str()); } else { m_EditStatistics.SetWindowText(""); Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-17 16:02:07 UTC (rev 3250) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-17 17:34:53 UTC (rev 3251) @@ -44,6 +44,7 @@ m_BufferAttributes.NumBuffers = 0; m_IsPlaying = false; + m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } @@ -164,6 +165,7 @@ int64 framesRendered = 0; { Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); + m_CurrentUpdateInterval = (double)numFrames / (double)m_Settings.Samplerate; m_StreamPositionRenderFrames += numFrames; m_StreamPositionOutputFrames = m_StreamPositionRenderFrames - framesLatency; framesRendered = m_StreamPositionRenderFrames; @@ -190,6 +192,7 @@ { { Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); + m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } @@ -209,6 +212,7 @@ m_IsPlaying = false; { Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); + m_CurrentUpdateInterval = 0.0; m_StreamPositionRenderFrames = 0; m_StreamPositionOutputFrames = 0; } @@ -216,8 +220,16 @@ } +double ISoundDevice::GetCurrentUpdateInterval() const +//--------------------------------------------------- +{ + Util::lock_guard<Util::mutex> lock(m_StreamPositionMutex); + return m_CurrentUpdateInterval; +} + + int64 ISoundDevice::GetStreamPositionFrames() const -//-------------------------------------------------- +//------------------------------------------------- { if(!IsOpen()) return 0; if(InternalHasGetStreamPosition()) Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-17 16:02:07 UTC (rev 3250) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-17 17:34:53 UTC (rev 3251) @@ -247,6 +247,7 @@ bool m_IsPlaying; mutable Util::mutex m_StreamPositionMutex; + double m_CurrentUpdateInterval; int64 m_StreamPositionRenderFrames; int64 m_StreamPositionOutputFrames; @@ -308,6 +309,7 @@ // Informational only, do not use for timing. // Use GetStreamPositionFrames() for timing virtual double GetCurrentLatency() const { return m_BufferAttributes.Latency; } + double GetCurrentUpdateInterval() const; int64 GetStreamPositionFrames() const; Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-17 16:02:07 UTC (rev 3250) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-17 17:34:53 UTC (rev 3251) @@ -216,11 +216,6 @@ { m_CurrentRealLatency = timeInfo->outputBufferDacTime - timeInfo->currentTime; } - SoundBufferAttributes bufferAttributes; - bufferAttributes.Latency = m_StreamInfo->outputLatency; - bufferAttributes.UpdateInterval = (double)frameCount / (double)m_StreamInfo->sampleRate; - bufferAttributes.NumBuffers = 1; - UpdateBufferAttributes(bufferAttributes); m_CurrentFrameBuffer = output; m_CurrentFrameCount = frameCount; SourceFillAudioBufferLocked(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |