/* MikMod sound library (c) 1998-2005 Miodrag Vallat and others - see file AUTHORS for complete list. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*============================================================================== Driver for output on win32 platforms using DirectSound ==============================================================================*/ /* Written by Brian McKinney */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "mikmod_internals.h" #ifdef DRV_DS #include #include /* Including dsound.h breaks in MSYS2 unless windows.h is * explicitly included first (without WIN32_LEAN_AND_MEAN). */ #include #define INITGUID #if defined(__WATCOMC__) #include #else #include /* guiddef.h not in all SDKs, e.g. mingw.org */ #endif #if !defined(__cplusplus) && !defined(CINTERFACE) #define CINTERFACE #endif #include #ifdef __WATCOMC__ /* If you encounter build failures from Open Watcom's dsound.h, * see: https://github.com/open-watcom/open-watcom-v2/pull/313 */ /* Open Watcom has broken __cdecl (leading underscore) name mangling for Windows * internal var names. It is fixed in Open Watcom V2 fork as of May/2014: * https://github.com/open-watcom/open-watcom-v2/commit/961ef1ff756f3ec5a7248cefcae00a6ecaa97ff4 * Therefore, we define and use a local copy of IID_IDirectSoundNotify here. */ DEFINE_GUID(IID_IDirectSoundNotify,0xB0210783,0x89cd,0x11d0,0xAF,0x08,0x00,0xA0,0xC9,0x25,0xCD,0x16); #endif /* PF_XMMI64_INSTRUCTIONS_AVAILABLE not in all SDKs */ #ifndef PF_XMMI64_INSTRUCTIONS_AVAILABLE #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 #endif /* DSBCAPS_CTRLALL is not defined anymore with DirectX 7. Of course DirectSound is a coherent, backwards compatible API... */ #ifndef DSBCAPS_CTRLALL #define DSBCAPS_CTRLALL ( DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_CTRLVOLUME | \ DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | \ DSBCAPS_CTRL3D ) #endif #ifndef WAVE_FORMAT_IEEE_FLOAT #define WAVE_FORMAT_IEEE_FLOAT 0x0003 #endif /* size of each buffer */ #define FRAGSIZE 16 /* buffer count */ #define UPDATES 2 static LPDIRECTSOUND pSoundCard = NULL; static LPDIRECTSOUNDBUFFER pPrimarySoundBuffer = NULL, pSoundBuffer = NULL; static LPDIRECTSOUNDNOTIFY pSoundBufferNotify = NULL; static HANDLE notifyUpdateHandle = NULL, updateBufferHandle = NULL; static BOOL threadInUse = FALSE; static int fragsize=1<19)) buf=FRAGSIZE; fragsize=1<