From: <man...@us...> - 2015-02-19 14:14:26
|
Revision: 4773 http://sourceforge.net/p/modplug/code/4773 Author: manxorist Date: 2015-02-19 14:14:09 +0000 (Thu, 19 Feb 2015) Log Message: ----------- [Fix] ASIO: ASIO specification demands a valid window handle to be provided for driver intialization. When initializiung an ASIO driver in order to check for availability or query its capabilities, OpenMPT did only provide a NULL window handle. Add a struct SoundDevice::AppInfo which gets provided on sound device initialization instead of on opening. [Ref] sounddev: Add an application name field to SoundDevice::AppInfo which will be useful for APIs that name ports after the application they belong to. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/sounddev/SoundDevice.cpp trunk/OpenMPT/sounddev/SoundDevice.h trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -998,7 +998,7 @@ m_pMainWnd->DragAcceptFiles(); // Load sound APIs - m_pSoundDevicesManager = new SoundDevice::Manager(TrackerSettings::Instance().GetEnabledSoundDeviceTypes()); + m_pSoundDevicesManager = new SoundDevice::Manager(SoundDevice::AppInfo().SetName(MPT_USTRING("OpenMPT")).SetHWND(*m_pMainWnd), TrackerSettings::Instance().GetEnabledSoundDeviceTypes()); if(TrackerSettings::Instance().m_SoundDeviceSettingsUseOldDefaults) { // get the old default device Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -709,7 +709,6 @@ } const SoundDevice::Caps deviceCaps = theApp.GetSoundDevicesManager()->GetDeviceCaps(device, CMainFrame::GetMainFrame()->gpSoundDevice); SoundDevice::Settings settings = StoredSoundDeviceSettings(conf, deviceInfo, deviceCaps.DefaultSettings); - settings.hWnd = CMainFrame::GetMainFrame()->m_hWnd; return settings; } Modified: trunk/OpenMPT/sounddev/SoundDevice.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDevice.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -176,14 +176,15 @@ } -bool Base::Init() -//--------------- +bool Base::Init(const SoundDevice::AppInfo &appInfo) +//-------------------------------------------------- { MPT_TRACE(); if(IsInited()) { return true; } + m_AppInfo = appInfo; m_Caps = InternalGetDeviceCaps(); return m_Caps.Available; } Modified: trunk/OpenMPT/sounddev/SoundDevice.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDevice.h 2015-02-19 14:14:09 UTC (rev 4773) @@ -289,9 +289,26 @@ }; +struct AppInfo +{ + mpt::ustring Name; + uintptr_t UIHandle; // HWND on Windows + AppInfo() + : UIHandle(0) + { + return; + } + AppInfo &SetName(const mpt::ustring &name) { Name = name; return *this; } + mpt::ustring GetName() const { return Name; } +#if MPT_OS_WINDOWS + AppInfo &SetHWND(HWND hwnd) { UIHandle = reinterpret_cast<uintptr_t>(hwnd); return *this; } + HWND GetHWND() const { return reinterpret_cast<HWND>(UIHandle); } +#endif // MPT_OS_WINDOWS +}; + + struct Settings { - HWND hWnd; double Latency; // seconds double UpdateInterval; // seconds uint32 Samplerate; @@ -304,8 +321,7 @@ int DitherType; SoundDevice::ChannelMapping ChannelMapping; Settings() - : hWnd(NULL) - , Latency(0.1) + : Latency(0.1) , UpdateInterval(0.005) , Samplerate(48000) , Channels(2) @@ -321,7 +337,6 @@ bool operator == (const SoundDevice::Settings &cmp) const { return true - && hWnd == cmp.hWnd && Util::Round<int64>(Latency * 1000000000.0) == Util::Round<int64>(cmp.Latency * 1000000000.0) // compare in nanoseconds && Util::Round<int64>(UpdateInterval * 1000000000.0) == Util::Round<int64>(cmp.UpdateInterval * 1000000000.0) // compare in nanoseconds && Samplerate == cmp.Samplerate @@ -492,7 +507,7 @@ virtual SoundDevice::Caps GetDeviceCaps() const = 0; virtual SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates) = 0; - virtual bool Init() = 0; + virtual bool Init(const SoundDevice::AppInfo &appInfo) = 0; virtual bool Open(const SoundDevice::Settings &settings) = 0; virtual bool Close() = 0; virtual bool Start() = 0; @@ -542,6 +557,7 @@ protected: + SoundDevice::AppInfo m_AppInfo; SoundDevice::Settings m_Settings; SoundDevice::Flags m_Flags; bool m_DeviceUnavailableOnOpen; @@ -624,7 +640,7 @@ SoundDevice::Caps GetDeviceCaps() const { return m_Caps; } virtual SoundDevice::DynamicCaps GetDeviceDynamicCaps(const std::vector<uint32> &baseSampleRates); - bool Init(); + bool Init(const SoundDevice::AppInfo &appInfo); bool Open(const SoundDevice::Settings &settings); bool Close(); bool Start(); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -684,7 +684,7 @@ } try { - if(m_pAsioDrv->init((void *)m_Settings.hWnd) != ASIOTrue) + if(m_pAsioDrv->init((void *)m_AppInfo.GetHWND()) != ASIOTrue) { Log("ASIO: init() failed!"); CloseDriver(); Modified: trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceDirectSound.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -213,7 +213,7 @@ GUID guid = internalID.empty() ? GUID() : Util::StringToGUID(mpt::ToWide(internalID)); if(DirectSoundCreate(internalID.empty() ? NULL : &guid, &m_piDS, NULL) != DS_OK) return false; if(!m_piDS) return false; - if(m_piDS->SetCooperativeLevel(m_Settings.hWnd, m_Settings.ExclusiveMode ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY) != DS_OK) + if(m_piDS->SetCooperativeLevel(m_AppInfo.GetHWND(), m_Settings.ExclusiveMode ? DSSCL_WRITEPRIMARY : DSSCL_PRIORITY) != DS_OK) { Close(); return false; Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-02-19 14:14:09 UTC (rev 4773) @@ -332,7 +332,7 @@ { return nullptr; } - if(!result->Init()) + if(!result->Init(m_AppInfo)) { delete result; result = nullptr; @@ -343,8 +343,9 @@ } -Manager::Manager(SoundDevice::TypesSet enabledTypes) -//-------------------------------------------------- +Manager::Manager(SoundDevice::AppInfo appInfo, SoundDevice::TypesSet enabledTypes) +//-------------------------------------------------------------------------------- + : m_AppInfo(appInfo) { ReEnumerate(enabledTypes); } Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.h =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.h 2015-02-19 12:10:19 UTC (rev 4772) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.h 2015-02-19 14:14:09 UTC (rev 4773) @@ -31,6 +31,8 @@ { private: + const SoundDevice::AppInfo m_AppInfo; + #ifndef NO_PORTAUDIO ComponentHandle<ComponentPortAudio> m_PortAudio; #endif // NO_PORTAUDIO @@ -41,7 +43,7 @@ std::map<SoundDevice::Identifier, SoundDevice::DynamicCaps> m_DeviceDynamicCaps; public: - Manager(SoundDevice::TypesSet enabledTypes); + Manager(SoundDevice::AppInfo appInfo, SoundDevice::TypesSet enabledTypes); ~Manager(); public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |