VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/DrvAudio.h@ 68637

Last change on this file since 68637 was 68488, checked in by vboxsync, 8 years ago

Audio/DrvAudio: A bit of parameter grouping; no actual code changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: DrvAudio.h 68488 2017-08-21 14:13:51Z vboxsync $ */
2/** @file
3 * Intermediate audio driver header.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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 DRV_AUDIO_H
19#define DRV_AUDIO_H
20
21#include <limits.h>
22
23#include <iprt/circbuf.h>
24#include <iprt/critsect.h>
25#include <iprt/file.h>
26#include <iprt/path.h>
27
28#include <VBox/vmm/pdmdev.h>
29#include <VBox/vmm/pdm.h>
30#include <VBox/vmm/pdmaudioifs.h>
31
32#ifdef DEBUG_andy
33# define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
34#endif
35
36#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
37# ifdef RT_OS_WINDOWS
38# define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "c:\\temp\\"
39# else
40# define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "/tmp/"
41# endif
42#endif /* VBOX_AUDIO_DEBUG_DUMP_PCM_DATA */
43
44typedef enum
45{
46 AUD_OPT_INT,
47 AUD_OPT_FMT,
48 AUD_OPT_STR,
49 AUD_OPT_BOOL
50} audio_option_tag_e;
51
52typedef struct audio_option
53{
54 const char *name;
55 audio_option_tag_e tag;
56 void *valp;
57 const char *descr;
58 int *overridenp;
59 int overriden;
60} audio_option;
61
62#ifdef VBOX_WITH_STATISTICS
63/**
64 * Structure for keeping stream statistics for the
65 * statistic manager (STAM).
66 */
67typedef struct DRVAUDIOSTATS
68{
69 STAMCOUNTER TotalStreamsActive;
70 STAMCOUNTER TotalStreamsCreated;
71 STAMCOUNTER TotalFramesRead;
72 STAMCOUNTER TotalFramesWritten;
73 STAMCOUNTER TotalFramesMixedIn;
74 STAMCOUNTER TotalFramesMixedOut;
75 STAMCOUNTER TotalFramesLostIn;
76 STAMCOUNTER TotalFramesLostOut;
77 STAMCOUNTER TotalFramesOut;
78 STAMCOUNTER TotalFramesIn;
79 STAMCOUNTER TotalBytesRead;
80 STAMCOUNTER TotalBytesWritten;
81 /** How much delay (in ms) for input processing. */
82 STAMPROFILEADV DelayIn;
83 /** How much delay (in ms) for output processing. */
84 STAMPROFILEADV DelayOut;
85} DRVAUDIOSTATS, *PDRVAUDIOSTATS;
86#endif
87
88/**
89 * Audio driver instance data.
90 *
91 * @implements PDMIAUDIOCONNECTOR
92 */
93typedef struct DRVAUDIO
94{
95 /** Friendly name of the driver. */
96 char szName[64];
97 /** Critical section for serializing access. */
98 RTCRITSECT CritSect;
99 /** Shutdown indicator. */
100 bool fTerminate;
101 /** Our audio connector interface. */
102 PDMIAUDIOCONNECTOR IAudioConnector;
103 /** Pointer to the driver instance. */
104 PPDMDRVINS pDrvIns;
105 /** Pointer to audio driver below us. */
106 PPDMIHOSTAUDIO pHostDrvAudio;
107 /** List of host input/output audio streams. */
108 RTLISTANCHOR lstHstStreams;
109 /** List of guest input/output audio streams. */
110 RTLISTANCHOR lstGstStreams;
111#ifdef VBOX_WITH_AUDIO_ENUM
112 /** Flag indicating to perform an (re-)enumeration of the host audio devices. */
113 bool fEnumerateDevices;
114#endif
115 /** Audio configuration settings retrieved from the backend. */
116 PDMAUDIOBACKENDCFG BackendCfg;
117#ifdef VBOX_WITH_STATISTICS
118 /** Statistics for the statistics manager (STAM). */
119 DRVAUDIOSTATS Stats;
120#endif
121 struct
122 {
123 /** Whether this driver's input streams are enabled or not.
124 * This flag overrides all the attached stream statuses. */
125 bool fEnabled;
126 /** Max. number of free input streams.
127 * UINT32_MAX for unlimited streams. */
128 uint32_t cStreamsFree;
129#ifdef VBOX_WITH_AUDIO_CALLBACKS
130 RTLISTANCHOR lstCB;
131#endif
132 } In;
133 struct
134 {
135 /** Whether this driver's output streams are enabled or not.
136 * This flag overrides all the attached stream statuses. */
137 bool fEnabled;
138 /** Max. number of free output streams.
139 * UINT32_MAX for unlimited streams. */
140 uint32_t cStreamsFree;
141#ifdef VBOX_WITH_AUDIO_CALLBACKS
142 RTLISTANCHOR lstCB;
143#endif
144 } Out;
145} DRVAUDIO, *PDRVAUDIO;
146
147/** Makes a PDRVAUDIO out of a PPDMIAUDIOCONNECTOR. */
148#define PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface) \
149 ( (PDRVAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIO, IAudioConnector)) )
150
151
152bool DrvAudioHlpAudFmtIsSigned(PDMAUDIOFMT enmFmt);
153uint8_t DrvAudioHlpAudFmtToBits(PDMAUDIOFMT enmFmt);
154const char *DrvAudioHlpAudFmtToStr(PDMAUDIOFMT enmFmt);
155void DrvAudioHlpClearBuf(const PPDMAUDIOPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cFrames);
156uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels);
157uint32_t DrvAudioHlpCalcBitrate(const PPDMAUDIOPCMPROPS pProps);
158bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps1, const PPDMAUDIOPCMPROPS pPCMProps2);
159bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps, const PPDMAUDIOSTREAMCFG pCfg);
160bool DrvAudioHlpPCMPropsAreValid(const PPDMAUDIOPCMPROPS pProps);
161void DrvAudioHlpPCMPropsPrint(const PPDMAUDIOPCMPROPS pProps);
162int DrvAudioHlpPCMPropsToStreamCfg(const PPDMAUDIOPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg);
163const char *DrvAudioHlpRecSrcToStr(const PDMAUDIORECSOURCE enmRecSource);
164void DrvAudioHlpStreamCfgPrint(const PPDMAUDIOSTREAMCFG pCfg);
165bool DrvAudioHlpStreamCfgIsValid(const PPDMAUDIOSTREAMCFG pCfg);
166int DrvAudioHlpStreamCfgCopy(PPDMAUDIOSTREAMCFG pDstCfg, const PPDMAUDIOSTREAMCFG pSrcCfg);
167PPDMAUDIOSTREAMCFG DrvAudioHlpStreamCfgDup(const PPDMAUDIOSTREAMCFG pCfg);
168void DrvAudioHlpStreamCfgFree(PPDMAUDIOSTREAMCFG pCfg);
169const char *DrvAudioHlpStreamCmdToStr(PDMAUDIOSTREAMCMD enmCmd);
170PDMAUDIOFMT DrvAudioHlpStrToAudFmt(const char *pszFmt);
171
172int DrvAudioHlpSanitizeFileName(char *pszPath, size_t cbPath);
173int DrvAudioHlpGetFileName(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName, PDMAUDIOFILETYPE enmType);
174
175PPDMAUDIODEVICE DrvAudioHlpDeviceAlloc(size_t cbData);
176void DrvAudioHlpDeviceFree(PPDMAUDIODEVICE pDev);
177PPDMAUDIODEVICE DrvAudioHlpDeviceDup(const PPDMAUDIODEVICE pDev, bool fCopyUserData);
178
179int DrvAudioHlpDeviceEnumInit(PPDMAUDIODEVICEENUM pDevEnm);
180void DrvAudioHlpDeviceEnumFree(PPDMAUDIODEVICEENUM pDevEnm);
181int DrvAudioHlpDeviceEnumAdd(PPDMAUDIODEVICEENUM pDevEnm, PPDMAUDIODEVICE pDev);
182int DrvAudioHlpDeviceEnumCopyEx(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm, PDMAUDIODIR enmUsage);
183int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm);
184PPDMAUDIODEVICEENUM DrvAudioHlpDeviceEnumDup(const PPDMAUDIODEVICEENUM pDevEnm);
185int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm);
186int DrvAudioHlpDeviceEnumCopyEx(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm, PDMAUDIODIR enmUsage, bool fCopyUserData);
187PPDMAUDIODEVICE DrvAudioHlpDeviceEnumGetDefaultDevice(const PPDMAUDIODEVICEENUM pDevEnm, PDMAUDIODIR enmDir);
188void DrvAudioHlpDeviceEnumPrint(const char *pszDesc, const PPDMAUDIODEVICEENUM pDevEnm);
189
190const char *DrvAudioHlpAudDirToStr(PDMAUDIODIR enmDir);
191const char *DrvAudioHlpAudMixerCtlToStr(PDMAUDIOMIXERCTL enmMixerCtl);
192char *DrvAudioHlpAudDevFlagsToStrA(PDMAUDIODEVFLAG fFlags);
193
194int DrvAudioHlpWAVFileOpen(PPDMAUDIOFILE pFile, const char *pszFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps, PDMAUDIOFILEFLAGS fFlags);
195int DrvAudioHlpWAVFileClose(PPDMAUDIOFILE pFile);
196size_t DrvAudioHlpWAVFileGetDataSize(PPDMAUDIOFILE pFile);
197int DrvAudioHlpWAVFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags);
198
199#define AUDIO_MAKE_FOURCC(c0, c1, c2, c3) RT_H2LE_U32_C(RT_MAKE_U32_FROM_U8(c0, c1, c2, c3))
200
201#endif /* DRV_AUDIO_H */
202
Note: See TracBrowser for help on using the repository browser.

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