Commit 50b46daf authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Alexandre Julliard

winealsa: Add initial dscapturedriver stub.

parent b42287ca
......@@ -8,6 +8,7 @@ EXTRALIBS = -ldxguid -luuid @ALSALIBS@
C_SRCS = \
alsa.c \
dscapture.c \
dsoutput.c \
midi.c \
mixer.c \
......
......@@ -193,6 +193,10 @@ int ALSA_XRUNRecovery(WINE_WAVEDEV * wwo, int err);
void ALSA_copyFormat(LPWAVEFORMATEX wf1, LPWAVEFORMATPCMEX wf2);
BOOL ALSA_supportedFormat(LPWAVEFORMATEX wf);
/* dscapture.c */
DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv);
DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc);
/* dsoutput.c */
DWORD wodDsCreate(UINT wDevID, PIDSDRIVER* drv);
DWORD wodDsDesc(UINT wDevID, PDSDRIVERDESC desc);
......
/*
* Sample Wine Driver for Advanced Linux Sound System (ALSA)
* Based on version <final> of the ALSA API
*
* Copyright 2007 - Maarten Lankhorst
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*======================================================================*
* Low level dsound input implementation *
*======================================================================*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winerror.h"
#include "winuser.h"
#include "mmddk.h"
#include "alsa.h"
#include "wine/library.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#ifdef HAVE_ALSA
WINE_DEFAULT_DEBUG_CHANNEL(dsalsa);
typedef struct IDsCaptureDriverImpl IDsCaptureDriverImpl;
struct IDsCaptureDriverImpl
{
/* IUnknown fields */
const IDsCaptureDriverVtbl *lpVtbl;
LONG ref;
/* IDsCaptureDriverImpl fields */
UINT wDevID;
};
static HRESULT WINAPI IDsCaptureDriverImpl_QueryInterface(PIDSCDRIVER iface, REFIID riid, LPVOID *ppobj)
{
/* IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface; */
FIXME("(%p): stub!\n",iface);
return DSERR_UNSUPPORTED;
}
static ULONG WINAPI IDsCaptureDriverImpl_AddRef(PIDSCDRIVER iface)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsCaptureDriverImpl_Release(PIDSCDRIVER iface)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
if (refCount)
return refCount;
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
static HRESULT WINAPI IDsCaptureDriverImpl_GetDriverDesc(PIDSCDRIVER iface, PDSDRIVERDESC pDesc)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
TRACE("(%p,%p)\n",iface,pDesc);
memcpy(pDesc, &(WInDev[This->wDevID].ds_desc), sizeof(DSDRIVERDESC));
pDesc->dwFlags = 0;
pDesc->dnDevNode = WInDev[This->wDevID].waveDesc.dnDevNode;
pDesc->wVxdId = 0;
pDesc->wReserved = 0;
pDesc->ulDeviceNum = This->wDevID;
pDesc->dwHeapType = DSDHEAP_NOHEAP;
pDesc->pvDirectDrawHeap = NULL;
pDesc->dwMemStartAddress = 0xDEAD0000;
pDesc->dwMemEndAddress = 0xDEAF0000;
pDesc->dwMemAllocExtra = 0;
pDesc->pvReserved1 = NULL;
pDesc->pvReserved2 = NULL;
return DS_OK;
}
static HRESULT WINAPI IDsCaptureDriverImpl_Open(PIDSCDRIVER iface)
{
FIXME("stub\n");
return DS_OK;
}
static HRESULT WINAPI IDsCaptureDriverImpl_Close(PIDSCDRIVER iface)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
TRACE("(%p) stub, harmless\n",This);
return DS_OK;
}
static HRESULT WINAPI IDsCaptureDriverImpl_GetCaps(PIDSCDRIVER iface, PDSCDRIVERCAPS pCaps)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
WINE_WAVEDEV *wwi = &WInDev[This->wDevID];
TRACE("(%p,%p)\n",iface,pCaps);
pCaps->dwSize = sizeof(DSCDRIVERCAPS);
pCaps->dwFlags = wwi->ds_caps.dwFlags;
pCaps->dwFormats = wwi->incaps.dwFormats;
pCaps->dwChannels = wwi->incaps.wChannels;
return DS_OK;
}
static HRESULT WINAPI IDsCaptureDriverImpl_CreateCaptureBuffer(PIDSCDRIVER iface,
LPWAVEFORMATEX pwfx,
DWORD dwFlags, DWORD dwCardAddress,
LPDWORD pdwcbBufferSize,
LPBYTE *ppbBuffer,
LPVOID *ppvObj)
{
FIXME("stub!\n");
return DSERR_GENERIC;
}
static const IDsCaptureDriverVtbl dscdvt =
{
IDsCaptureDriverImpl_QueryInterface,
IDsCaptureDriverImpl_AddRef,
IDsCaptureDriverImpl_Release,
IDsCaptureDriverImpl_GetDriverDesc,
IDsCaptureDriverImpl_Open,
IDsCaptureDriverImpl_Close,
IDsCaptureDriverImpl_GetCaps,
IDsCaptureDriverImpl_CreateCaptureBuffer
};
/**************************************************************************
* widDsCreate [internal]
*/
DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv)
{
IDsCaptureDriverImpl** idrv = (IDsCaptureDriverImpl**)drv;
TRACE("(%d,%p)\n",wDevID,drv);
if (!(WInDev[wDevID].dwSupport & WAVECAPS_DIRECTSOUND))
{
WARN("Hardware accelerated capture not supported, falling back to wavein\n");
return MMSYSERR_NOTSUPPORTED;
}
*idrv = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDsCaptureDriverImpl));
if (!*idrv)
return MMSYSERR_NOMEM;
(*idrv)->lpVtbl = &dscdvt;
(*idrv)->ref = 1;
(*idrv)->wDevID = wDevID;
return MMSYSERR_NOERROR;
}
/**************************************************************************
* widDsDesc [internal]
*/
DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc)
{
memcpy(desc, &(WInDev[wDevID].ds_desc), sizeof(DSDRIVERDESC));
return MMSYSERR_NOERROR;
}
#endif /* HAVE_ALSA */
......@@ -452,10 +452,6 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
return MMSYSERR_ALLOCATED;
}
if ((dwFlags & WAVE_DIRECTSOUND) && !(wwi->dwSupport & WAVECAPS_DIRECTSOUND))
/* not supported, ignore it */
dwFlags &= ~WAVE_DIRECTSOUND;
wwi->pcm = 0;
flags = SND_PCM_NONBLOCK;
......@@ -559,7 +555,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
err = snd_pcm_hw_params_get_buffer_size(hw_params, &buffer_size);
snd_pcm_sw_params_current(pcm, sw_params);
EXIT_ON_ERROR( snd_pcm_sw_params_set_start_threshold(pcm, sw_params, dwFlags & WAVE_DIRECTSOUND ? INT_MAX : 1 ), MMSYSERR_ERROR, "unable to set start threshold");
EXIT_ON_ERROR( snd_pcm_sw_params_set_start_threshold(pcm, sw_params, 1), MMSYSERR_ERROR, "unable to set start threshold");
EXIT_ON_ERROR( snd_pcm_sw_params_set_silence_size(pcm, sw_params, 0), MMSYSERR_ERROR, "unable to set silence size");
EXIT_ON_ERROR( snd_pcm_sw_params_set_avail_min(pcm, sw_params, period_size), MMSYSERR_ERROR, "unable to set avail min");
EXIT_ON_ERROR( snd_pcm_sw_params_set_xfer_align(pcm, sw_params, 1), MMSYSERR_ERROR, "unable to set xfer align");
......@@ -594,17 +590,12 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwi->format.Format.nSamplesPerSec, wwi->format.Format.nChannels,
wwi->format.Format.nBlockAlign);
if (!(dwFlags & WAVE_DIRECTSOUND)) {
wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID));
if (wwi->hThread)
SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwi->hStartUpEvent, INFINITE);
CloseHandle(wwi->hStartUpEvent);
} else {
wwi->hThread = INVALID_HANDLE_VALUE;
wwi->dwThreadID = 0;
}
wwi->hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
wwi->hThread = CreateThread(NULL, 0, widRecorder, (LPVOID)(DWORD)wDevID, 0, &(wwi->dwThreadID));
if (wwi->hThread)
SetThreadPriority(wwi->hThread, THREAD_PRIORITY_TIME_CRITICAL);
WaitForSingleObject(wwi->hStartUpEvent, INFINITE);
CloseHandle(wwi->hStartUpEvent);
wwi->hStartUpEvent = INVALID_HANDLE_VALUE;
return widNotifyClient(wwi, WIM_OPEN, 0L, 0L);
......@@ -819,28 +810,6 @@ static DWORD widDevInterface(UINT wDevID, PWCHAR dwParam1, DWORD dwParam2)
}
/**************************************************************************
* widDsCreate [internal]
*/
static DWORD widDsCreate(UINT wDevID, PIDSCDRIVER* drv)
{
TRACE("(%d,%p)\n",wDevID,drv);
/* the HAL isn't much better than the HEL if we can't do mmap() */
FIXME("DirectSoundCapture not implemented\n");
FIXME("The (slower) DirectSound HEL mode will be used instead.\n");
return MMSYSERR_NOTSUPPORTED;
}
/**************************************************************************
* widDsDesc [internal]
*/
static DWORD widDsDesc(UINT wDevID, PDSDRIVERDESC desc)
{
memcpy(desc, &(WInDev[wDevID].ds_desc), sizeof(DSDRIVERDESC));
return MMSYSERR_NOERROR;
}
/**************************************************************************
* widMessage (WINEALSA.@)
*/
DWORD WINAPI ALSA_widMessage(UINT wDevID, UINT wMsg, DWORD dwUser,
......
......@@ -525,12 +525,6 @@ static int ALSA_AddCaptureDevice(snd_ctl_t *ctl, snd_pcm_t *pcm, const char *pcm
return(rc);
}
if (wwi.dwSupport & WAVECAPS_DIRECTSOUND)
{
FIXME("Add support for DSCapture\n");
wwi.dwSupport &= ~WAVECAPS_DIRECTSOUND;
}
rc = ALSA_AddDeviceToArray(&wwi, &WInDev, &ALSA_WidNumDevs, &ALSA_WidNumMallocedDevs, isdefault);
if (rc)
ALSA_FreeDevice(&wwi);
......
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