VirtualBox

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

Last change on this file since 68388 was 68136, checked in by vboxsync, 8 years ago

Audio: Header updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/* $Id: DrvAudio.h 68136 2017-07-27 10:52:43Z 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 /** Input/output processing thread. */
96 RTTHREAD hThread;
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 /** Max. number of free input streams.
112 * UINT32_MAX for unlimited streams. */
113 uint32_t cStreamsFreeIn;
114 /** Max. number of free output streams.
115 * UINT32_MAX for unlimited streams. */
116 uint32_t cStreamsFreeOut;
117#ifdef VBOX_WITH_AUDIO_ENUM
118 /** Flag indicating to perform an (re-)enumeration of the host audio devices. */
119 bool fEnumerateDevices;
120#endif
121 /** Audio configuration settings retrieved from the backend. */
122 PDMAUDIOBACKENDCFG BackendCfg;
123#ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS
124 /** @todo Use a map with primary key set to the callback type? */
125 RTLISTANCHOR lstCBIn;
126 RTLISTANCHOR lstCBOut;
127#endif
128#ifdef VBOX_WITH_STATISTICS
129 /** Statistics for the statistics manager (STAM). */
130 DRVAUDIOSTATS Stats;
131#endif
132} DRVAUDIO, *PDRVAUDIO;
133
134/** Makes a PDRVAUDIO out of a PPDMIAUDIOCONNECTOR. */
135#define PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface) \
136 ( (PDRVAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIO, IAudioConnector)) )
137
138
139bool DrvAudioHlpAudFmtIsSigned(PDMAUDIOFMT enmFmt);
140uint8_t DrvAudioHlpAudFmtToBits(PDMAUDIOFMT enmFmt);
141const char *DrvAudioHlpAudFmtToStr(PDMAUDIOFMT enmFmt);
142void DrvAudioHlpClearBuf(const PPDMAUDIOPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cFrames);
143uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels);
144uint32_t DrvAudioHlpCalcBitrate(const PPDMAUDIOPCMPROPS pProps);
145bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps1, const PPDMAUDIOPCMPROPS pPCMProps2);
146bool DrvAudioHlpPCMPropsAreEqual(const PPDMAUDIOPCMPROPS pPCMProps, const PPDMAUDIOSTREAMCFG pCfg);
147bool DrvAudioHlpPCMPropsAreValid(const PPDMAUDIOPCMPROPS pProps);
148void DrvAudioHlpPCMPropsPrint(const PPDMAUDIOPCMPROPS pProps);
149int DrvAudioHlpPCMPropsToStreamCfg(const PPDMAUDIOPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg);
150const char *DrvAudioHlpRecSrcToStr(const PDMAUDIORECSOURCE enmRecSource);
151void DrvAudioHlpStreamCfgPrint(const PPDMAUDIOSTREAMCFG pCfg);
152bool DrvAudioHlpStreamCfgIsValid(const PPDMAUDIOSTREAMCFG pCfg);
153int DrvAudioHlpStreamCfgCopy(PPDMAUDIOSTREAMCFG pDstCfg, const PPDMAUDIOSTREAMCFG pSrcCfg);
154PPDMAUDIOSTREAMCFG DrvAudioHlpStreamCfgDup(const PPDMAUDIOSTREAMCFG pCfg);
155void DrvAudioHlpStreamCfgFree(PPDMAUDIOSTREAMCFG pCfg);
156const char *DrvAudioHlpStreamCmdToStr(PDMAUDIOSTREAMCMD enmCmd);
157PDMAUDIOFMT DrvAudioHlpStrToAudFmt(const char *pszFmt);
158
159int DrvAudioHlpSanitizeFileName(char *pszPath, size_t cbPath);
160int DrvAudioHlpGetFileName(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName, PDMAUDIOFILETYPE enmType);
161
162PPDMAUDIODEVICE DrvAudioHlpDeviceAlloc(size_t cbData);
163void DrvAudioHlpDeviceFree(PPDMAUDIODEVICE pDev);
164PPDMAUDIODEVICE DrvAudioHlpDeviceDup(const PPDMAUDIODEVICE pDev, bool fCopyUserData);
165
166int DrvAudioHlpDeviceEnumInit(PPDMAUDIODEVICEENUM pDevEnm);
167void DrvAudioHlpDeviceEnumFree(PPDMAUDIODEVICEENUM pDevEnm);
168int DrvAudioHlpDeviceEnumAdd(PPDMAUDIODEVICEENUM pDevEnm, PPDMAUDIODEVICE pDev);
169int DrvAudioHlpDeviceEnumCopyEx(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm, PDMAUDIODIR enmUsage);
170int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm);
171PPDMAUDIODEVICEENUM DrvAudioHlpDeviceEnumDup(const PPDMAUDIODEVICEENUM pDevEnm);
172int DrvAudioHlpDeviceEnumCopy(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm);
173int DrvAudioHlpDeviceEnumCopyEx(PPDMAUDIODEVICEENUM pDstDevEnm, const PPDMAUDIODEVICEENUM pSrcDevEnm, PDMAUDIODIR enmUsage, bool fCopyUserData);
174PPDMAUDIODEVICE DrvAudioHlpDeviceEnumGetDefaultDevice(const PPDMAUDIODEVICEENUM pDevEnm, PDMAUDIODIR enmDir);
175void DrvAudioHlpDeviceEnumPrint(const char *pszDesc, const PPDMAUDIODEVICEENUM pDevEnm);
176
177const char *DrvAudioHlpAudDirToStr(PDMAUDIODIR enmDir);
178const char *DrvAudioHlpAudMixerCtlToStr(PDMAUDIOMIXERCTL enmMixerCtl);
179char *DrvAudioHlpAudDevFlagsToStrA(PDMAUDIODEVFLAG fFlags);
180
181int DrvAudioHlpWAVFileOpen(PPDMAUDIOFILE pFile, const char *pszFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps, PDMAUDIOFILEFLAGS fFlags);
182int DrvAudioHlpWAVFileClose(PPDMAUDIOFILE pFile);
183size_t DrvAudioHlpWAVFileGetDataSize(PPDMAUDIOFILE pFile);
184int DrvAudioHlpWAVFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags);
185
186#define AUDIO_MAKE_FOURCC(c0, c1, c2, c3) RT_H2LE_U32_C(RT_MAKE_U32_FROM_U8(c0, c1, c2, c3))
187
188#endif /* DRV_AUDIO_H */
189
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