From: <man...@us...> - 2013-10-15 10:25:52
|
Revision: 2904 http://sourceforge.net/p/modplug/code/2904 Author: manxorist Date: 2013-10-15 10:25:42 +0000 (Tue, 15 Oct 2013) Log Message: ----------- [Ref] sounddev: Decouple sound device code from GUI code some more. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h 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 Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-10-15 10:25:42 UTC (rev 2904) @@ -259,6 +259,7 @@ ISoundDevice *dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(TrackerSettings::Instance().m_nWaveDevice); if(dummy) { + dummy->SetMessageReceiver(CMainFrame::GetMainFrame()); TrackerSettings::Instance().m_MixerSettings.gdwMixingFreq = dummy->GetCurrentSampleRate(); delete dummy; } @@ -774,6 +775,13 @@ } +void CMainFrame::AudioMessage(const std::string &str) +//--------------------------------------------------- +{ + Reporting::Notification(str.c_str()); +} + + void CMainFrame::FillAudioBufferLocked(IFillAudioBuffer &callback) //---------------------------------------------------------------- { @@ -905,6 +913,7 @@ { return false; } + gpSoundDevice->SetMessageReceiver(this); gpSoundDevice->SetSource(this); return gpSoundDevice->Open(TrackerSettings::Instance().GetSoundDeviceSettings()); } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-10-15 10:25:42 UTC (rev 2904) @@ -246,9 +246,9 @@ #include "TrackerSettings.h" struct MODPLUGDIB; -//======================================================== -class CMainFrame: public CMDIFrameWnd, public ISoundSource -//======================================================== +//====================================================================================== +class CMainFrame: public CMDIFrameWnd, public ISoundSource, public ISoundMessageReceiver +//====================================================================================== { DECLARE_DYNAMIC(CMainFrame) // static data @@ -328,6 +328,9 @@ void AudioRead(const SoundDeviceSettings &settings, std::size_t numFrames, void *buffer); void AudioDone(const SoundDeviceSettings &settings, std::size_t numFrames, int64 streamPosition); + // from ISoundMessageReceiver + void AudioMessage(const std::string &str); + bool audioTryOpeningDevice(); bool audioOpenDevice(); bool audioReopenDevice(); Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-15 10:25:42 UTC (rev 2904) @@ -397,6 +397,10 @@ { justCreated = true; dummy = theApp.GetSoundDevicesManager()->CreateSoundDevice(dev); + if(dummy) + { + dummy->SetMessageReceiver(CMainFrame::GetMainFrame()); + } } if(dummy != nullptr) Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2013-10-15 10:25:42 UTC (rev 2904) @@ -34,6 +34,7 @@ ISoundDevice::ISoundDevice(SoundDeviceID id, const std::wstring &internalID) //-------------------------------------------------------------------------- : m_Source(nullptr) + , m_MessageReceiver(nullptr) , m_ID(id) , m_InternalID(internalID) { @@ -152,6 +153,16 @@ } +void ISoundDevice::AudioSendMessage(const std::string &str) +//--------------------------------------------------------- +{ + if(m_MessageReceiver) + { + m_MessageReceiver->AudioMessage(str); + } +} + + void ISoundDevice::Start() //------------------------ { Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2013-10-15 10:25:42 UTC (rev 2904) @@ -40,6 +40,15 @@ }; +//========================= +class ISoundMessageReceiver +//========================= +{ +public: + virtual void AudioMessage(const std::string &str) = 0; +}; + + //================ class ISoundSource //================ @@ -184,6 +193,7 @@ private: ISoundSource *m_Source; + ISoundMessageReceiver *m_MessageReceiver; const SoundDeviceID m_ID; @@ -206,12 +216,15 @@ void SourceFillAudioBufferLocked(); void SourceAudioRead(void *buffer, std::size_t numFrames); void SourceAudioDone(std::size_t numFrames, int32 framesLatency); + void AudioSendMessage(const std::string &str); public: ISoundDevice(SoundDeviceID id, const std::wstring &internalID); virtual ~ISoundDevice(); void SetSource(ISoundSource *source) { m_Source = source; } ISoundSource *GetSource() const { return m_Source; } + void SetMessageReceiver(ISoundMessageReceiver *receiver) { m_MessageReceiver = receiver; } + ISoundMessageReceiver *GetMessageReceiver() const { return m_MessageReceiver; } public: SoundDeviceID GetDeviceID() const { return m_ID; } SoundDeviceType GetDeviceType() const { return m_ID.GetType(); } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-10-15 10:25:42 UTC (rev 2904) @@ -17,9 +17,6 @@ #include "SoundDeviceASIO.h" #include "../common/misc_util.h" -#ifdef MODPLUG_TRACKER -#include "../mptrack/Reporting.h" -#endif #include "../common/StringFixer.h" #include "../soundlib/SampleFormatConverters.h" @@ -715,7 +712,7 @@ void CASIODevice::ReportASIOException(const std::string &str) //----------------------------------------------------------- { - Reporting::Notification(str.c_str()); + AudioSendMessage(str); Log("%s", str.c_str()); } Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-15 05:08:21 UTC (rev 2903) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.h 2013-10-15 10:25:42 UTC (rev 2904) @@ -85,7 +85,8 @@ static void SampleRateDidChange(ASIOSampleRate sRate); static long AsioMessage(long selector, long value, void* message, double* opt); static ASIOTime* BufferSwitchTimeInfo(ASIOTime* params, long doubleBufferIndex, ASIOBool directProcess); - static void ReportASIOException(const std::string &str); + + void ReportASIOException(const std::string &str); }; #endif // NO_ASIO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |