2007-11-14 02:02:18 +00:00
|
|
|
/**
|
|
|
|
* OpenAL cross platform audio library
|
|
|
|
* Copyright (C) 1999-2007 by authors.
|
|
|
|
* 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 library 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.
|
|
|
|
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
|
|
|
*/
|
|
|
|
|
2008-01-16 22:09:04 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-03-01 09:39:42 +00:00
|
|
|
#define _WIN32_WINNT 0x0500
|
2007-11-14 02:02:18 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <memory.h>
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
|
|
|
|
|
|
|
#include "alMain.h"
|
|
|
|
#include "AL/al.h"
|
|
|
|
#include "AL/alc.h"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2010-11-26 01:37:34 +00:00
|
|
|
// MMSYSTEM Device
|
|
|
|
volatile ALboolean bWaveShutdown;
|
2010-11-27 22:13:40 +00:00
|
|
|
HANDLE hWaveHdrEvent;
|
|
|
|
HANDLE hWaveThreadEvent;
|
|
|
|
HANDLE hWaveThread;
|
|
|
|
DWORD ulWaveThreadID;
|
|
|
|
LONG lWaveBuffersCommitted;
|
|
|
|
WAVEHDR WaveBuffer[4];
|
2010-11-26 01:37:34 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
HWAVEIN In;
|
2010-11-27 22:13:40 +00:00
|
|
|
HWAVEOUT Out;
|
2010-11-26 01:37:34 +00:00
|
|
|
} hWaveHandle;
|
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
ALsizei Frequency;
|
|
|
|
|
|
|
|
RingBuffer *pRing;
|
2007-11-14 02:02:18 +00:00
|
|
|
} WinMMData;
|
|
|
|
|
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
static const ALCchar woDefault[] = "WaveOut Default";
|
|
|
|
|
|
|
|
static ALCchar **PlaybackDeviceList;
|
|
|
|
static ALuint NumPlaybackDevices;
|
2009-08-27 08:47:41 +00:00
|
|
|
static ALCchar **CaptureDeviceList;
|
|
|
|
static ALuint NumCaptureDevices;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
|
|
|
|
static void ProbePlaybackDevices(void)
|
|
|
|
{
|
|
|
|
ALuint i;
|
|
|
|
|
|
|
|
for(i = 0;i < NumPlaybackDevices;i++)
|
|
|
|
free(PlaybackDeviceList[i]);
|
|
|
|
|
|
|
|
NumPlaybackDevices = waveOutGetNumDevs();
|
|
|
|
PlaybackDeviceList = realloc(PlaybackDeviceList, sizeof(ALCchar*) * NumPlaybackDevices);
|
|
|
|
for(i = 0;i < NumPlaybackDevices;i++)
|
|
|
|
{
|
|
|
|
WAVEOUTCAPS WaveCaps;
|
|
|
|
|
|
|
|
PlaybackDeviceList[i] = NULL;
|
|
|
|
if(waveOutGetDevCaps(i, &WaveCaps, sizeof(WaveCaps)) == MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
char name[1024];
|
|
|
|
ALuint count, j;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
do {
|
|
|
|
if(count == 0)
|
|
|
|
snprintf(name, sizeof(name), "%s via WaveOut", WaveCaps.szPname);
|
|
|
|
else
|
|
|
|
snprintf(name, sizeof(name), "%s #%d via WaveOut", WaveCaps.szPname, count+1);
|
|
|
|
count++;
|
|
|
|
|
|
|
|
for(j = 0;j < i;j++)
|
|
|
|
{
|
|
|
|
if(strcmp(name, PlaybackDeviceList[j]) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while(j != i);
|
|
|
|
|
|
|
|
PlaybackDeviceList[i] = strdup(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
static void ProbeCaptureDevices(void)
|
2010-03-09 13:44:18 +00:00
|
|
|
{
|
|
|
|
ALuint i;
|
|
|
|
|
|
|
|
for(i = 0;i < NumCaptureDevices;i++)
|
|
|
|
free(CaptureDeviceList[i]);
|
|
|
|
|
|
|
|
NumCaptureDevices = waveInGetNumDevs();
|
|
|
|
CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices);
|
|
|
|
for(i = 0;i < NumCaptureDevices;i++)
|
|
|
|
{
|
|
|
|
WAVEINCAPS WaveInCaps;
|
|
|
|
|
|
|
|
CaptureDeviceList[i] = NULL;
|
|
|
|
if(waveInGetDevCaps(i, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR)
|
|
|
|
{
|
2010-06-01 02:04:41 +00:00
|
|
|
char name[1024];
|
2010-06-10 22:54:04 +00:00
|
|
|
ALuint count, j;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
do {
|
|
|
|
if(count == 0)
|
|
|
|
snprintf(name, sizeof(name), "%s via WaveIn", WaveInCaps.szPname);
|
|
|
|
else
|
|
|
|
snprintf(name, sizeof(name), "%s #%d via WaveIn", WaveInCaps.szPname, count+1);
|
|
|
|
count++;
|
|
|
|
|
|
|
|
for(j = 0;j < i;j++)
|
|
|
|
{
|
|
|
|
if(strcmp(name, CaptureDeviceList[j]) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while(j != i);
|
|
|
|
|
2010-03-09 13:44:18 +00:00
|
|
|
CaptureDeviceList[i] = strdup(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
/*
|
|
|
|
WaveOutProc
|
|
|
|
|
|
|
|
Posts a message to 'PlaybackThreadProc' everytime a WaveOut Buffer is completed and
|
|
|
|
returns to the application (for more data)
|
|
|
|
*/
|
|
|
|
static void CALLBACK WaveOutProc(HWAVEOUT hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2)
|
|
|
|
{
|
|
|
|
ALCdevice *pDevice = (ALCdevice*)dwInstance;
|
|
|
|
WinMMData *pData = pDevice->ExtraData;
|
|
|
|
|
|
|
|
(void)hDevice;
|
|
|
|
(void)dwParam2;
|
|
|
|
|
|
|
|
if(uMsg != WOM_DONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Decrement number of buffers in use
|
|
|
|
InterlockedDecrement(&pData->lWaveBuffersCommitted);
|
|
|
|
|
|
|
|
if(pData->bWaveShutdown == AL_FALSE)
|
|
|
|
{
|
|
|
|
// Notify Wave Processor Thread that a Wave Header has returned
|
|
|
|
PostThreadMessage(pData->ulWaveThreadID, uMsg, 0, dwParam1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(pData->lWaveBuffersCommitted == 0)
|
|
|
|
{
|
|
|
|
// Signal Wave Buffers Returned event
|
|
|
|
if(pData->hWaveHdrEvent)
|
|
|
|
SetEvent(pData->hWaveHdrEvent);
|
|
|
|
|
|
|
|
// Post 'Quit' Message to WaveOut Processor Thread
|
|
|
|
PostThreadMessage(pData->ulWaveThreadID, WM_QUIT, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
PlaybackThreadProc
|
|
|
|
|
|
|
|
Used by "MMSYSTEM" Device. Called when a WaveOut buffer has used up its
|
|
|
|
audio data.
|
|
|
|
*/
|
|
|
|
static DWORD WINAPI PlaybackThreadProc(LPVOID lpParameter)
|
|
|
|
{
|
|
|
|
ALCdevice *pDevice = (ALCdevice*)lpParameter;
|
|
|
|
WinMMData *pData = pDevice->ExtraData;
|
|
|
|
LPWAVEHDR pWaveHdr;
|
|
|
|
ALuint FrameSize;
|
|
|
|
MSG msg;
|
|
|
|
|
2010-12-05 03:50:00 +00:00
|
|
|
FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType);
|
2010-11-27 22:13:40 +00:00
|
|
|
|
|
|
|
while(GetMessage(&msg, NULL, 0, 0))
|
|
|
|
{
|
|
|
|
if(msg.message != WOM_DONE || pData->bWaveShutdown)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pWaveHdr = ((LPWAVEHDR)msg.lParam);
|
|
|
|
|
|
|
|
aluMixData(pDevice, pWaveHdr->lpData, pWaveHdr->dwBufferLength/FrameSize);
|
|
|
|
|
|
|
|
// Send buffer back to play more data
|
|
|
|
waveOutWrite(pData->hWaveHandle.Out, pWaveHdr, sizeof(WAVEHDR));
|
|
|
|
InterlockedIncrement(&pData->lWaveBuffersCommitted);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Signal Wave Thread completed event
|
|
|
|
if(pData->hWaveThreadEvent)
|
|
|
|
SetEvent(pData->hWaveThreadEvent);
|
|
|
|
|
|
|
|
ExitThread(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
/*
|
|
|
|
WaveInProc
|
|
|
|
|
|
|
|
Posts a message to 'CaptureThreadProc' everytime a WaveIn Buffer is completed and
|
|
|
|
returns to the application (with more data)
|
|
|
|
*/
|
|
|
|
static void CALLBACK WaveInProc(HWAVEIN hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2)
|
|
|
|
{
|
2010-07-07 09:47:29 +00:00
|
|
|
ALCdevice *pDevice = (ALCdevice*)dwInstance;
|
2007-11-14 02:02:18 +00:00
|
|
|
WinMMData *pData = pDevice->ExtraData;
|
|
|
|
|
|
|
|
(void)hDevice;
|
|
|
|
(void)dwParam2;
|
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
if(uMsg != WIM_DATA)
|
|
|
|
return;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
// Decrement number of buffers in use
|
2010-11-27 22:13:40 +00:00
|
|
|
InterlockedDecrement(&pData->lWaveBuffersCommitted);
|
2010-07-07 09:47:29 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->bWaveShutdown == AL_FALSE)
|
2010-07-07 09:47:29 +00:00
|
|
|
{
|
|
|
|
// Notify Wave Processor Thread that a Wave Header has returned
|
2010-11-26 01:37:34 +00:00
|
|
|
PostThreadMessage(pData->ulWaveThreadID,uMsg,0,dwParam1);
|
2010-07-07 09:47:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->lWaveBuffersCommitted == 0)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2010-07-07 09:47:29 +00:00
|
|
|
// Signal Wave Buffers Returned event
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->hWaveHdrEvent)
|
|
|
|
SetEvent(pData->hWaveHdrEvent);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
// Post 'Quit' Message to WaveIn Processor Thread
|
2010-11-26 01:37:34 +00:00
|
|
|
PostThreadMessage(pData->ulWaveThreadID,WM_QUIT,0,0);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CaptureThreadProc
|
|
|
|
|
|
|
|
Used by "MMSYSTEM" Device. Called when a WaveIn buffer had been filled with new
|
|
|
|
audio data.
|
|
|
|
*/
|
2010-07-08 22:10:59 +00:00
|
|
|
static DWORD WINAPI CaptureThreadProc(LPVOID lpParameter)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCdevice *pDevice = (ALCdevice*)lpParameter;
|
|
|
|
WinMMData *pData = pDevice->ExtraData;
|
|
|
|
LPWAVEHDR pWaveHdr;
|
2010-07-07 09:47:29 +00:00
|
|
|
ALuint FrameSize;
|
2007-11-14 02:02:18 +00:00
|
|
|
MSG msg;
|
|
|
|
|
2010-12-05 03:50:00 +00:00
|
|
|
FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
while(GetMessage(&msg, NULL, 0, 0))
|
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
if(msg.message != WIM_DATA || pData->bWaveShutdown)
|
2010-07-07 09:47:29 +00:00
|
|
|
continue;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
pWaveHdr = ((LPWAVEHDR)msg.lParam);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
WriteRingBuffer(pData->pRing, (ALubyte*)pWaveHdr->lpData,
|
|
|
|
pWaveHdr->dwBytesRecorded/FrameSize);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
// Send buffer back to capture more data
|
2010-11-26 01:37:34 +00:00
|
|
|
waveInAddBuffer(pData->hWaveHandle.In,pWaveHdr,sizeof(WAVEHDR));
|
2010-11-27 22:13:40 +00:00
|
|
|
InterlockedIncrement(&pData->lWaveBuffersCommitted);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Signal Wave Thread completed event
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->hWaveThreadEvent)
|
|
|
|
SetEvent(pData->hWaveThreadEvent);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
ExitThread(0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
static ALCboolean WinMMOpenPlayback(ALCdevice *pDevice, const ALCchar *deviceName)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2010-11-27 22:13:40 +00:00
|
|
|
WAVEFORMATEX wfexFormat;
|
|
|
|
WinMMData *pData = NULL;
|
2011-02-08 18:33:18 +00:00
|
|
|
UINT lDeviceID = 0;
|
2010-11-27 22:13:40 +00:00
|
|
|
MMRESULT res;
|
|
|
|
ALuint i = 0;
|
|
|
|
|
|
|
|
// Find the Device ID matching the deviceName if valid
|
|
|
|
if(!deviceName || strcmp(deviceName, woDefault) == 0)
|
|
|
|
lDeviceID = WAVE_MAPPER;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!PlaybackDeviceList)
|
|
|
|
ProbePlaybackDevices();
|
|
|
|
|
|
|
|
for(i = 0;i < NumPlaybackDevices;i++)
|
|
|
|
{
|
|
|
|
if(PlaybackDeviceList[i] &&
|
|
|
|
strcmp(deviceName, PlaybackDeviceList[i]) == 0)
|
|
|
|
{
|
|
|
|
lDeviceID = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(i == NumPlaybackDevices)
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pData = calloc(1, sizeof(*pData));
|
|
|
|
if(!pData)
|
|
|
|
{
|
|
|
|
alcSetError(pDevice, ALC_OUT_OF_MEMORY);
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
pDevice->ExtraData = pData;
|
|
|
|
|
2010-12-05 03:50:00 +00:00
|
|
|
if(pDevice->FmtChans != DevFmtMono)
|
|
|
|
pDevice->FmtChans = DevFmtStereo;
|
|
|
|
switch(pDevice->FmtType)
|
2010-11-27 22:13:40 +00:00
|
|
|
{
|
2010-12-05 03:50:00 +00:00
|
|
|
case DevFmtByte:
|
|
|
|
pDevice->FmtType = DevFmtUByte;
|
|
|
|
break;
|
|
|
|
case DevFmtUShort:
|
|
|
|
case DevFmtFloat:
|
|
|
|
pDevice->FmtType = DevFmtShort;
|
|
|
|
break;
|
|
|
|
case DevFmtUByte:
|
|
|
|
case DevFmtShort:
|
|
|
|
break;
|
2010-11-27 22:13:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memset(&wfexFormat, 0, sizeof(WAVEFORMATEX));
|
|
|
|
wfexFormat.wFormatTag = WAVE_FORMAT_PCM;
|
2010-12-05 03:50:00 +00:00
|
|
|
wfexFormat.nChannels = ChannelsFromDevFmt(pDevice->FmtChans);
|
|
|
|
wfexFormat.wBitsPerSample = BytesFromDevFmt(pDevice->FmtType) * 8;
|
2010-11-27 22:13:40 +00:00
|
|
|
wfexFormat.nBlockAlign = wfexFormat.wBitsPerSample *
|
|
|
|
wfexFormat.nChannels / 8;
|
|
|
|
wfexFormat.nSamplesPerSec = pDevice->Frequency;
|
|
|
|
wfexFormat.nAvgBytesPerSec = wfexFormat.nSamplesPerSec *
|
|
|
|
wfexFormat.nBlockAlign;
|
|
|
|
wfexFormat.cbSize = 0;
|
|
|
|
|
|
|
|
if((res=waveOutOpen(&pData->hWaveHandle.Out, lDeviceID, &wfexFormat, (DWORD_PTR)&WaveOutProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION)) != MMSYSERR_NOERROR)
|
|
|
|
{
|
|
|
|
AL_PRINT("waveInOpen failed: %u\n", res);
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
pData->hWaveHdrEvent = CreateEvent(NULL, AL_TRUE, AL_FALSE, "WaveOutAllHeadersReturned");
|
|
|
|
pData->hWaveThreadEvent = CreateEvent(NULL, AL_TRUE, AL_FALSE, "WaveOutThreadDestroyed");
|
|
|
|
if(pData->hWaveHdrEvent == NULL || pData->hWaveThreadEvent == NULL)
|
|
|
|
{
|
|
|
|
AL_PRINT("CreateEvent failed: %lu\n", GetLastError());
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
pData->Frequency = pDevice->Frequency;
|
|
|
|
|
|
|
|
pDevice->szDeviceName = strdup((lDeviceID==WAVE_MAPPER) ? woDefault :
|
|
|
|
PlaybackDeviceList[lDeviceID]);
|
|
|
|
return ALC_TRUE;
|
|
|
|
|
|
|
|
failure:
|
|
|
|
if(pData->hWaveThreadEvent)
|
|
|
|
CloseHandle(pData->hWaveThreadEvent);
|
|
|
|
if(pData->hWaveHdrEvent)
|
|
|
|
CloseHandle(pData->hWaveHdrEvent);
|
|
|
|
|
|
|
|
if(pData->hWaveHandle.Out)
|
|
|
|
waveOutClose(pData->hWaveHandle.Out);
|
|
|
|
|
|
|
|
free(pData);
|
|
|
|
pDevice->ExtraData = NULL;
|
2007-11-14 02:02:18 +00:00
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WinMMClosePlayback(ALCdevice *device)
|
|
|
|
{
|
2010-11-27 22:13:40 +00:00
|
|
|
WinMMData *pData = (WinMMData*)device->ExtraData;
|
|
|
|
|
|
|
|
// Close the Wave device
|
|
|
|
CloseHandle(pData->hWaveThreadEvent);
|
|
|
|
pData->hWaveThreadEvent = 0;
|
|
|
|
|
|
|
|
CloseHandle(pData->hWaveHdrEvent);
|
|
|
|
pData->hWaveHdrEvent = 0;
|
|
|
|
|
|
|
|
waveInClose(pData->hWaveHandle.In);
|
|
|
|
pData->hWaveHandle.In = 0;
|
|
|
|
|
|
|
|
free(pData);
|
|
|
|
device->ExtraData = NULL;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
static ALCboolean WinMMResetPlayback(ALCdevice *device)
|
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)device->ExtraData;
|
|
|
|
ALbyte *BufferData;
|
|
|
|
ALint lBufferSize;
|
|
|
|
ALuint i;
|
|
|
|
|
|
|
|
pData->hWaveThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlaybackThreadProc, (LPVOID)device, 0, &pData->ulWaveThreadID);
|
|
|
|
if(pData->hWaveThread == NULL)
|
|
|
|
return ALC_FALSE;
|
|
|
|
|
|
|
|
device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize *
|
|
|
|
pData->Frequency / device->Frequency);
|
2011-05-03 09:29:26 +00:00
|
|
|
if(device->Frequency != streamInfo->sampleRate)
|
|
|
|
{
|
|
|
|
if((device->Flags&DEVICE_FREQUENCY_REQUEST))
|
|
|
|
AL_PRINT("WinMM does not support changing sample rates (wanted %dhz, got %dhz)\n", device->Frequency, pData->Frequency);
|
|
|
|
device->Flags &= ~DEVICE_FREQUENCY_REQUEST;
|
|
|
|
device->Frequency = pData->Frequency;
|
|
|
|
}
|
2010-11-27 22:13:40 +00:00
|
|
|
|
|
|
|
pData->lWaveBuffersCommitted = 0;
|
|
|
|
|
|
|
|
// Create 4 Buffers
|
|
|
|
lBufferSize = device->UpdateSize*device->NumUpdates / 4;
|
2010-12-05 03:50:00 +00:00
|
|
|
lBufferSize *= FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
|
2010-11-27 22:13:40 +00:00
|
|
|
|
|
|
|
BufferData = calloc(4, lBufferSize);
|
|
|
|
for(i = 0;i < 4;i++)
|
|
|
|
{
|
|
|
|
memset(&pData->WaveBuffer[i], 0, sizeof(WAVEHDR));
|
|
|
|
pData->WaveBuffer[i].dwBufferLength = lBufferSize;
|
|
|
|
pData->WaveBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData :
|
|
|
|
(pData->WaveBuffer[i-1].lpData +
|
|
|
|
pData->WaveBuffer[i-1].dwBufferLength));
|
|
|
|
waveOutPrepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
|
|
|
waveOutWrite(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
|
|
|
InterlockedIncrement(&pData->lWaveBuffersCommitted);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ALC_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WinMMStopPlayback(ALCdevice *device)
|
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)device->ExtraData;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(pData->hWaveThread == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Set flag to stop processing headers
|
|
|
|
pData->bWaveShutdown = AL_TRUE;
|
|
|
|
|
|
|
|
// Wait for signal that all Wave Buffers have returned
|
|
|
|
WaitForSingleObjectEx(pData->hWaveHdrEvent, 5000, FALSE);
|
|
|
|
|
|
|
|
// Wait for signal that Wave Thread has been destroyed
|
|
|
|
WaitForSingleObjectEx(pData->hWaveThreadEvent, 5000, FALSE);
|
|
|
|
|
|
|
|
CloseHandle(pData->hWaveThread);
|
|
|
|
pData->hWaveThread = 0;
|
|
|
|
|
|
|
|
pData->bWaveShutdown = AL_FALSE;
|
|
|
|
|
|
|
|
// Release the wave buffers
|
|
|
|
for(i = 0;i < 4;i++)
|
|
|
|
{
|
|
|
|
waveOutUnprepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
|
|
|
if(i == 0)
|
|
|
|
free(pData->WaveBuffer[i].lpData);
|
|
|
|
pData->WaveBuffer[i].lpData = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-14 02:36:14 +00:00
|
|
|
static ALCboolean WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
WAVEFORMATEX wfexCaptureFormat;
|
2010-07-07 09:47:29 +00:00
|
|
|
DWORD ulCapturedDataSize;
|
2007-11-14 02:02:18 +00:00
|
|
|
WinMMData *pData = NULL;
|
2011-02-08 18:33:18 +00:00
|
|
|
UINT lDeviceID = 0;
|
2010-07-12 23:37:44 +00:00
|
|
|
ALbyte *BufferData;
|
2007-11-14 02:02:18 +00:00
|
|
|
ALint lBufferSize;
|
2010-08-01 23:20:28 +00:00
|
|
|
MMRESULT res;
|
2009-08-27 08:47:41 +00:00
|
|
|
ALuint i;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-03-09 14:09:29 +00:00
|
|
|
if(!CaptureDeviceList)
|
2010-11-26 01:37:34 +00:00
|
|
|
ProbeCaptureDevices();
|
2010-03-09 14:09:29 +00:00
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
// Find the Device ID matching the deviceName if valid
|
2010-03-09 13:44:18 +00:00
|
|
|
if(deviceName)
|
|
|
|
{
|
|
|
|
for(i = 0;i < NumCaptureDevices;i++)
|
|
|
|
{
|
|
|
|
if(CaptureDeviceList[i] &&
|
|
|
|
strcmp(deviceName, CaptureDeviceList[i]) == 0)
|
|
|
|
{
|
|
|
|
lDeviceID = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-27 08:47:41 +00:00
|
|
|
for(i = 0;i < NumCaptureDevices;i++)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2010-03-09 13:44:18 +00:00
|
|
|
if(CaptureDeviceList[i])
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
lDeviceID = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-03-09 13:44:18 +00:00
|
|
|
if(i == NumCaptureDevices)
|
|
|
|
return ALC_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
pData = calloc(1, sizeof(*pData));
|
|
|
|
if(!pData)
|
|
|
|
{
|
2009-12-29 07:19:13 +00:00
|
|
|
alcSetError(pDevice, ALC_OUT_OF_MEMORY);
|
2007-11-14 02:02:18 +00:00
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2010-11-27 22:13:40 +00:00
|
|
|
pDevice->ExtraData = pData;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-12-05 03:50:00 +00:00
|
|
|
if((pDevice->FmtChans != DevFmtMono && pDevice->FmtChans != DevFmtStereo) ||
|
|
|
|
(pDevice->FmtType != DevFmtUByte && pDevice->FmtType != DevFmtShort))
|
|
|
|
{
|
|
|
|
alcSetError(pDevice, ALC_INVALID_ENUM);
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
memset(&wfexCaptureFormat, 0, sizeof(WAVEFORMATEX));
|
|
|
|
wfexCaptureFormat.wFormatTag = WAVE_FORMAT_PCM;
|
2010-12-05 03:50:00 +00:00
|
|
|
wfexCaptureFormat.nChannels = ChannelsFromDevFmt(pDevice->FmtChans);
|
|
|
|
wfexCaptureFormat.wBitsPerSample = BytesFromDevFmt(pDevice->FmtType) * 8;
|
2008-02-15 06:05:56 +00:00
|
|
|
wfexCaptureFormat.nBlockAlign = wfexCaptureFormat.wBitsPerSample *
|
|
|
|
wfexCaptureFormat.nChannels / 8;
|
2009-08-14 02:36:14 +00:00
|
|
|
wfexCaptureFormat.nSamplesPerSec = pDevice->Frequency;
|
2007-11-14 02:02:18 +00:00
|
|
|
wfexCaptureFormat.nAvgBytesPerSec = wfexCaptureFormat.nSamplesPerSec *
|
2008-02-15 06:05:56 +00:00
|
|
|
wfexCaptureFormat.nBlockAlign;
|
2007-11-14 02:02:18 +00:00
|
|
|
wfexCaptureFormat.cbSize = 0;
|
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
if((res=waveInOpen(&pData->hWaveHandle.In, lDeviceID, &wfexCaptureFormat, (DWORD_PTR)&WaveInProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION)) != MMSYSERR_NOERROR)
|
2010-08-01 23:20:28 +00:00
|
|
|
{
|
|
|
|
AL_PRINT("waveInOpen failed: %u\n", res);
|
2007-11-14 02:02:18 +00:00
|
|
|
goto failure;
|
2010-08-01 23:20:28 +00:00
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
pData->hWaveHdrEvent = CreateEvent(NULL, AL_TRUE, AL_FALSE, "WaveInAllHeadersReturned");
|
|
|
|
pData->hWaveThreadEvent = CreateEvent(NULL, AL_TRUE, AL_FALSE, "WaveInThreadDestroyed");
|
|
|
|
if(pData->hWaveHdrEvent == NULL || pData->hWaveThreadEvent == NULL)
|
2010-08-01 23:20:28 +00:00
|
|
|
{
|
|
|
|
AL_PRINT("CreateEvent failed: %lu\n", GetLastError());
|
2007-11-14 02:02:18 +00:00
|
|
|
goto failure;
|
2010-08-01 23:20:28 +00:00
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
pData->Frequency = pDevice->Frequency;
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
// Allocate circular memory buffer for the captured audio
|
2010-07-07 09:47:29 +00:00
|
|
|
ulCapturedDataSize = pDevice->UpdateSize*pDevice->NumUpdates;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
// Make sure circular buffer is at least 100ms in size
|
|
|
|
if(ulCapturedDataSize < (wfexCaptureFormat.nSamplesPerSec / 10))
|
|
|
|
ulCapturedDataSize = wfexCaptureFormat.nSamplesPerSec / 10;
|
|
|
|
|
|
|
|
pData->pRing = CreateRingBuffer(wfexCaptureFormat.nBlockAlign, ulCapturedDataSize);
|
|
|
|
if(!pData->pRing)
|
|
|
|
goto failure;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
pData->lWaveBuffersCommitted = 0;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
// Create 4 Buffers of 50ms each
|
|
|
|
lBufferSize = wfexCaptureFormat.nAvgBytesPerSec / 20;
|
|
|
|
lBufferSize -= (lBufferSize % wfexCaptureFormat.nBlockAlign);
|
|
|
|
|
2010-07-12 23:37:44 +00:00
|
|
|
BufferData = calloc(4, lBufferSize);
|
|
|
|
if(!BufferData)
|
|
|
|
goto failure;
|
|
|
|
|
2010-07-09 00:37:35 +00:00
|
|
|
for(i = 0;i < 4;i++)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
memset(&pData->WaveBuffer[i], 0, sizeof(WAVEHDR));
|
|
|
|
pData->WaveBuffer[i].dwBufferLength = lBufferSize;
|
|
|
|
pData->WaveBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData :
|
|
|
|
(pData->WaveBuffer[i-1].lpData +
|
|
|
|
pData->WaveBuffer[i-1].dwBufferLength));
|
|
|
|
pData->WaveBuffer[i].dwFlags = 0;
|
|
|
|
pData->WaveBuffer[i].dwLoops = 0;
|
|
|
|
waveInPrepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
|
|
|
waveInAddBuffer(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
2010-11-27 22:13:40 +00:00
|
|
|
InterlockedIncrement(&pData->lWaveBuffersCommitted);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
pData->hWaveThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveThreadID);
|
|
|
|
if (pData->hWaveThread == NULL)
|
2008-02-03 08:28:00 +00:00
|
|
|
goto failure;
|
|
|
|
|
2009-08-27 09:53:09 +00:00
|
|
|
pDevice->szDeviceName = strdup(CaptureDeviceList[lDeviceID]);
|
2007-11-14 02:02:18 +00:00
|
|
|
return ALC_TRUE;
|
|
|
|
|
|
|
|
failure:
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->hWaveThread)
|
|
|
|
CloseHandle(pData->hWaveThread);
|
2010-07-09 00:37:35 +00:00
|
|
|
|
|
|
|
for(i = 0;i < 4;i++)
|
2008-02-03 08:28:00 +00:00
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->WaveBuffer[i].lpData)
|
2008-02-03 08:28:00 +00:00
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
2010-07-12 23:37:44 +00:00
|
|
|
if(i == 0)
|
2010-11-26 01:37:34 +00:00
|
|
|
free(pData->WaveBuffer[i].lpData);
|
2008-02-03 08:28:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-09 00:37:35 +00:00
|
|
|
if(pData->pRing)
|
|
|
|
DestroyRingBuffer(pData->pRing);
|
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->hWaveThreadEvent)
|
|
|
|
CloseHandle(pData->hWaveThreadEvent);
|
|
|
|
if(pData->hWaveHdrEvent)
|
|
|
|
CloseHandle(pData->hWaveHdrEvent);
|
2010-07-09 00:37:35 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
if(pData->hWaveHandle.In)
|
|
|
|
waveInClose(pData->hWaveHandle.In);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
free(pData);
|
2009-08-27 09:53:09 +00:00
|
|
|
pDevice->ExtraData = NULL;
|
2007-11-14 02:02:18 +00:00
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WinMMCloseCapture(ALCdevice *pDevice)
|
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Call waveOutReset to shutdown wave device
|
2010-11-26 01:37:34 +00:00
|
|
|
pData->bWaveShutdown = AL_TRUE;
|
|
|
|
waveInReset(pData->hWaveHandle.In);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
// Wait for signal that all Wave Buffers have returned
|
2010-11-26 01:37:34 +00:00
|
|
|
WaitForSingleObjectEx(pData->hWaveHdrEvent, 5000, FALSE);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
// Wait for signal that Wave Thread has been destroyed
|
2010-11-26 01:37:34 +00:00
|
|
|
WaitForSingleObjectEx(pData->hWaveThreadEvent, 5000, FALSE);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
CloseHandle(pData->hWaveThread);
|
|
|
|
pData->hWaveThread = 0;
|
2010-07-09 00:37:35 +00:00
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
// Release the wave buffers
|
2010-07-09 00:37:35 +00:00
|
|
|
for(i = 0;i < 4;i++)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR));
|
2010-07-12 23:37:44 +00:00
|
|
|
if(i == 0)
|
2010-11-26 01:37:34 +00:00
|
|
|
free(pData->WaveBuffer[i].lpData);
|
|
|
|
pData->WaveBuffer[i].lpData = NULL;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-07-09 00:37:35 +00:00
|
|
|
DestroyRingBuffer(pData->pRing);
|
|
|
|
pData->pRing = NULL;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-07-09 00:37:35 +00:00
|
|
|
// Close the Wave device
|
2010-11-26 01:37:34 +00:00
|
|
|
CloseHandle(pData->hWaveThreadEvent);
|
|
|
|
pData->hWaveThreadEvent = 0;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
CloseHandle(pData->hWaveHdrEvent);
|
|
|
|
pData->hWaveHdrEvent = 0;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-26 01:37:34 +00:00
|
|
|
waveInClose(pData->hWaveHandle.In);
|
|
|
|
pData->hWaveHandle.In = 0;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
free(pData);
|
|
|
|
pDevice->ExtraData = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void WinMMStartCapture(ALCdevice *pDevice)
|
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
2010-11-26 01:37:34 +00:00
|
|
|
waveInStart(pData->hWaveHandle.In);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void WinMMStopCapture(ALCdevice *pDevice)
|
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
2010-11-26 01:37:34 +00:00
|
|
|
waveInStop(pData->hWaveHandle.In);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
static ALCuint WinMMAvailableSamples(ALCdevice *pDevice)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
2010-07-07 09:47:29 +00:00
|
|
|
return RingBufferSize(pData->pRing);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-07-07 09:47:29 +00:00
|
|
|
static void WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
WinMMData *pData = (WinMMData*)pDevice->ExtraData;
|
2010-07-07 09:47:29 +00:00
|
|
|
|
|
|
|
if(WinMMAvailableSamples(pDevice) >= lSamples)
|
|
|
|
ReadRingBuffer(pData->pRing, pBuffer, lSamples);
|
|
|
|
else
|
|
|
|
alcSetError(pDevice, ALC_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-08 22:10:59 +00:00
|
|
|
static BackendFuncs WinMMFuncs = {
|
2007-11-14 02:02:18 +00:00
|
|
|
WinMMOpenPlayback,
|
|
|
|
WinMMClosePlayback,
|
2010-11-27 22:13:40 +00:00
|
|
|
WinMMResetPlayback,
|
|
|
|
WinMMStopPlayback,
|
2007-11-14 02:02:18 +00:00
|
|
|
WinMMOpenCapture,
|
|
|
|
WinMMCloseCapture,
|
|
|
|
WinMMStartCapture,
|
|
|
|
WinMMStopCapture,
|
|
|
|
WinMMCaptureSamples,
|
2010-11-21 14:32:59 +00:00
|
|
|
WinMMAvailableSamples
|
2007-11-14 02:02:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void alcWinMMInit(BackendFuncs *FuncList)
|
2009-08-27 13:09:33 +00:00
|
|
|
{
|
|
|
|
*FuncList = WinMMFuncs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void alcWinMMDeinit()
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-27 08:47:41 +00:00
|
|
|
ALuint lLoop;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
for(lLoop = 0;lLoop < NumPlaybackDevices;lLoop++)
|
|
|
|
free(PlaybackDeviceList[lLoop]);
|
|
|
|
free(PlaybackDeviceList);
|
|
|
|
PlaybackDeviceList = NULL;
|
|
|
|
|
|
|
|
NumPlaybackDevices = 0;
|
|
|
|
|
|
|
|
|
2009-08-27 13:09:33 +00:00
|
|
|
for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++)
|
|
|
|
free(CaptureDeviceList[lLoop]);
|
|
|
|
free(CaptureDeviceList);
|
|
|
|
CaptureDeviceList = NULL;
|
|
|
|
|
|
|
|
NumCaptureDevices = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-28 13:33:59 +00:00
|
|
|
void alcWinMMProbe(int type)
|
2009-08-27 13:09:33 +00:00
|
|
|
{
|
2010-03-09 13:44:18 +00:00
|
|
|
ALuint i;
|
2009-08-27 13:09:33 +00:00
|
|
|
|
2010-11-27 22:13:40 +00:00
|
|
|
if(type == DEVICE_PROBE)
|
|
|
|
{
|
|
|
|
ProbePlaybackDevices();
|
|
|
|
if(NumPlaybackDevices > 0)
|
|
|
|
AppendDeviceList(woDefault);
|
|
|
|
}
|
|
|
|
else if(type == ALL_DEVICE_PROBE)
|
|
|
|
{
|
|
|
|
ProbePlaybackDevices();
|
|
|
|
if(NumPlaybackDevices > 0)
|
|
|
|
AppendAllDeviceList(woDefault);
|
|
|
|
for(i = 0;i < NumPlaybackDevices;i++)
|
|
|
|
{
|
|
|
|
if(PlaybackDeviceList[i])
|
|
|
|
AppendAllDeviceList(PlaybackDeviceList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(type == CAPTURE_DEVICE_PROBE)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2010-11-26 01:37:34 +00:00
|
|
|
ProbeCaptureDevices();
|
|
|
|
for(i = 0;i < NumCaptureDevices;i++)
|
|
|
|
{
|
|
|
|
if(CaptureDeviceList[i])
|
|
|
|
AppendCaptureDeviceList(CaptureDeviceList[i]);
|
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
}
|