Add _DEBUG/NDEBUG defines when DEBUG/NODEBUG options are used, respectively
[openal-soft.git] / Router / OpenAL32.cpp
blob8c84148bf9832e1ee5c2f4c040a25a4dc9741e47
1 /**
2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2000 by authors.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
24 #include <windows.h>
25 #include "OpenAL32.h"
28 void CleanDeviceEnumeration();
29 void CleanDeviceList(ALDEVICE *pDeviceList);
31 //*****************************************************************************
32 // DllMain
33 //*****************************************************************************
35 BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID reserved)
37 BOOL result = TRUE;
39 // Perform actions based on the reason for calling.
40 switch(reason)
42 case DLL_PROCESS_ATTACH:
43 // Create the context list lock so I can safely add/remove contexts.
44 result = alListCreate(&alContextList);
45 break;
47 case DLL_THREAD_ATTACH:
48 // Do thread-specific initialization.
49 break;
51 case DLL_THREAD_DETACH:
52 // Do thread-specific cleanup.
53 break;
55 case DLL_PROCESS_DETACH:
56 // Perform any necessary cleanup.
57 CleanDeviceEnumeration();
58 alListFree(alContextList);
59 alContextList = 0;
60 break;
63 return TRUE;
67 void CleanDeviceEnumeration()
69 if (pszDefaultDeviceSpecifier)
71 free(pszDefaultDeviceSpecifier);
72 pszDefaultDeviceSpecifier = NULL;
75 if (pszDeviceSpecifierList)
77 free(pszDeviceSpecifierList);
78 pszDeviceSpecifierList = NULL;
81 if (pszDefaultCaptureDeviceSpecifier)
83 free(pszDefaultCaptureDeviceSpecifier);
84 pszDefaultCaptureDeviceSpecifier = NULL;
87 if (pszCaptureDeviceSpecifierList)
89 free(pszCaptureDeviceSpecifierList);
90 pszCaptureDeviceSpecifierList = NULL;
93 if (pszDefaultAllDevicesSpecifier)
95 free(pszDefaultAllDevicesSpecifier);
96 pszDefaultAllDevicesSpecifier = NULL;
99 if (pszAllDevicesSpecifierList)
101 free(pszAllDevicesSpecifierList);
102 pszAllDevicesSpecifierList = NULL;
105 CleanDeviceList(g_pDeviceList);
106 g_pDeviceList = NULL;
108 CleanDeviceList(g_pCaptureDeviceList);
109 g_pCaptureDeviceList = NULL;
111 CleanDeviceList(g_pAllDevicesList);
112 g_pAllDevicesList = NULL;
115 void CleanDeviceList(ALDEVICE *pDeviceList)
117 ALDEVICE *pDevice, *pNextDevice;
119 pDevice = pDeviceList;
121 while (pDevice)
123 pNextDevice = pDevice->pNextDevice;
125 if (pDevice->pszHostDLLFilename)
126 free(pDevice->pszHostDLLFilename);
128 if (pDevice->pszDeviceName)
129 free(pDevice->pszDeviceName);
131 free(pDevice);
133 pDevice = pNextDevice;