ReactOS  0.4.15-dev-506-ga3ec01c
format.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/wave/format.c
5  *
6  * PURPOSE: Queries and sets wave device format (sample rate, etc.)
7  *
8  * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
9 */
10 
11 #include "precomp.h"
12 
15  IN PSOUND_DEVICE SoundDevice,
17  IN DWORD FormatSize)
18 {
22 
23  SND_TRACE(L"Querying wave format support\n");
24 
27  VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
28 
29  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
31 
32  /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
34 
35  /* Obtain the function table */
38 
39  if ( ! MMSUCCESS(Result) )
41 
42  if ( ! FunctionTable->QueryWaveFormatSupport )
43  return MMSYSERR_NOTSUPPORTED;
44 
45  return FunctionTable->QueryWaveFormatSupport(SoundDevice, Format, FormatSize);
46 }
47 
50  IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance,
51  IN DWORD DeviceId,
53  IN DWORD FormatSize)
54 {
58  PSOUND_DEVICE SoundDevice;
59 
60  SND_TRACE(L"Setting wave format\n");
61 
63 
64  Result = GetSoundDeviceFromInstance(SoundDeviceInstance, &SoundDevice);
65  if ( ! MMSUCCESS(Result) )
67 
68  Result = GetSoundDeviceType(SoundDevice, &DeviceType);
71  {
73  VALIDATE_MMSYS_PARAMETER( FormatSize >= sizeof(WAVEFORMATEX) );
74  }
75 
76  /* Ensure we have a wave device (TODO: check if this applies to wavein as well) */
78 
79  /* Obtain the function table */
82 
83  if ( ! MMSUCCESS(Result) )
85 
86  if ( ! FunctionTable->SetWaveFormat )
87  return MMSYSERR_NOTSUPPORTED;
88 
89  return FunctionTable->SetWaveFormat(SoundDeviceInstance, DeviceId, Format, FormatSize);
90 }
#define IN
Definition: typedefs.h:39
#define MMSUCCESS(result)
Definition: mmebuddy.h:80
DeviceType
Definition: mmdrv.h:41
MMRESULT QueryWaveDeviceFormatSupport(IN PSOUND_DEVICE SoundDevice, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: format.c:14
MMRESULT TranslateInternalMmResult(IN MMRESULT Result)
Definition: utility.c:132
UINT MMRESULT
Definition: mmsystem.h:962
#define IS_MIDI_DEVICE_TYPE(x)
Definition: sndtypes.h:49
#define VALIDATE_MMSYS_PARAMETER(parameter_condition)
Definition: mmebuddy.h:71
UCHAR MMDEVICE_TYPE
Definition: mmebuddy.h:88
MMRESULT GetSoundDeviceFunctionTable(IN PSOUND_DEVICE SoundDevice, OUT PMMFUNCTION_TABLE *FunctionTable)
Definition: functiontable.c:47
#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 IS_WAVE_DEVICE_TYPE(x)
Definition: sndtypes.h:46
BOOLEAN IsValidSoundDeviceInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance)
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
unsigned long DWORD
Definition: ntddk_ex.h:95
MMRESULT SetWaveDeviceFormat(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, IN DWORD DeviceId, IN LPWAVEFORMATEX Format, IN DWORD FormatSize)
Definition: format.c:49
#define MMSYSERR_NOTSUPPORTED
Definition: mmsystem.h:104
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN IsValidSoundDevice(IN PSOUND_DEVICE SoundDevice)
Definition: devicelist.c:87
#define IS_MIXER_DEVICE_TYPE(x)
Definition: sndtypes.h:55
MMRESULT GetSoundDeviceType(IN PSOUND_DEVICE SoundDevice, OUT PMMDEVICE_TYPE DeviceType)
Definition: devicelist.c:346
static WLX_DISPATCH_VERSION_1_4 FunctionTable
Definition: wlx.c:736
MMRESULT GetSoundDeviceFromInstance(IN PSOUND_DEVICE_INSTANCE SoundDeviceInstance, OUT PSOUND_DEVICE *SoundDevice)
#define SND_TRACE(...)