VirtualBox

source: vbox/trunk/src/VBox/Main/include/AudioDriver.h@ 91501

Last change on this file since 91501 was 89580, checked in by vboxsync, 3 years ago

Main: Try fix VRDP-input-always-disabled regression from r120203+r120206. bugref:7820 bugref:9890

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* $Id: AudioDriver.h 89580 2021-06-09 13:22:55Z vboxsync $ */
2/** @file
3 * VirtualBox audio base class for Main audio drivers.
4 */
5
6/*
7 * Copyright (C) 2018-2020 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 MAIN_INCLUDED_AudioDriver_h
19#define MAIN_INCLUDED_AudioDriver_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/com/ptr.h>
25#include <VBox/com/string.h>
26#include <VBox/com/AutoLock.h>
27
28using namespace com;
29
30/**
31 * Audio driver configuration for audio drivers implemented
32 * in Main.
33 */
34struct AudioDriverCfg
35{
36 AudioDriverCfg(Utf8Str a_strDev = "", unsigned a_uInst = 0, unsigned a_uLUN = 0, Utf8Str a_strName = "",
37 bool a_fEnabledIn = false, bool a_fEnabledOut = false)
38 : strDev(a_strDev)
39 , uInst(a_uInst)
40 , uLUN(a_uLUN)
41 , strName(a_strName)
42 , fEnabledIn(a_fEnabledIn)
43 , fEnabledOut(a_fEnabledOut)
44 { }
45
46 /** Copy assignment operator. */
47 AudioDriverCfg& operator=(AudioDriverCfg const &a_rThat) RT_NOEXCEPT
48 {
49 this->strDev = a_rThat.strDev;
50 this->uInst = a_rThat.uInst;
51 this->uLUN = a_rThat.uLUN;
52 this->strName = a_rThat.strName;
53 this->fEnabledIn = a_rThat.fEnabledIn;
54 this->fEnabledOut = a_rThat.fEnabledOut;
55
56 return *this;
57 }
58
59 /** The device name. */
60 Utf8Str strDev;
61 /** The device instance. */
62 unsigned uInst;
63 /** The LUN the driver is attached to.
64 * Set the UINT8_MAX if not attached. */
65 unsigned uLUN;
66 /** The driver name. */
67 Utf8Str strName;
68 /** Whether input is enabled. */
69 bool fEnabledIn;
70 /** Whether output is enabled. */
71 bool fEnabledOut;
72};
73
74class Console;
75
76/**
77 * Base class for all audio drivers implemented in Main.
78 */
79class AudioDriver
80{
81
82public:
83 AudioDriver(Console *pConsole);
84 virtual ~AudioDriver();
85
86 /** Copy assignment operator. */
87 AudioDriver &operator=(AudioDriver const &a_rThat) RT_NOEXCEPT;
88
89 Console *GetParent(void) { return mpConsole; }
90
91 AudioDriverCfg *GetConfig(void) { return &mCfg; }
92 int InitializeConfig(AudioDriverCfg *pCfg);
93
94 /** Checks if audio is configured or not. */
95 bool isConfigured() const { return mCfg.strName.isNotEmpty(); }
96
97 bool IsAttached(void) { return mfAttached; }
98
99 int doAttachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock);
100 int doDetachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock);
101
102protected:
103 static DECLCALLBACK(int) attachDriverOnEmt(AudioDriver *pThis);
104 static DECLCALLBACK(int) detachDriverOnEmt(AudioDriver *pThis);
105
106 int configure(unsigned uLUN, bool fAttach);
107
108 /**
109 * Optional (virtual) function to give the derived audio driver
110 * class the ability to add (or change) the driver configuration
111 * entries when setting up.
112 *
113 * @return VBox status code.
114 * @param pLunCfg CFGM configuration node of the driver.
115 */
116 virtual int configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); return VINF_SUCCESS; }
117
118protected:
119
120 /** Pointer to parent. */
121 Console *mpConsole;
122 /** The driver's configuration. */
123 AudioDriverCfg mCfg;
124 /** Whether the driver is attached or not. */
125 bool mfAttached;
126};
127
128#endif /* !MAIN_INCLUDED_AudioDriver_h */
129
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette