From: <sag...@us...> - 2010-10-12 20:13:17
|
Revision: 736 http://modplug.svn.sourceforge.net/modplug/?rev=736&view=rev Author: saga-games Date: 2010-10-12 20:13:10 +0000 (Tue, 12 Oct 2010) Log Message: ----------- [Ref] Sound device code refactoring Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/soundlib/SNDDEV.H Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2010-10-08 14:40:44 UTC (rev 735) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2010-10-12 20:13:10 UTC (rev 736) @@ -187,7 +187,7 @@ DWORD CMainFrame::m_nBitsPerSample = 16; DWORD CMainFrame::m_nPreAmp = 128; DWORD CMainFrame::gbLoopSong = TRUE; -LONG CMainFrame::m_nWaveDevice = (SNDDEV_DSOUND<<8); +LONG CMainFrame::m_nWaveDevice = (SNDDEV_DSOUND << SNDDEV_DEVICE_SHIFT); LONG CMainFrame::m_nMidiDevice = 0; DWORD CMainFrame::m_nBufferLength = 75; LONG CMainFrame::gnLVuMeter = 0; @@ -433,12 +433,12 @@ m_dwRate = 44100; #ifndef NO_ASIO // If no mixing rate is specified and we're using ASIO, get a mixing rate supported by the device. - if((m_nWaveDevice >> 8) == SNDDEV_ASIO) + if(SNDDEV_GET_TYPE(m_nWaveDevice) == SNDDEV_ASIO) { ISoundDevice *dummy; if(CreateSoundDevice(SNDDEV_ASIO, &dummy)) { - m_dwRate = dummy->GetCurrentSampleRate(m_nWaveDevice & 0xFF); + m_dwRate = dummy->GetCurrentSampleRate(SNDDEV_GET_NUMBER(m_nWaveDevice)); delete dummy; } } @@ -691,8 +691,6 @@ VOID CMainFrame::Initialize() //--------------------------- { - CHAR s[256]; - //Adding version number to the frame title CString title = GetTitle(); title += CString(" ") + MptVersion::str; @@ -711,12 +709,12 @@ // Load Chords theApp.LoadChords(Chords); // Check for valid sound device - if (!EnumerateSoundDevices(m_nWaveDevice>>8, m_nWaveDevice&0xff, s, sizeof(s))) + if (!EnumerateSoundDevices(SNDDEV_GET_TYPE(m_nWaveDevice), SNDDEV_GET_NUMBER(m_nWaveDevice), nullptr, 0)) { - m_nWaveDevice = (SNDDEV_DSOUND<<8); - if (!EnumerateSoundDevices(m_nWaveDevice>>8, m_nWaveDevice&0xff, s, sizeof(s))) + m_nWaveDevice = (SNDDEV_DSOUND << SNDDEV_DEVICE_SHIFT); + if (!EnumerateSoundDevices(SNDDEV_GET_TYPE(m_nWaveDevice), SNDDEV_GET_NUMBER(m_nWaveDevice), nullptr, 0)) { - m_nWaveDevice = (SNDDEV_WAVEOUT<<8); + m_nWaveDevice = (SNDDEV_WAVEOUT << SNDDEV_DEVICE_SHIFT); } } // Default directory location @@ -1480,8 +1478,8 @@ m_pSndFile->SetWaveConfig(samplespersec, bits, channels, (m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) ? TRUE : FALSE); // Maybe we failed because someone is playing sound already. // Shut any sound off, and try once more before giving up. - UINT nDevType = m_nWaveDevice>>8; - UINT nDevNo = m_nWaveDevice&0xff; + UINT nDevType = SNDDEV_GET_TYPE(m_nWaveDevice); + UINT nDevNo = SNDDEV_GET_NUMBER(m_nWaveDevice); UINT fulOptions = (m_dwSoundSetup & SOUNDSETUP_SECONDARY) ? SNDDEV_OPTIONS_SECONDARY : 0; if ((gpSoundDevice) && (gpSoundDevice->GetDeviceType() != nDevType)) { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2010-10-08 14:40:44 UTC (rev 735) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2010-10-12 20:13:10 UTC (rev 736) @@ -423,7 +423,7 @@ // Audio Setup static DWORD m_dwSoundSetup, m_dwRate, m_dwQuality, m_nSrcMode, m_nBitsPerSample, m_nPreAmp, gbLoopSong, m_nChannels; - static LONG m_nWaveDevice; // lower 8 bits: device number (for this type). higher 8 bits: device type + static LONG m_nWaveDevice; // use the SNDDEV_GET_NUMBER and SNDDEV_GET_TYPE macros to decode static LONG m_nMidiDevice; static DWORD m_nBufferLength; static EQPRESET m_EqSettings; Modified: trunk/OpenMPT/soundlib/SNDDEV.H =================================================================== --- trunk/OpenMPT/soundlib/SNDDEV.H 2010-10-08 14:40:44 UTC (rev 735) +++ trunk/OpenMPT/soundlib/SNDDEV.H 2010-10-12 20:13:10 UTC (rev 736) @@ -22,13 +22,19 @@ // // Sound Device Types -enum { - SNDDEV_WAVEOUT=0, +enum +{ + SNDDEV_WAVEOUT = 0, SNDDEV_DSOUND, SNDDEV_ASIO, SNDDEV_NUM_DEVTYPES }; +#define SNDDEV_DEVICE_MASK 0xFF // Mask for getting the device number +#define SNDDEV_DEVICE_SHIFT 8 // Shift amount for getting the device type +#define SNDDEV_GET_NUMBER(x) (x & SNDDEV_DEVICE_MASK) // Use this for getting the device number +#define SNDDEV_GET_TYPE(x) (x >> SNDDEV_DEVICE_SHIFT) // ...and this for getting the device type + #define SNDDEV_MINBUFFERS 2 #define SNDDEV_MAXBUFFERS 16 #define SNDDEV_MINBUFFERLEN 1 // 1ms This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |