Commit 3735ecac authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

dsound: Reimplement capturing devices on mmdevapi.

parent e786998d
...@@ -1343,7 +1343,7 @@ HRESULT DirectSoundDevice_GetCaps( ...@@ -1343,7 +1343,7 @@ HRESULT DirectSoundDevice_GetCaps(
return DS_OK; return DS_OK;
} }
static BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate, BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate,
DWORD depth, WORD channels) DWORD depth, WORD channels)
{ {
WAVEFORMATEX fmt, *junk; WAVEFORMATEX fmt, *junk;
...@@ -1364,7 +1364,7 @@ static BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate, ...@@ -1364,7 +1364,7 @@ static BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate,
return hr == S_OK; return hr == S_OK;
} }
static UINT DSOUND_create_timer(LPTIMECALLBACK cb, DWORD_PTR user) UINT DSOUND_create_timer(LPTIMECALLBACK cb, DWORD_PTR user)
{ {
UINT triggertime = DS_TIME_DEL, res = DS_TIME_RES, id; UINT triggertime = DS_TIME_DEL, res = DS_TIME_RES, id;
TIMECAPS time; TIMECAPS time;
......
...@@ -68,6 +68,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound); ...@@ -68,6 +68,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound);
struct list DSOUND_renderers = LIST_INIT(DSOUND_renderers); struct list DSOUND_renderers = LIST_INIT(DSOUND_renderers);
CRITICAL_SECTION DSOUND_renderers_lock; CRITICAL_SECTION DSOUND_renderers_lock;
struct list DSOUND_capturers = LIST_INIT(DSOUND_capturers);
CRITICAL_SECTION DSOUND_capturers_lock;
GUID DSOUND_renderer_guids[MAXWAVEDRIVERS]; GUID DSOUND_renderer_guids[MAXWAVEDRIVERS];
GUID DSOUND_capture_guids[MAXWAVEDRIVERS]; GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
...@@ -652,64 +655,17 @@ DirectSoundCaptureEnumerateW( ...@@ -652,64 +655,17 @@ DirectSoundCaptureEnumerateW(
LPDSENUMCALLBACKW lpDSEnumCallback, LPDSENUMCALLBACKW lpDSEnumCallback,
LPVOID lpContext) LPVOID lpContext)
{ {
unsigned devs, wid;
DSDRIVERDESC desc;
GUID guid;
int err;
WCHAR wDesc[MAXPNAMELEN];
WCHAR wName[MAXPNAMELEN];
TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext ); TRACE("(%p,%p)\n", lpDSEnumCallback, lpContext );
if (lpDSEnumCallback == NULL) { if (lpDSEnumCallback == NULL) {
WARN("invalid parameter: lpDSEnumCallback == NULL\n"); WARN("invalid parameter: lpDSEnumCallback == NULL\n");
return DSERR_INVALIDPARAM; return DSERR_INVALIDPARAM;
} }
setup_dsound_options(); setup_dsound_options();
devs = waveInGetNumDevs(); return enumerate_mmdevices(eCapture, DSOUND_capture_guids,
if (devs > 0) { lpDSEnumCallback, lpContext);
if (GetDeviceID(&DSDEVID_DefaultCapture, &guid) == DS_OK) {
for (wid = 0; wid < devs; ++wid) {
if (IsEqualGUID( &guid, &DSOUND_capture_guids[wid] ) ) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(NULL,\"%s\",\"%s\",%p)\n",
"Primary Sound Capture Driver",desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, "Primary Sound Capture Driver", -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
wName[(sizeof(wName)/sizeof(WCHAR)) - 1] = '\0';
if (lpDSEnumCallback(NULL, wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
}
}
}
}
for (wid = 0; wid < devs; ++wid) {
err = mmErr(waveInMessage(UlongToHandle(wid),DRV_QUERYDSOUNDDESC,(DWORD_PTR)&desc,0));
if (err == DS_OK) {
TRACE("calling lpDSEnumCallback(%s,\"%s\",\"%s\",%p)\n",
debugstr_guid(&DSOUND_capture_guids[wid]),desc.szDesc,desc.szDrvname,lpContext);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1,
wDesc, sizeof(wDesc)/sizeof(WCHAR) );
wDesc[(sizeof(wDesc)/sizeof(WCHAR)) - 1] = '\0';
MultiByteToWideChar( CP_ACP, 0, desc.szDrvname, -1,
wName, sizeof(wName)/sizeof(WCHAR) );
wName[(sizeof(wName)/sizeof(WCHAR)) - 1] = '\0';
if (lpDSEnumCallback(&DSOUND_capture_guids[wid], wDesc, wName, lpContext) == FALSE)
return DS_OK;
}
}
return DS_OK;
} }
/******************************************************************************* /*******************************************************************************
...@@ -877,21 +833,17 @@ HRESULT WINAPI DllCanUnloadNow(void) ...@@ -877,21 +833,17 @@ HRESULT WINAPI DllCanUnloadNow(void)
*/ */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ {
int i;
TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpvReserved); TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpvReserved);
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
TRACE("DLL_PROCESS_ATTACH\n"); TRACE("DLL_PROCESS_ATTACH\n");
for (i = 0; i < MAXWAVEDRIVERS; i++) {
DSOUND_capture[i] = NULL;
INIT_GUID(DSOUND_capture_guids[i], 0xbd6dd71b, 0x3deb, 0x11d1, 0xb1, 0x71, 0x00, 0xc0, 0x4f, 0xc2, 0x00, 0x00 + i);
}
instance = hInstDLL; instance = hInstDLL;
DisableThreadLibraryCalls(hInstDLL); DisableThreadLibraryCalls(hInstDLL);
/* Increase refcount on dsound by 1 */ /* Increase refcount on dsound by 1 */
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)hInstDLL, &hInstDLL); GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)hInstDLL, &hInstDLL);
InitializeCriticalSection(&DSOUND_renderers_lock); InitializeCriticalSection(&DSOUND_renderers_lock);
InitializeCriticalSection(&DSOUND_capturers_lock);
InitializeCriticalSection(&g_devenum_lock); InitializeCriticalSection(&g_devenum_lock);
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
......
...@@ -280,21 +280,22 @@ struct DirectSoundCaptureDevice ...@@ -280,21 +280,22 @@ struct DirectSoundCaptureDevice
DSDRIVERDESC drvdesc; DSDRIVERDESC drvdesc;
DSCDRIVERCAPS drvcaps; DSCDRIVERCAPS drvcaps;
/* wave driver info */
HWAVEIN hwi;
/* more stuff */ /* more stuff */
LPBYTE buffer; LPBYTE buffer;
DWORD buflen; DWORD buflen, write_pos_bytes;
PWAVEFORMATEX pwfx; PWAVEFORMATEX pwfx;
IDirectSoundCaptureBufferImpl* capture_buffer; IDirectSoundCaptureBufferImpl* capture_buffer;
DWORD state; DWORD state;
LPWAVEHDR pwave; UINT timerID;
int nrofpwaves;
int index;
CRITICAL_SECTION lock; CRITICAL_SECTION lock;
IMMDevice *mmdevice;
IAudioClient *client;
IAudioCaptureClient *capture;
struct list entry;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -428,10 +429,10 @@ HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSP ...@@ -428,10 +429,10 @@ HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSP
#define DSOUND_FREQSHIFT (20) #define DSOUND_FREQSHIFT (20)
extern CRITICAL_SECTION DSOUND_renderers_lock DECLSPEC_HIDDEN; extern CRITICAL_SECTION DSOUND_renderers_lock DECLSPEC_HIDDEN;
extern CRITICAL_SECTION DSOUND_capturers_lock DECLSPEC_HIDDEN;
extern struct list DSOUND_capturers DECLSPEC_HIDDEN;
extern struct list DSOUND_renderers DECLSPEC_HIDDEN; extern struct list DSOUND_renderers DECLSPEC_HIDDEN;
extern DirectSoundCaptureDevice * DSOUND_capture[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN; extern GUID DSOUND_renderer_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN; extern GUID DSOUND_capture_guids[MAXWAVEDRIVERS] DECLSPEC_HIDDEN;
...@@ -440,3 +441,7 @@ void setup_dsound_options(void) DECLSPEC_HIDDEN; ...@@ -440,3 +441,7 @@ void setup_dsound_options(void) DECLSPEC_HIDDEN;
const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN; const char * dumpCooperativeLevel(DWORD level) DECLSPEC_HIDDEN;
HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device) DECLSPEC_HIDDEN; HRESULT get_mmdevice(EDataFlow flow, const GUID *tgt, IMMDevice **device) DECLSPEC_HIDDEN;
BOOL DSOUND_check_supported(IAudioClient *client, DWORD rate,
DWORD depth, WORD channels) DECLSPEC_HIDDEN;
UINT DSOUND_create_timer(LPTIMECALLBACK cb, DWORD_PTR user) DECLSPEC_HIDDEN;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment