VirtualBox

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

Last change on this file since 73768 was 70644, checked in by vboxsync, 6 years ago

Audio/Main: More code needed for attaching / detaching host backends at runtime.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: AudioDriver.h 70644 2018-01-19 12:20:33Z 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#include <VBox/com/AutoLock.h>
24
25using namespace com;
26
27/**
28 * Audio driver configuration for audio drivers implemented
29 * in Main.
30 */
31struct AudioDriverCfg
32{
33 AudioDriverCfg(Utf8Str a_strDev = "", unsigned a_uInst = 0, unsigned a_uLUN = 0, 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
60class Console;
61
62/**
63 * Base class for all audio drivers implemented in Main.
64 */
65class AudioDriver
66{
67
68public:
69 AudioDriver(Console *pConsole);
70 virtual ~AudioDriver();
71
72 Console *GetParent(void) { return mpConsole; }
73
74 AudioDriverCfg *GetConfig(void) { return &mCfg; }
75 int InitializeConfig(AudioDriverCfg *pCfg);
76
77 /** Checks if audio is configured or not. */
78 bool isConfigured() const { return mCfg.strName.isNotEmpty(); }
79
80 bool IsAttached(void) { return mfAttached; }
81
82 int doAttachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock);
83 int doDetachDriverViaEmt(PUVM pUVM, util::AutoWriteLock *pAutoLock);
84
85protected:
86 static DECLCALLBACK(int) attachDriverOnEmt(AudioDriver *pThis);
87 static DECLCALLBACK(int) detachDriverOnEmt(AudioDriver *pThis);
88
89 int configure(unsigned uLUN, bool fAttach);
90
91 /**
92 * Optional (virtual) function to give the derived audio driver
93 * class the ability to add (or change) the driver configuration
94 * entries when setting up.
95 *
96 * @return VBox status code.
97 * @param pLunCfg CFGM configuration node of the driver.
98 */
99 virtual int configureDriver(PCFGMNODE pLunCfg) { RT_NOREF(pLunCfg); return VINF_SUCCESS; }
100
101protected:
102
103 /** Pointer to parent. */
104 Console *mpConsole;
105 /** The driver's configuration. */
106 AudioDriverCfg mCfg;
107 /** Whether the driver is attached or not. */
108 bool mfAttached;
109};
110
111#endif /* !____H_AUDIODRIVER */
112
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use