ReactOS 0.4.15-dev-8241-g63935f8
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 }
64 {
65 GoodSize = CapabilitiesSize >= sizeof(WAVEINCAPSW);
66 break;
67 }
69 {
70 GoodSize = CapabilitiesSize >= sizeof(MIDIOUTCAPSW);
71 break;
72 }
74 {
75 GoodSize = CapabilitiesSize >= sizeof(MIDIINCAPSW);
76 break;
77 }
78 case AUX_DEVICE_TYPE :
79 {
80 GoodSize = CapabilitiesSize >= sizeof(AUXCAPSW);
81 break;
82 }
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");
94 }
95
96 /* Call the "get capabilities" function within the function table */
97 SND_ASSERT( FunctionTable->GetCapabilities );
98
99 if ( ! FunctionTable->GetCapabilities )
101
102 return FunctionTable->GetCapabilities(SoundDevice,
103 DeviceId,
105 CapabilitiesSize);
106}
unsigned char BOOLEAN
MMRESULT GetSoundDeviceCapabilities(IN PSOUND_DEVICE SoundDevice, IN DWORD DeviceId, OUT PVOID Capabilities, IN DWORD CapabilitiesSize)
Definition: capabilities.c:24
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
DeviceType
Definition: mmdrv.h:42
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
#define SND_ERR(...)
#define SND_ASSERT(condition)
struct tagMIDIINCAPSW MIDIINCAPSW
struct tagAUXCAPSW AUXCAPSW
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
struct tagMIDIOUTCAPSW MIDIOUTCAPSW
struct tagWAVEINCAPSW WAVEINCAPSW
#define MMSYSERR_INVALPARAM
Definition: mmsystem.h:107
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
struct tagMIXERCAPSW MIXERCAPSW
struct tagWAVEOUTCAPSW WAVEOUTCAPSW
#define L(x)
Definition: ntvdm.h:50
@ MIXER_DEVICE_TYPE
Definition: sndtypes.h:33
@ MIDI_OUT_DEVICE_TYPE
Definition: sndtypes.h:31
@ WAVE_IN_DEVICE_TYPE
Definition: sndtypes.h:28
@ AUX_DEVICE_TYPE
Definition: sndtypes.h:32
@ WAVE_OUT_DEVICE_TYPE
Definition: sndtypes.h:29
@ MIDI_IN_DEVICE_TYPE
Definition: sndtypes.h:30
#define IS_VALID_SOUND_DEVICE_TYPE(x)
Definition: sndtypes.h:43
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:722
_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:409