VirtualBox

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

Last change on this file since 59010 was 58744, checked in by vboxsync, 9 years ago

Audio: Update for audio notification support.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: DrvAudio.h 58744 2015-11-18 15:41:04Z 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 /** Our audio connector interface. */
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#ifdef VBOX_WITH_AUDIO_CALLBACKS
101 /** @todo Use a map with primary key set to the callback type? */
102 RTLISTANCHOR lstCBIn;
103 RTLISTANCHOR lstCBOut;
104#endif
105} DRVAUDIO, *PDRVAUDIO;
106
107/** Makes a PDRVAUDIO out of a PPDMIAUDIOCONNECTOR. */
108#define PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface) \
109 ( (PDRVAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIO, IAudioConnector)) )
110
111//const char *drvAudioHlpFormatToString(PDMAUDIOFMT fmt);
112const char *drvAudioRecSourceToString(PDMAUDIORECSOURCE enmRecSource);
113PDMAUDIOFMT drvAudioHlpStringToFormat(const char *pszFormat);
114
115bool drvAudioPCMPropsAreEqual(PPDMPCMPROPS info, PPDMAUDIOSTREAMCFG pCfg);
116void drvAudioStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg);
117
118/* AUDIO IN function declarations. */
119void drvAudioHlpPcmSwFreeResourcesIn(PPDMAUDIOGSTSTRMIN pGstStrmIn);
120void drvAudioGstInFreeRes(PPDMAUDIOGSTSTRMIN pGstStrmIn);
121void drvAudioGstInRemove(PPDMAUDIOGSTSTRMIN pGstStrmIn);
122uint32_t drvAudioHstInFindMinCaptured(PPDMAUDIOHSTSTRMIN pHstStrmIn);
123void drvAudioHstInFreeRes(PPDMAUDIOHSTSTRMIN pHstStrmIn);
124uint32_t drvAudioHstInGetFree(PPDMAUDIOHSTSTRMIN pHstStrmIn);
125uint32_t drvAudioHstInGetLive(PPDMAUDIOHSTSTRMIN pHstStrmIn);
126void drvAudioGstInRemove(PPDMAUDIOGSTSTRMIN pGstStrmIn);
127int drvAudioGstInInit(PPDMAUDIOGSTSTRMIN pGstStrmIn, PPDMAUDIOHSTSTRMIN pHstStrmIn, const char *pszName, PPDMAUDIOSTREAMCFG pCfg);
128
129PPDMAUDIOHSTSTRMIN drvAudioFindNextHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn);
130PPDMAUDIOHSTSTRMIN drvAudioFindNextEnabledHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn);
131PPDMAUDIOHSTSTRMIN drvAudioFindNextEqHstIn(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMIN pHstStrmIn, PPDMAUDIOSTREAMCFG pCfg);
132
133/* AUDIO OUT function declarations. */
134int drvAudioGstOutAlloc(PPDMAUDIOGSTSTRMOUT pGstStrmOut);
135void drvAudioGstOutFreeRes(PPDMAUDIOGSTSTRMOUT pGstStrmOut);
136void drvAudioHstOutFreeRes(PPDMAUDIOHSTSTRMOUT pHstStrmOut);
137int drvAudioDestroyGstOut(PDRVAUDIO pDrvAudio, PPDMAUDIOGSTSTRMOUT pGstStrmOut);
138void drvAudioDestroyHstOut(PDRVAUDIO pDrvAudio, PDMAUDIOHSTSTRMOUT pHstStrmOut);
139int drvAudioGstOutInit(PPDMAUDIOGSTSTRMOUT pGstStrmOut, PPDMAUDIOHSTSTRMOUT pHstStrmOut, const char *pszName, PPDMAUDIOSTREAMCFG pCfg);
140
141PPDMAUDIOHSTSTRMOUT drvAudioFindAnyHstOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
142PPDMAUDIOHSTSTRMOUT drvAudioHstFindAnyEnabledOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut);
143PPDMAUDIOHSTSTRMOUT drvAudioFindSpecificOut(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pCfg);
144int drvAudioAllocHstOut(PDRVAUDIO pDrvAudio, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut);
145int drvAudioHlpPcmHwAddOut(PDRVAUDIO pDrvAudio, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut);
146int drvAudioHlpPcmCreateVoicePairOut(PDRVAUDIO pDrvAudio, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut);
147
148/* Common functions between DrvAudio and backends (host audio drivers). */
149void DrvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cSamples);
150int DrvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);
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