VirtualBox

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

Last change on this file since 58459 was 58378, checked in by vboxsync, 9 years ago

Audio: Renaming / cleanups:

  • Got rid of custom shifting and use AUDIOMIXBUF_S2B / AUDIOMIXBUF_B2S instead.
  • Renamed drvAudioStreamCfgToProps() to DrvAudioStreamCfgToProps() as this is a public function for the host backends.
  • Replaced drvAudioHstOutSamplesLive() with AudioMixBufAvail().
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/* $Id: DrvAudio.h 58378 2015-10-22 12:46:32Z vboxsync $ */
2/** @file
3 * Intermediate audio driver header.
4 */
5
6/*
7 * Copyright (C) 2006-2015 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 * This code is based on: audio.h
19 *
20 * QEMU Audio subsystem header
21 *
22 * Copyright (c) 2003-2005 Vassili Karpov (malc)
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a copy
25 * of this software and associated documentation files (the "Software"), to deal
26 * in the Software without restriction, including without limitation the rights
27 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 * copies of the Software, and to permit persons to whom the Software is
29 * furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice shall be included in
32 * all copies or substantial portions of the Software.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40 * THE SOFTWARE.
41 */
42
43#ifndef DRV_AUDIO_H
44#define DRV_AUDIO_H
45
46#include <limits.h>
47
48#include <iprt/circbuf.h>
49
50#include <VBox/vmm/pdmdev.h>
51#include <VBox/vmm/pdm.h>
52#include <VBox/vmm/pdmaudioifs.h>
53
54typedef enum
55{
56 AUD_OPT_INT,
57 AUD_OPT_FMT,
58 AUD_OPT_STR,
59 AUD_OPT_BOOL
60} audio_option_tag_e;
61
62typedef struct audio_option
63{
64 const char *name;
65 audio_option_tag_e tag;
66 void *valp;
67 const char *descr;
68 int *overridenp;
69 int overriden;
70} audio_option;
71
72/**
73 * Audio driver instance data.
74 *
75 * @implements PDMIAUDIOCONNECTOR
76 */
77typedef struct DRVAUDIO
78{
79 /** Input/output processing thread. */
80 RTTHREAD hThread;
81 /** Event for input/ouput processing. */
82 RTSEMEVENT hEvent;
83 /** Shutdown indicator. */
84 bool fTerminate;
85 /** The audio interface presented to the device/driver above us. */
86 PDMIAUDIOCONNECTOR IAudioConnector;
87 /** Pointer to the driver instance. */
88 PPDMDRVINS pDrvIns;
89 /** Pointer to audio driver below us. */
90 PPDMIHOSTAUDIO pHostDrvAudio;
91 RTLISTANCHOR lstHstStrmIn;
92 RTLISTANCHOR lstHstStrmOut;
93 /** Max. number of free input streams. */
94 uint8_t cFreeInputStreams;
95 /** Max. number of free output streams. */
96 uint8_t cFreeOutputStreams;
97 /** Audio configuration settings retrieved
98 * from the backend. */
99 PDMAUDIOBACKENDCFG BackendCfg;
100
101} DRVAUDIO, *PDRVAUDIO;
102
103/** Makes a PDRVBLOCK out of a PPDMIBLOCK. */
104#define PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface) \
105 ( (PDRVAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIO, IAudioConnector)) )
106
107//const char *drvAudioHlpFormatToString(PDMAUDIOFMT fmt);
108const char *drvAudioRecSourceToString(PDMAUDIORECSOURCE enmRecSource);
109PDMAUDIOFMT drvAudioHlpStringToFormat(const char *pszFormat);
110
111bool drvAudioPCMPropsAreEqual(PPDMPCMPROPS info, PPDMAUDIOSTREAMCFG pCfg);
112void drvAudioStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg);
113
114/* AUDIO IN function declarations. */
115void drvAudioHlpPcmSwFreeResourcesIn(PPDMAUDIOGSTSTRMIN pGstStrmIn);
116void drvAudioGstInFreeRes(PPDMAUDIOGSTSTRMIN pGstStrmIn);
117void drvAudioGstInRemove(PPDMAUDIOGSTSTRMIN pGstStrmIn);
118uint32_t drvAudioHstInFindMinCaptured(PPDMAUDIOHSTSTRMIN pHstStrmIn);
119void drvAudioHstInFreeRes(PPDMAUDIOHSTSTRMIN pHstStrmIn);
120uint32_t drvAudioHstInGetFree(PPDMAUDIOHSTSTRMIN pHstStrmIn);
121uint32_t drvAudioHstInGetLive(PPDMAUDIOHSTSTRMIN pHstStrmIn);
122void drvAudioGstInRemove(PPDMAUDIOGSTSTRMIN pGstStrmIn);
123int drvAudioGstInInit(PPDMAUDIOGSTSTRMIN pGstStrmIn, PPDMAUDIOHSTSTRMIN pHstStrmIn, const char *pszName, PPDMAUDIOSTREAMCFG pCfg);
124
125PPDMAUDIOHSTSTRMIN drvAudioFindNextHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn);
126PPDMAUDIOHSTSTRMIN drvAudioFindNextEnabledHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn);
127PPDMAUDIOHSTSTRMIN drvAudioFindNextEqHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn, PPDMAUDIOSTREAMCFG pCfg);
128
129/* AUDIO OUT function declarations. */
130int drvAudioGstOutAlloc(PPDMAUDIOGSTSTRMOUT pGstStrmOut);
131void drvAudioGstOutFreeRes(PPDMAUDIOGSTSTRMOUT pGstStrmOut);
132void drvAudioHstOutFreeRes(PPDMAUDIOHSTSTRMOUT pHstStrmOut);
133int drvAudioDestroyGstOut(PDRVAUDIO pDrvAudio, PPDMAUDIOGSTSTRMOUT pGstStrmOut);
134void drvAudioDestroyHstOut(PDRVAUDIO pDrvAudio, PDMAUDIOHSTSTRMOUT pHstStrmOut);
135int drvAudioGstOutInit(PPDMAUDIOGSTSTRMOUT pGstStrmOut, PPDMAUDIOHSTSTRMOUT pHstStrmOut, const char *pszName, PPDMAUDIOSTREAMCFG pCfg);
136
137PPDMAUDIOHSTSTRMOUT drvAudioFindAnyHstOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
138PPDMAUDIOHSTSTRMOUT drvAudioHstFindAnyEnabledOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
139PPDMAUDIOHSTSTRMOUT drvAudioFindSpecificOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pCfg);
140int drvAudioAllocHstOut(PDRVAUDIO pDrvAudio, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut);
141int drvAudioHlpPcmHwAddOut(PDRVAUDIO pDrvAudio, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut);
142int drvAudioHlpPcmCreateVoicePairOut(PDRVAUDIO pDrvAudio, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut);
143
144/* Common functions between DrvAudio and backends (host audio drivers). */
145void DrvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cSamples);
146int DrvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);
147
148typedef struct fixed_settings
149{
150 int enabled;
151 int cStreams;
152 int greedy;
153 PDMAUDIOSTREAMCFG settings;
154} fixed_settings;
155
156static struct {
157 struct fixed_settings fixed_out;
158 struct fixed_settings fixed_in;
159 union {
160 int hz;
161 int64_t ticks;
162 } period;
163 int plive;
164} conf = {
165
166 /* Fixed output settings. */
167 { /* DAC fixed settings */
168 1, /* enabled */
169 1, /* cStreams */
170 1, /* greedy */
171 {
172 44100, /* freq */
173 2, /* nchannels */
174 AUD_FMT_S16, /* fmt */
175 PDMAUDIOHOSTENDIANNESS
176 }
177 },
178
179 /* Fixed input settings. */
180 { /* ADC fixed settings */
181 1, /* enabled */
182 2, /* cStreams */
183 1, /* greedy */
184 {
185 44100, /* freq */
186 2, /* nchannels */
187 AUD_FMT_S16, /* fmt */
188 PDMAUDIOHOSTENDIANNESS
189 }
190 },
191
192 { 200 }, /* frequency (in Hz) */
193 0, /* plive */ /** @todo Disable pending live? */
194};
195#endif /* DRV_AUDIO_H */
196
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