279d1194f765783d413386f80d7a022bfc6f06f0
[reactos.git] / reactos / lib / drivers / sound / mmixer / mixer.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: lib/drivers/sound/mmixer/mmixer.c
5 * PURPOSE: Mixer Handling Functions
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9
10
11 #include "priv.h"
12
13 MIXER_STATUS
14 MMixerInitialize(
15 IN PMIXER_CONTEXT MixerContext,
16 IN PMIXER_ENUM EnumFunction,
17 IN PVOID EnumContext)
18 {
19 MIXER_STATUS Status;
20 HANDLE hMixer;
21 ULONG DeviceIndex, Count;
22 LPWSTR DeviceName;
23
24 if (!MixerContext || !EnumFunction || !EnumContext)
25 {
26 // invalid parameter
27 return MM_STATUS_INVALID_PARAMETER;
28 }
29
30 if (!MixerContext->Alloc || !MixerContext->Control || !MixerContext->Free)
31 {
32 // invalid parameter
33 return MM_STATUS_INVALID_PARAMETER;
34 }
35
36
37 // start enumerating all available devices
38 Count = 0;
39 DeviceIndex = 0;
40
41 do
42 {
43 // enumerate a device
44 Status = EnumFunction(EnumContext, DeviceIndex, &DeviceName, &hMixer);
45
46 if (Status != MM_STATUS_SUCCESS)
47 {
48 //check error code
49 if (Status != MM_STATUS_NO_MORE_DEVICES)
50 {
51 // enumeration has failed
52 return Status;
53 }
54 // last device
55 break;
56 }
57
58
59 // increment device index
60 DeviceIndex++;
61
62 Status = MMixerSetupFilter(MixerContext, hMixer, &Count, DeviceName);
63
64 if (Status != MM_STATUS_SUCCESS)
65 break;
66
67 }while(TRUE);
68
69 // done
70 return Status;
71 }
72
73