1 | /* $Id: AudioDriver.h 70544 2018-01-11 16:20:27Z vboxsync $ */
|
---|
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 | Utf8Str a_strName = "")
|
---|
34 | : strDev(a_strDev)
|
---|
35 | , uInst(a_uInst)
|
---|
36 | , uLUN(a_uLUN)
|
---|
37 | , strName(a_strName) { }
|
---|
38 |
|
---|
39 | AudioDriverCfg& operator=(AudioDriverCfg that)
|
---|
40 | {
|
---|
41 | this->strDev = that.strDev;
|
---|
42 | this->uInst = that.uInst;
|
---|
43 | this->uLUN = that.uLUN;
|
---|
44 | this->strName = that.strName;
|
---|
45 |
|
---|
46 | return *this;
|
---|
47 | }
|
---|
48 |
|
---|
49 | /** The device name. */
|
---|
50 | Utf8Str strDev;
|
---|
51 | /** The device instance. */
|
---|
52 | unsigned uInst;
|
---|
53 | /** The LUN the driver is attached to.
|
---|
54 | * Set the UINT8_MAX if not attached. */
|
---|
55 | unsigned uLUN;
|
---|
56 | /** The driver name. */
|
---|
57 | Utf8Str strName;
|
---|
58 | };
|
---|
59 |
|
---|
60 | class Console;
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Base class for all audio drivers implemented in Main.
|
---|
64 | */
|
---|
65 | class AudioDriver
|
---|
66 | {
|
---|
67 |
|
---|
68 | public:
|
---|
69 |
|
---|
70 | AudioDriver(Console *pConsole);
|
---|
71 |
|
---|
72 | virtual ~AudioDriver();
|
---|
73 |
|
---|
74 | AudioDriverCfg *GetConfig(void) { return &mCfg; }
|
---|
75 |
|
---|
76 | Console *GetParent(void) { return mpConsole; }
|
---|
77 |
|
---|
78 | bool IsAttached(void) { return mfAttached; }
|
---|
79 |
|
---|
80 | static DECLCALLBACK(int) Attach(AudioDriver *pThis, AudioDriverCfg *pCfg);
|
---|
81 |
|
---|
82 | static DECLCALLBACK(int) Detach(AudioDriver *pThis);
|
---|
83 |
|
---|
84 | int Configure(AudioDriverCfg *pCfg, bool fAttach);
|
---|
85 |
|
---|
86 | protected:
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Optional (virtual) function to give the derived audio driver
|
---|
90 | * class the ability to add more driver configuration entries when
|
---|
91 | * setting up.
|
---|
92 | *
|
---|
93 | * @param pLunCfg CFGM configuration node of the driver.
|
---|
94 | */
|
---|
95 | virtual void configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); }
|
---|
96 |
|
---|
97 | unsigned getFreeLUN(void);
|
---|
98 |
|
---|
99 | protected:
|
---|
100 |
|
---|
101 | /** Pointer to parent. */
|
---|
102 | Console *mpConsole;
|
---|
103 | /** The driver's configuration. */
|
---|
104 | AudioDriverCfg mCfg;
|
---|
105 | /** Whether the driver is attached or not. */
|
---|
106 | bool mfAttached;
|
---|
107 | };
|
---|
108 |
|
---|
109 | #endif /* ____H_AUDIODRIVER */
|
---|
110 |
|
---|