- Make sure string is null terminated

- Copy all required fields for WaveIn devices
- Use double of the reported FrameSize to increase audio playback performance

svn path=/trunk/; revision=43703
This commit is contained in:
Johannes Anderwald 2009-10-23 21:53:25 +00:00
parent 75b317922f
commit b4018f21e9

View file

@ -94,14 +94,13 @@ GetWdmDeviceCapabilities(
SND_ASSERT( SoundDevice ); SND_ASSERT( SoundDevice );
SND_ASSERT( Capabilities ); SND_ASSERT( Capabilities );
SND_TRACE(L"WDMAUD - GetWdmDeviceCapabilities\n");
Result = GetSoundDeviceType(SoundDevice, &DeviceType); Result = GetSoundDeviceType(SoundDevice, &DeviceType);
SND_ASSERT( Result == MMSYSERR_NOERROR ); SND_ASSERT( Result == MMSYSERR_NOERROR );
if ( ! MMSUCCESS(Result) ) if ( ! MMSUCCESS(Result) )
return Result; return Result;
SND_TRACE(L"WDMAUD - GetWdmDeviceCapabilities DeviceType %u DeviceId %u\n", DeviceType, DeviceId);
ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO)); ZeroMemory(&DeviceInfo, sizeof(WDMAUD_DEVICE_INFO));
DeviceInfo.DeviceType = DeviceType; DeviceInfo.DeviceType = DeviceType;
@ -120,8 +119,6 @@ GetWdmDeviceCapabilities(
return TranslateInternalMmResult(Result); return TranslateInternalMmResult(Result);
} }
SND_TRACE(L"WDMAUD Name %S\n", DeviceInfo.u.WaveOutCaps.szPname);
/* This is pretty much a big hack right now */ /* This is pretty much a big hack right now */
switch ( DeviceType ) switch ( DeviceType )
{ {
@ -129,18 +126,21 @@ GetWdmDeviceCapabilities(
{ {
LPMIXERCAPS MixerCaps = (LPMIXERCAPS) Capabilities; LPMIXERCAPS MixerCaps = (LPMIXERCAPS) Capabilities;
CopyWideString(MixerCaps->szPname, DeviceInfo.u.WaveOutCaps.szPname); DeviceInfo.u.MixCaps.szPname[MAXPNAMELEN-1] = L'\0';
CopyWideString(MixerCaps->szPname, DeviceInfo.u.MixCaps.szPname);
MixerCaps->cDestinations = DeviceInfo.u.MixCaps.cDestinations; MixerCaps->cDestinations = DeviceInfo.u.MixCaps.cDestinations;
MixerCaps->fdwSupport = DeviceInfo.u.MixCaps.fdwSupport; MixerCaps->fdwSupport = DeviceInfo.u.MixCaps.fdwSupport;
MixerCaps->vDriverVersion = DeviceInfo.u.MixCaps.vDriverVersion; MixerCaps->vDriverVersion = DeviceInfo.u.MixCaps.vDriverVersion;
MixerCaps->wMid = DeviceInfo.u.MixCaps.wMid; MixerCaps->wMid = DeviceInfo.u.MixCaps.wMid;
MixerCaps->wPid = DeviceInfo.u.MixCaps.wPid; MixerCaps->wPid = DeviceInfo.u.MixCaps.wPid;
break; break;y
} }
case WAVE_OUT_DEVICE_TYPE : case WAVE_OUT_DEVICE_TYPE :
{ {
LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities; LPWAVEOUTCAPS WaveOutCaps = (LPWAVEOUTCAPS) Capabilities;
DeviceInfo.u.WaveOutCaps.szPname[MAXPNAMELEN-1] = L'\0';
WaveOutCaps->wMid = DeviceInfo.u.WaveOutCaps.wMid; WaveOutCaps->wMid = DeviceInfo.u.WaveOutCaps.wMid;
WaveOutCaps->wPid = DeviceInfo.u.WaveOutCaps.wPid; WaveOutCaps->wPid = DeviceInfo.u.WaveOutCaps.wPid;
@ -154,9 +154,19 @@ GetWdmDeviceCapabilities(
} }
case WAVE_IN_DEVICE_TYPE : case WAVE_IN_DEVICE_TYPE :
{ {
LPWAVEINCAPS WaveInCaps = (LPWAVEINCAPS) Capabilities; LPWAVEINCAPSW WaveInCaps = (LPWAVEINCAPSW) Capabilities;
CopyWideString(WaveInCaps->szPname, DeviceInfo.u.WaveOutCaps.szPname);
/* TODO... other fields */ DeviceInfo.u.WaveInCaps.szPname[MAXPNAMELEN-1] = L'\0';
WaveInCaps->wMid = DeviceInfo.u.WaveInCaps.wMid;
WaveInCaps->wPid = DeviceInfo.u.WaveInCaps.wPid;
WaveInCaps->vDriverVersion = 0x0001;
CopyWideString(WaveInCaps->szPname, DeviceInfo.u.WaveInCaps.szPname);
WaveInCaps->dwFormats = DeviceInfo.u.WaveInCaps.dwFormats;
WaveInCaps->wChannels = DeviceInfo.u.WaveInCaps.wChannels;
WaveInCaps->wReserved1 = 0;
break; break;
} }
} }
@ -407,7 +417,7 @@ SetWdmWaveDeviceFormat(
{ {
if (DeviceInfo.u.FrameSize) if (DeviceInfo.u.FrameSize)
{ {
//Instance->FrameSize = DeviceInfo.u.FrameSize; Instance->FrameSize = DeviceInfo.u.FrameSize * 2;
Instance->BufferCount = WaveFormat->nAvgBytesPerSec / Instance->FrameSize; Instance->BufferCount = WaveFormat->nAvgBytesPerSec / Instance->FrameSize;
SND_TRACE(L"FrameSize %u BufferCount %u\n", Instance->FrameSize, Instance->BufferCount); SND_TRACE(L"FrameSize %u BufferCount %u\n", Instance->FrameSize, Instance->BufferCount);
} }