VirtualBox

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

Last change on this file since 54988 was 54433, checked in by vboxsync, 10 years ago

export

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 KB
Line 
1/* $Id: DrvAudio.h 54433 2015-02-24 10:49:21Z vboxsync $ */
2/** @file
3 * Intermediate audio driver header.
4 */
5
6/*
7 * Copyright (C) 2006-2014 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);
112int drvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);
113void drvAudioStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg);
114
115/* AUDIO IN function declarations. */
116void drvAudioHlpPcmSwFreeResourcesIn(PPDMAUDIOGSTSTRMIN pGstStrmIn);
117void drvAudioGstInFreeRes(PPDMAUDIOGSTSTRMIN pGstStrmIn);
118void drvAudioGstInRemove(PPDMAUDIOGSTSTRMIN pGstStrmIn);
119uint32_t drvAudioHstInFindMinCaptured(PPDMAUDIOHSTSTRMIN pHstStrmIn);
120void drvAudioHstInFreeRes(PPDMAUDIOHSTSTRMIN pHstStrmIn);
121uint32_t drvAudioHstInGetFree(PPDMAUDIOHSTSTRMIN pHstStrmIn);
122uint32_t drvAudioHstInGetLive(PPDMAUDIOHSTSTRMIN pHstStrmIn);
123void drvAudioGstInRemove(PPDMAUDIOGSTSTRMIN pGstStrmIn);
124int drvAudioGstInInit(PPDMAUDIOGSTSTRMIN pGstStrmIn, PPDMAUDIOHSTSTRMIN pHstStrmIn, const char *pszName, PPDMAUDIOSTREAMCFG pCfg);
125
126PPDMAUDIOHSTSTRMIN drvAudioFindNextHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn);
127PPDMAUDIOHSTSTRMIN drvAudioFindNextEnabledHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn);
128PPDMAUDIOHSTSTRMIN drvAudioFindNextEqHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn, PPDMAUDIOSTREAMCFG pCfg);
129
130/* AUDIO OUT function declarations. */
131int drvAudioGstOutAlloc(PPDMAUDIOGSTSTRMOUT pGstStrmOut);
132void drvAudioGstOutFreeRes(PPDMAUDIOGSTSTRMOUT pGstStrmOut);
133void drvAudioHstOutFreeRes(PPDMAUDIOHSTSTRMOUT pHstStrmOut);
134int drvAudioDestroyGstOut(PDRVAUDIO pDrvAudio, PPDMAUDIOGSTSTRMOUT pGstStrmOut);
135void drvAudioDestroyHstOut(PDRVAUDIO pDrvAudio, PDMAUDIOHSTSTRMOUT pHstStrmOut);
136int drvAudioGstOutInit(PPDMAUDIOGSTSTRMOUT pGstStrmOut, PPDMAUDIOHSTSTRMOUT pHstStrmOut, const char *pszName, PPDMAUDIOSTREAMCFG pCfg);
137
138PPDMAUDIOHSTSTRMOUT drvAudioFindAnyHstOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
139PPDMAUDIOHSTSTRMOUT drvAudioHstFindAnyEnabledOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
140PPDMAUDIOHSTSTRMOUT drvAudioFindSpecificOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pCfg);
141int drvAudioAllocHstOut(PDRVAUDIO pDrvAudio, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut);
142int drvAudioHlpPcmHwAddOut(PDRVAUDIO pDrvAudio, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut);
143int drvAudioHlpPcmCreateVoicePairOut(PDRVAUDIO pDrvAudio, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut);
144
145/* Common functions between DrvAudio and backends (host audio drivers). */
146int drvAudioAttachCapture(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
147void drvAudioDetachCapture(PPDMAUDIOHSTSTRMOUT pHstStrmOut);
148uint32_t drvAudioHstOutSamplesLive(PPDMAUDIOHSTSTRMOUT pHstStrmOut, uint32_t *pcStreamsLive);
149
150void audio_pcm_info_clear_buf(PPDMPCMPROPS pPCMInfo, void *pvBuf, int len);
151
152/* Externals. */
153extern volume_t nominal_volume;
154extern volume_t pcm_in_volume;
155
156typedef struct fixed_settings
157{
158 int enabled;
159 int cStreams;
160 int greedy;
161 PDMAUDIOSTREAMCFG settings;
162} fixed_settings;
163
164static struct {
165 struct fixed_settings fixed_out;
166 struct fixed_settings fixed_in;
167 union {
168 int hz;
169 int64_t ticks;
170 } period;
171 int plive;
172} conf = {
173
174 /* Fixed output settings. */
175 { /* DAC fixed settings */
176 1, /* enabled */
177 1, /* cStreams */
178 1, /* greedy */
179 {
180 44100, /* freq */
181 2, /* nchannels */
182 AUD_FMT_S16, /* fmt */
183 PDMAUDIOHOSTENDIANESS
184 }
185 },
186
187 /* Fixed input settings. */
188 { /* ADC fixed settings */
189 1, /* enabled */
190 1, /* cStreams */
191 1, /* greedy */
192 {
193 44100, /* freq */
194 2, /* nchannels */
195 AUD_FMT_S16, /* fmt */
196 PDMAUDIOHOSTENDIANESS
197 }
198 },
199
200 { 200 }, /* frequency (in Hz) */
201 0, /* plive */ /** @todo Disable pending live? */
202};
203#endif /* DRV_AUDIO_H */
204
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