1 | /* $Id$ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox audio base class for Main audio drivers.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_AUDIODRIVER
|
---|
19 | #define ____H_AUDIODRIVER
|
---|
20 |
|
---|
21 | #include <VBox/com/ptr.h>
|
---|
22 | #include <VBox/com/string.h>
|
---|
23 |
|
---|
24 | using namespace com;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Audio driver configuration for audio drivers implemented
|
---|
28 | * in Main.
|
---|
29 | */
|
---|
30 | struct AudioDriverCfg
|
---|
31 | {
|
---|
32 | AudioDriverCfg(Utf8Str a_strDev = "", unsigned a_uInst = 0, unsigned a_uLUN = 0)
|
---|
33 | : strDev(a_strDev)
|
---|
34 | , uInst(a_uInst)
|
---|
35 | , uLUN(a_uLUN) { }
|
---|
36 |
|
---|
37 | AudioDriverCfg& operator=(AudioDriverCfg that)
|
---|
38 | {
|
---|
39 | this->strDev = that.strDev;
|
---|
40 | this->uInst = that.uInst;
|
---|
41 | this->uLUN = that.uLUN;
|
---|
42 |
|
---|
43 | return *this;
|
---|
44 | }
|
---|
45 |
|
---|
46 | /** The device name. */
|
---|
47 | Utf8Str strDev;
|
---|
48 | /** The device instance. */
|
---|
49 | unsigned uInst;
|
---|
50 | /** The LUN the driver is attached to.
|
---|
51 | * Set the UINT8_MAX if not attached. */
|
---|
52 | unsigned uLUN;
|
---|
53 | };
|
---|
54 |
|
---|
55 | class Console;
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Base class for all audio drivers implemented in Main.
|
---|
59 | */
|
---|
60 | class AudioDriver
|
---|
61 | {
|
---|
62 |
|
---|
63 | public:
|
---|
64 |
|
---|
65 | AudioDriver(Console *pConsole);
|
---|
66 |
|
---|
67 | virtual ~AudioDriver();
|
---|
68 |
|
---|
69 | AudioDriverCfg *GetConfig(void) { return &mCfg; }
|
---|
70 |
|
---|
71 | Console *GetParent(void) { return mpConsole; }
|
---|
72 |
|
---|
73 | bool IsAttached(void) { return mfAttached; }
|
---|
74 |
|
---|
75 | static DECLCALLBACK(int) Attach(AudioDriver *pThis, AudioDriverCfg *pCfg);
|
---|
76 |
|
---|
77 | static DECLCALLBACK(int) Detach(AudioDriver *pThis);
|
---|
78 |
|
---|
79 | int Configure(AudioDriverCfg *pCfg, bool fAttach);
|
---|
80 |
|
---|
81 | protected:
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * Optional (virtual) function to give the derived audio driver
|
---|
85 | * class the ability to add more driver configuration entries when
|
---|
86 | * setting up.
|
---|
87 | *
|
---|
88 | * @param pLunCfg CFGM configuration node of the driver.
|
---|
89 | */
|
---|
90 | virtual void configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); }
|
---|
91 |
|
---|
92 | unsigned getFreeLUN(void);
|
---|
93 |
|
---|
94 | protected:
|
---|
95 |
|
---|
96 | /** Pointer to parent. */
|
---|
97 | Console *mpConsole;
|
---|
98 | /** The driver's configuration. */
|
---|
99 | AudioDriverCfg mCfg;
|
---|
100 | /** Whether the driver is attached or not. */
|
---|
101 | bool mfAttached;
|
---|
102 | };
|
---|
103 |
|
---|
104 | #endif /* ____H_AUDIODRIVER */
|
---|
105 |
|
---|