From: <man...@us...> - 2013-11-22 12:16:55
|
Revision: 3290 http://sourceforge.net/p/modplug/code/3290 Author: manxorist Date: 2013-11-22 12:16:45 +0000 (Fri, 22 Nov 2013) Log Message: ----------- [Ref] sounddev: Pass buffer attributes to AudioRead. [Ref] Add TimingInfo to CSoundFile. [Ref] Fill CSoundFile timing info in AudioRead. [Fix] VST: Pass the actual obtained output latency to VST plugins instead of the user wanted latency. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-22 09:05:29 UTC (rev 3289) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-11-22 12:16:45 UTC (rev 3290) @@ -724,12 +724,17 @@ }; -void CMainFrame::AudioRead(const SoundDeviceSettings &settings, SoundTimeInfo timeInfo, std::size_t numFrames, void *buffer) -//-------------------------------------------------------------------------------------------------------------------------- +void CMainFrame::AudioRead(const SoundDeviceSettings &settings, const SoundBufferAttributes &bufferAttributes, SoundTimeInfo timeInfo, std::size_t numFrames, void *buffer) +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { - MPT_UNREFERENCED_PARAMETER(timeInfo); ASSERT(InAudioThread()); OPENMPT_PROFILE_FUNCTION(Profiler::Audio); + TimingInfo timingInfo; + timingInfo.OutputLatency = bufferAttributes.Latency; + timingInfo.StreamFrames = timeInfo.StreamFrames; + timingInfo.SystemTimestamp = timeInfo.SystemTimestamp; + timingInfo.Speed = timeInfo.Speed; + m_pSndFile->m_TimingInfo = timingInfo; StereoVuMeterTargetWrapper target(settings.sampleFormat, m_Dither, buffer); CSoundFile::samplecount_t renderedFrames = m_pSndFile->Read(numFrames, target); ASSERT(renderedFrames <= numFrames); @@ -750,14 +755,16 @@ } -void CMainFrame::AudioDone(const SoundDeviceSettings &settings, SoundTimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) -//---------------------------------------------------------------------------------------------------------------------------------- +void CMainFrame::AudioDone(const SoundDeviceSettings &settings, const SoundBufferAttributes &bufferAttributes, SoundTimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) +//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- { MPT_UNREFERENCED_PARAMETER(settings); + MPT_UNREFERENCED_PARAMETER(bufferAttributes); MPT_UNREFERENCED_PARAMETER(timeInfo); ASSERT(InAudioThread()); OPENMPT_PROFILE_FUNCTION(Profiler::Notify); DoNotification(numFrames, streamPosition); + //m_pSndFile->m_TimingInfo = TimingInfo(); // reset } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-22 09:05:29 UTC (rev 3289) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-11-22 12:16:45 UTC (rev 3290) @@ -332,8 +332,8 @@ // from ISoundSource void FillAudioBufferLocked(IFillAudioBuffer &callback); - void AudioRead(const SoundDeviceSettings &settings, SoundTimeInfo timeInfo, std::size_t numFrames, void *buffer); - void AudioDone(const SoundDeviceSettings &settings, SoundTimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); + void AudioRead(const SoundDeviceSettings &settings, const SoundBufferAttributes &bufferAttributes, SoundTimeInfo timeInfo, std::size_t numFrames, void *buffer); + void AudioDone(const SoundDeviceSettings &settings, const SoundBufferAttributes &bufferAttributes, SoundTimeInfo timeInfo, std::size_t numFrames, int64 streamPosition); // from ISoundMessageReceiver void AudioMessage(const std::string &str); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-22 09:05:29 UTC (rev 3289) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-22 12:16:45 UTC (rev 3290) @@ -231,8 +231,15 @@ case audioMasterGetOutputLatency: if(pVstPlugin) { - return Util::muldiv(TrackerSettings::Instance().m_LatencyMS, pVstPlugin->m_nSampleRate, 1000); + if(pVstPlugin->GetSoundFile().IsRenderingToDisc()) + { + return 0; + } else + { + return Util::Round<VstIntPtr>(pVstPlugin->GetSoundFile().m_TimingInfo.OutputLatency * pVstPlugin->m_nSampleRate); + } } + break; // input pin in <value> (-1: first to come), returns cEffect* - DEPRECATED in VST 2.4 case audioMasterGetPreviousPlug: Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-22 09:05:29 UTC (rev 3289) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-11-22 12:16:45 UTC (rev 3290) @@ -192,7 +192,7 @@ { return; } - m_Source->AudioRead(m_Settings, m_TimeInfo, numFrames, buffer); + m_Source->AudioRead(m_Settings, m_BufferAttributes, m_TimeInfo, numFrames, buffer); } @@ -211,7 +211,7 @@ m_StreamPositionOutputFrames = m_StreamPositionRenderFrames - framesLatency; framesRendered = m_StreamPositionRenderFrames; } - m_Source->AudioDone(m_Settings, m_TimeInfo, numFrames, framesRendered); + m_Source->AudioDone(m_Settings, m_BufferAttributes, m_TimeInfo, numFrames, framesRendered); } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-22 09:05:29 UTC (rev 3289) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-11-22 12:16:45 UTC (rev 3290) @@ -31,6 +31,7 @@ struct SoundDeviceSettings; +struct SoundBufferAttributes; //==================== @@ -72,8 +73,8 @@ { public: virtual void FillAudioBufferLocked(IFillAudioBuffer &callback) = 0; // take any locks needed while rendering audio and then call FillAudioBuffer - virtual void AudioRead(const SoundDeviceSettings &settings, SoundTimeInfo timeInfo, std::size_t numFrames, void *buffer) = 0; - virtual void AudioDone(const SoundDeviceSettings &settings, SoundTimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) = 0; // in sample frames + virtual void AudioRead(const SoundDeviceSettings &settings, const SoundBufferAttributes &bufferAttributes, SoundTimeInfo timeInfo, std::size_t numFrames, void *buffer) = 0; + virtual void AudioDone(const SoundDeviceSettings &settings, const SoundBufferAttributes &bufferAttributes, SoundTimeInfo timeInfo, std::size_t numFrames, int64 streamPosition) = 0; // in sample frames }; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-11-22 09:05:29 UTC (rev 3289) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-11-22 12:16:45 UTC (rev 3290) @@ -187,6 +187,25 @@ #endif // MODPLUG_TRACKER +struct TimingInfo +{ + double InputLatency; // seconds + double OutputLatency; // seconds + int64 StreamFrames; + uint64 SystemTimestamp; // nanoseconds + double Speed; + TimingInfo() + : InputLatency(0.0) + , OutputLatency(0.0) + , StreamFrames(0) + , SystemTimestamp(0) + , Speed(1.0) + { + return; + } +}; + + class IAudioReadTarget { public: @@ -411,6 +430,7 @@ #endif // MODPLUG_TRACKER bool m_bIsRendering; + TimingInfo m_TimingInfo; // only valid if !m_bIsRendering bool m_bPatternTransitionOccurred; private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |