Commit 7d43d7bb authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Use the drivers to get device capabilities and property sets.

parent 3e037992
......@@ -1044,6 +1044,7 @@ HRESULT WINAPI IDirectSoundBufferImpl_Create(
dsb->dsb = 0;
dsb->dsound = ds;
dsb->lpVtbl = &dsbvt;
dsb->iks = NULL;
memcpy(&dsb->dsbd, dsbd, sizeof(*dsbd));
if (wfex)
......@@ -1064,7 +1065,9 @@ HRESULT WINAPI IDirectSoundBufferImpl_Create(
else capf |= DSCAPS_SECONDARYMONO;
if (wfex->wBitsPerSample==16) capf |= DSCAPS_SECONDARY16BIT;
else capf |= DSCAPS_SECONDARY8BIT;
use_hw = (ds->drvcaps.dwFlags & capf) == capf;
TRACE("use_hw = 0x%08x, capf = 0x%08lx, ds->drvcaps.dwFlags = 0x%08lx\n", use_hw, capf, ds->drvcaps.dwFlags);
/* FIXME: check hardware sample rate mixing capabilities */
/* FIXME: check app hints for software/hardware buffer (STATIC, LOCHARDWARE, etc) */
......
......@@ -674,34 +674,34 @@ static HRESULT WINAPI IDirectSoundImpl_GetCaps(LPDIRECTSOUND8 iface,LPDSCAPS lpD
lpDSCaps->dwFlags = This->drvcaps.dwFlags;
TRACE("(flags=0x%08lx)\n",lpDSCaps->dwFlags);
/* FIXME: copy caps from This->drv */
lpDSCaps->dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
lpDSCaps->dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
lpDSCaps->dwMinSecondarySampleRate = This->drvcaps.dwMinSecondarySampleRate;
lpDSCaps->dwMaxSecondarySampleRate = This->drvcaps.dwMaxSecondarySampleRate;
lpDSCaps->dwPrimaryBuffers = 1;
lpDSCaps->dwPrimaryBuffers = This->drvcaps.dwPrimaryBuffers;
lpDSCaps->dwMaxHwMixingAllBuffers = 0;
lpDSCaps->dwMaxHwMixingStaticBuffers = 0;
lpDSCaps->dwMaxHwMixingStreamingBuffers = 0;
lpDSCaps->dwMaxHwMixingAllBuffers = This->drvcaps.dwMaxHwMixingAllBuffers;
lpDSCaps->dwMaxHwMixingStaticBuffers = This->drvcaps.dwMaxHwMixingStaticBuffers;
lpDSCaps->dwMaxHwMixingStreamingBuffers = This->drvcaps.dwMaxHwMixingStreamingBuffers;
lpDSCaps->dwFreeHwMixingAllBuffers = 0;
lpDSCaps->dwFreeHwMixingStaticBuffers = 0;
lpDSCaps->dwFreeHwMixingStreamingBuffers = 0;
lpDSCaps->dwFreeHwMixingAllBuffers = This->drvcaps.dwFreeHwMixingAllBuffers;
lpDSCaps->dwFreeHwMixingStaticBuffers = This->drvcaps.dwFreeHwMixingStaticBuffers;
lpDSCaps->dwFreeHwMixingStreamingBuffers = This->drvcaps.dwFreeHwMixingStreamingBuffers;
lpDSCaps->dwMaxHw3DAllBuffers = 0;
lpDSCaps->dwMaxHw3DStaticBuffers = 0;
lpDSCaps->dwMaxHw3DStreamingBuffers = 0;
lpDSCaps->dwMaxHw3DAllBuffers = This->drvcaps.dwMaxHw3DAllBuffers;
lpDSCaps->dwMaxHw3DStaticBuffers = This->drvcaps.dwMaxHw3DStaticBuffers;
lpDSCaps->dwMaxHw3DStreamingBuffers = This->drvcaps.dwMaxHw3DStreamingBuffers;
lpDSCaps->dwFreeHw3DAllBuffers = 0;
lpDSCaps->dwFreeHw3DStaticBuffers = 0;
lpDSCaps->dwFreeHw3DStreamingBuffers = 0;
lpDSCaps->dwFreeHw3DAllBuffers = This->drvcaps.dwFreeHw3DAllBuffers;
lpDSCaps->dwFreeHw3DStaticBuffers = This->drvcaps.dwFreeHw3DStaticBuffers;
lpDSCaps->dwFreeHw3DStreamingBuffers = This->drvcaps.dwFreeHw3DStreamingBuffers;
lpDSCaps->dwTotalHwMemBytes = 0;
lpDSCaps->dwTotalHwMemBytes = This->drvcaps.dwTotalHwMemBytes;
lpDSCaps->dwFreeHwMemBytes = 0;
lpDSCaps->dwFreeHwMemBytes = This->drvcaps.dwFreeHwMemBytes;
lpDSCaps->dwMaxContigFreeHwMemBytes = 0;
lpDSCaps->dwMaxContigFreeHwMemBytes = This->drvcaps.dwMaxContigFreeHwMemBytes;
/* driver doesn't have these */
lpDSCaps->dwUnlockTransferRateHwBuffers = 4096; /* But we have none... */
lpDSCaps->dwPlayCpuOverheadSwBuffers = 1; /* 1% */
......@@ -1099,7 +1099,7 @@ HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID,LPDIRECTSOUND8 *ppDS,IUnknown
*ippDS = NULL;
return err;
}
(*ippDS)->drvcaps.dwFlags = 0;
ZeroMemory(&(*ippDS)->drvcaps, sizeof((*ippDS)->drvcaps));
if ((woc.dwFormats & WAVE_FORMAT_1M08) ||
(woc.dwFormats & WAVE_FORMAT_2M08) ||
(woc.dwFormats & WAVE_FORMAT_4M08) ||
......@@ -1134,6 +1134,9 @@ HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID,LPDIRECTSOUND8 *ppDS,IUnknown
}
if (ds_emuldriver)
(*ippDS)->drvcaps.dwFlags |= DSCAPS_EMULDRIVER;
(*ippDS)->drvcaps.dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
(*ippDS)->drvcaps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
(*ippDS)->drvcaps.dwPrimaryBuffers = 1;
}
DSOUND_RecalcVolPan(&((*ippDS)->volpan));
......
......@@ -25,12 +25,14 @@
#include <sys/types.h>
#include <sys/fcntl.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
......@@ -43,9 +45,9 @@
#include "wine/windef16.h"
#include "wine/debug.h"
#include "dsound.h"
#include "dsconf.h"
#include "dsdriver.h"
#include "dsound_private.h"
#include "dsconf.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
......@@ -103,9 +105,28 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_Get(
PULONG pcbReturned )
{
ICOM_THIS(IKsBufferPropertySetImpl,iface);
FIXME("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p) stub!\n",
PIDSDRIVERPROPERTYSET ps;
TRACE("(iface=%p,guidPropSet=%s,dwPropID=%ld,pInstanceData=%p,cbInstanceData=%ld,pPropData=%p,cbPropData=%ld,pcbReturned=%p)\n",
This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
if (ps) {
DSPROPERTY prop;
HRESULT hres;
prop.s.Set = *guidPropSet;
prop.s.Id = dwPropID;
prop.s.Flags = 0; /* unused */
prop.s.InstanceId = (ULONG)This->dsb->dsound;
hres = IDsDriverPropertySet_Get(ps, &prop, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
IDsDriverPropertySet_Release(ps);
return hres;
}
return E_PROP_ID_UNSUPPORTED;
}
......@@ -119,8 +140,26 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_Set(
ULONG cbPropData )
{
ICOM_THIS(IKsBufferPropertySetImpl,iface);
PIDSDRIVERPROPERTYSET ps;
TRACE("(%p,%s,%ld,%p,%ld,%p,%ld)\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
if (ps) {
DSPROPERTY prop;
HRESULT hres;
prop.s.Set = *guidPropSet;
prop.s.Id = dwPropID;
prop.s.Flags = 0; /* unused */
prop.s.InstanceId = (ULONG)This->dsb->dsound;
hres = IDsDriverPropertySet_Set(ps,&prop,pInstanceData,cbInstanceData,pPropData,cbPropData);
IDsDriverPropertySet_Release(ps);
return hres;
}
FIXME("(%p,%s,%ld,%p,%ld,%p,%ld), stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
return E_PROP_ID_UNSUPPORTED;
}
......@@ -131,7 +170,20 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_QuerySupport(
PULONG pTypeSupport )
{
ICOM_THIS(IKsBufferPropertySetImpl,iface);
FIXME("(%p,%s,%ld,%p) stub!\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
PIDSDRIVERPROPERTYSET ps;
TRACE("(%p,%s,%ld,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
if (ps) {
HRESULT hres;
hres = IDsDriverPropertySet_QuerySupport(ps,guidPropSet, dwPropID,pTypeSupport);
IDsDriverPropertySet_Release(ps);
return hres;
}
return E_PROP_ID_UNSUPPORTED;
}
......@@ -151,8 +203,9 @@ HRESULT WINAPI IKsBufferPropertySetImpl_Create(
IKsBufferPropertySetImpl **piks)
{
IKsBufferPropertySetImpl *iks;
TRACE("(%p,%p)\n",dsb,piks);
iks = (IKsBufferPropertySetImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(*iks));
iks = (IKsBufferPropertySetImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*iks));
iks->ref = 0;
iks->dsb = dsb;
dsb->iks = iks;
......@@ -299,11 +352,13 @@ static HRESULT WINAPI DSPROPERTY_Description1(
FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
return E_PROP_ID_UNSUPPORTED;
} else {
}
ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
GetDeviceID(&ppd->DeviceId, &dev_guid);
if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultVoicePlayback) ) {
if ( IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultPlayback) ||
IsEqualGUID( &ppd->DeviceId, &DSDEVID_DefaultVoicePlayback) ) {
ULONG wod;
int wodn;
TRACE("DataFlow=DIRECTSOUNDDEVICE_DATAFLOW_RENDER\n");
......@@ -318,10 +373,14 @@ static HRESULT WINAPI DSPROPERTY_Description1(
ppd->Devnode = wod;
err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSDRIVER drv = NULL;
strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
strncpy(ppd->ModuleA, desc.szDrvName, sizeof(ppd->ModuleA) - 1);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
if (err == DS_OK && drv)
ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
break;
} else {
WARN("waveOutMessage failed\n");
......@@ -349,10 +408,14 @@ static HRESULT WINAPI DSPROPERTY_Description1(
ppd->Devnode = wid;
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSCDRIVER drv;
strncpy(ppd->DescriptionA, desc.szDesc, sizeof(ppd->DescriptionA) - 1);
strncpy(ppd->ModuleA, desc.szDrvName, sizeof(ppd->ModuleA) - 1);
MultiByteToWideChar( CP_ACP, 0, desc.szDesc, -1, ppd->DescriptionW, sizeof(ppd->DescriptionW)/sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, desc.szDrvName, -1, ppd->ModuleW, sizeof(ppd->ModuleW)/sizeof(WCHAR) );
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
if (err == DS_OK && drv)
ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
break;
} else {
WARN("waveInMessage failed\n");
......@@ -369,9 +432,6 @@ static HRESULT WINAPI DSPROPERTY_Description1(
FIXME("DeviceId=Unknown\n");
return E_PROP_ID_UNSUPPORTED;
}
}
ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
if (pcbReturned) {
*pcbReturned = cbPropData;
......@@ -417,7 +477,9 @@ static HRESULT WINAPI DSPROPERTY_DescriptionW(
FIXME("(guidPropSet=%s,pPropData=%p,cbPropData=%ld,pcbReturned=%p) GUID_NULL not implemented!\n",
debugstr_guid(guidPropSet),pPropData,cbPropData,pcbReturned);
return E_PROP_ID_UNSUPPORTED;
} else {
}
ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
GetDeviceID(&ppd->DeviceId, &dev_guid);
if ( IsEqualGUID( &ppd->DeviceId , &DSDEVID_DefaultPlayback) ||
......@@ -435,6 +497,7 @@ static HRESULT WINAPI DSPROPERTY_DescriptionW(
ppd->WaveDeviceId = wod;
err = mmErr(waveOutMessage((HWAVEOUT)wod,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSDRIVER drv = NULL;
/* FIXME: this is a memory leak */
WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
......@@ -447,6 +510,9 @@ static HRESULT WINAPI DSPROPERTY_DescriptionW(
ppd->Description = wDescription;
ppd->Module = wModule;
ppd->Interface = wInterface;
err = mmErr(waveOutMessage((HWAVEOUT)wod, DRV_QUERYDSOUNDIFACE, (DWORD)&drv, 0));
if (err == DS_OK && drv)
ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
break;
} else {
WARN("waveOutMessage failed\n");
......@@ -473,6 +539,7 @@ static HRESULT WINAPI DSPROPERTY_DescriptionW(
ppd->WaveDeviceId = wid;
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDDESC,(DWORD)&(desc),0));
if (err == DS_OK) {
PIDSCDRIVER drv;
/* FIXME: this is a memory leak */
WCHAR * wDescription = HeapAlloc(GetProcessHeap(),0,0x200);
WCHAR * wModule = HeapAlloc(GetProcessHeap(),0,0x200);
......@@ -485,6 +552,9 @@ static HRESULT WINAPI DSPROPERTY_DescriptionW(
ppd->Description = wDescription;
ppd->Module = wModule;
ppd->Interface = wInterface;
err = mmErr(waveInMessage((HWAVEIN)wid,DRV_QUERYDSOUNDIFACE,(DWORD)&drv,0));
if (err == DS_OK && drv)
ppd->Type = DIRECTSOUNDDEVICE_TYPE_VXD;
break;
} else {
WARN("waveInMessage failed\n");
......@@ -501,9 +571,6 @@ static HRESULT WINAPI DSPROPERTY_DescriptionW(
FIXME("DeviceId=Unknown\n");
return E_PROP_ID_UNSUPPORTED;
}
}
ppd->Type = DIRECTSOUNDDEVICE_TYPE_EMULATED;
if (pcbReturned) {
*pcbReturned = cbPropData;
......
......@@ -2009,6 +2009,8 @@ static HRESULT WINAPI IDsDriverImpl_GetCaps(PIDSDRIVER iface, PDSDRIVERCAPS pCap
pCaps->dwPrimaryBuffers = 1;
TRACE("caps=0x%X\n",(unsigned int)pCaps->dwFlags);
pCaps->dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
pCaps->dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
/* the other fields only apply to secondary buffers, which we don't support
* (unless we want to mess with wavetable synthesizers and MIDI) */
......
......@@ -1562,6 +1562,8 @@ static HRESULT WINAPI IDsDriverImpl_GetCaps(PIDSDRIVER iface, PDSDRIVERCAPS pCap
pCaps->dwFlags = DSCAPS_PRIMARYMONO | DSCAPS_PRIMARYSTEREO |
DSCAPS_PRIMARY8BIT | DSCAPS_PRIMARY16BIT;
pCaps->dwPrimaryBuffers = 1;
pCaps->dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
pCaps->dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
/* the other fields only apply to secondary buffers, which we don't support
* (unless we want to mess with wavetable synthesizers and MIDI) */
return DS_OK;
......
......@@ -553,6 +553,8 @@ static BOOL OSS_WaveOutInit(OSS_DEVICE* ossdev)
/* direct sound caps */
ossdev->ds_caps.dwFlags = 0;
ossdev->ds_caps.dwPrimaryBuffers = 1;
ossdev->ds_caps.dwMinSecondarySampleRate = DSBFREQUENCY_MIN;
ossdev->ds_caps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
if (WINE_TRACE_ON(wave)) {
/* Note that this only reports the formats supported by the hardware.
......
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