ReactOS  0.4.15-dev-449-g64abd9f
capabilities.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Sound System "MME Buddy" Library
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: lib/drivers/sound/mmebuddy/capabilities.c
5  *
6  * PURPOSE: Queries sound devices for their capabilities.
7  *
8  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
9 */
10 
11 #include "precomp.h"
12 
13 /*
14  Obtains the capabilities of a sound device. This routine ensures that the
15  supplied CapabilitiesSize parameter at least meets the minimum size of the
16  relevant capabilities structure.
17 
18  Ultimately, it will call the GetCapabilities function specified in the
19  sound device's function table. Note that there are several of these, in a
20  union. This is simply to avoid manually typecasting when implementing the
21  functions.
22 */
25  IN PSOUND_DEVICE SoundDevice,
26  IN DWORD DeviceId,
28  IN DWORD CapabilitiesSize)
29 {
32  BOOLEAN GoodSize = FALSE;
34 
37  VALIDATE_MMSYS_PARAMETER( CapabilitiesSize > 0 );
38 
39  /* Obtain the device type */
40  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
42 
43  if ( ! MMSUCCESS(Result) )
45 
46  /* Obtain the function table */
49 
50  if ( ! MMSUCCESS(Result) )
52 
54 
55  /* Check that the capabilities structure is of a valid size */
56  switch ( DeviceType )
57  {
59  {
60  GoodSize = CapabilitiesSize >= sizeof(WAVEOUTCAPSW);
61  break;
62  }
63  case WAVE_IN_DEVICE_TYPE :
64  {
65  GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPSW);
66  break;
67  }
69  {
70  GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPSW);
71  break;
72  }
73  case MIDI_IN_DEVICE_TYPE :
74  {
75  GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPSW);
76  break;
77  }
78  case AUX_DEVICE_TYPE :
79  {
80  GoodSize = CapabilitiesSize >= sizeof(AUXCAPSW);
81  break;
82  }
83  case MIXER_DEVICE_TYPE :
84  {
85  GoodSize = CapabilitiesSize >= sizeof(MIXERCAPSW);
86  break;
87  }
88  };
89 
90  if ( ! GoodSize )
91  {
92  SND_ERR(L"Device capabilities structure too small\n");
93  return MMSYSERR_INVALPARAM;
94  }
95 
96  /* Call the "get capabilities" function within the function table */
97  SND_ASSERT( FunctionTable->GetCapabilities );
98 
99  if ( ! FunctionTable->GetCapabilities )
100  return MMSYSERR_NOTSUPPORTED;
101 
102  return FunctionTable->GetCapabilities(SoundDevice,
103  DeviceId,
104  Capabilities,
105  CapabilitiesSize);
106 }
#define IN
Definition: typedefs.h:39
struct tagMIXERCAPSW MIXERCAPSW
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
struct tagMIDIINCAPSW MIDIINCAPSW
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT GetSoundDeviceCapabilities(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: capabilities.c:24
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
struct tagWAVEINCAPSW WAVEINCAPSW
unsigned char BOOLEAN
#define SND_ASSERT(condition)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
struct tagAUXCAPSW AUXCAPSW
#define SND_ERR(...)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
struct tagMIDIOUTCAPSW MIDIOUTCAPSW
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
#define OUT
Definition: typedefs.h:40
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
struct tagWAVEOUTCAPSW WAVEOUTCAPSW