Abandoning silverblade-audio branch.
[reactos.git] / reactos / lib / drivers / sound / mmebuddy / functiontable.c
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/functiontable.c
5 *
6 * PURPOSE: Routes function calls through a function table, calling
7 * implementation-defined routines or a default function, depending
8 * on configuration.
9 *
10 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
11 */
12
13 #include <windows.h>
14 #include <mmsystem.h>
15 #include <mmddk.h>
16 #include <mmebuddy.h>
17
18 /*
19 Attaches a function table to a sound device. Any NULL entries in this
20 table are automatically set to point to a default routine to handle
21 the appropriate function. If NULL is passed as the function table itself,
22 the entire function table will use only the default routines.
23 */
24 MMRESULT
25 SetSoundDeviceFunctionTable(
26 IN PSOUND_DEVICE SoundDevice,
27 IN PMMFUNCTION_TABLE FunctionTable OPTIONAL)
28 {
29 VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
30
31 /* Zero out the existing function table (if present) */
32 ZeroMemory(&SoundDevice->FunctionTable, sizeof(MMFUNCTION_TABLE));
33
34 if ( FunctionTable )
35 {
36 /* Fill in the client-supplied functions */
37 CopyMemory(&SoundDevice->FunctionTable,
38 FunctionTable,
39 sizeof(MMFUNCTION_TABLE));
40 }
41
42 return MMSYSERR_NOERROR;
43 }
44
45 /*
46 Retrieves the function table for a sound device, as previously set using
47 SetSoundDeviceFunctionTable.
48 */
49 MMRESULT
50 GetSoundDeviceFunctionTable(
51 IN PSOUND_DEVICE SoundDevice,
52 OUT PMMFUNCTION_TABLE* FunctionTable)
53 {
54 VALIDATE_MMSYS_PARAMETER( IsValidSoundDevice(SoundDevice) );
55 VALIDATE_MMSYS_PARAMETER( FunctionTable );
56
57 *FunctionTable = &SoundDevice->FunctionTable;
58
59 return MMSYSERR_NOERROR;
60 }