VirtualBox

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

Last change on this file since 55747 was 55335, checked in by vboxsync, 10 years ago

Audio: Spelling, Hungarian fixes.

  • 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 55335 2015-04-17 16:00:22Z 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
152typedef struct fixed_settings
153{
154 int enabled;
155 int cStreams;
156 int greedy;
157 PDMAUDIOSTREAMCFG settings;
158} fixed_settings;
159
160static struct {
161 struct fixed_settings fixed_out;
162 struct fixed_settings fixed_in;
163 union {
164 int hz;
165 int64_t ticks;
166 } period;
167 int plive;
168} conf = {
169
170 /* Fixed output settings. */
171 { /* DAC fixed settings */
172 1, /* enabled */
173 1, /* cStreams */
174 1, /* greedy */
175 {
176 44100, /* freq */
177 2, /* nchannels */
178 AUD_FMT_S16, /* fmt */
179 PDMAUDIOHOSTENDIANNESS
180 }
181 },
182
183 /* Fixed input settings. */
184 { /* ADC fixed settings */
185 1, /* enabled */
186 2, /* cStreams */
187 1, /* greedy */
188 {
189 44100, /* freq */
190 2, /* nchannels */
191 AUD_FMT_S16, /* fmt */
192 PDMAUDIOHOSTENDIANNESS
193 }
194 },
195
196 { 200 }, /* frequency (in Hz) */
197 0, /* plive */ /** @todo Disable pending live? */
198};
199#endif /* DRV_AUDIO_H */
200
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