VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioMixer.h@ 61157

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

Audio:

  • Unified GPDMAUDIOGSTSTRMIN / PDMAUDIOGSTSTRMOUT / PDMAUDIOHSTSTRMIN / PDMAUDIOHSTSTRMOUT structures to use a single PDMAUDIOSTREAM structure.
  • Cleaned up PDMIAUDIOCONNECTOR / PDMIHOSTAUDIO interfaces.
  • Made the VRDE audio support configurable with VBOX_WITH_VRDE_AUDIO (enabled by default).
  • Updates on mixing buffer handling. Work in progress.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1/* $Id: AudioMixer.h 61157 2016-05-24 11:47:09Z vboxsync $ */
2/** @file
3 * VBox audio: Mixing routines, mainly used by the various audio device
4 * emulations to achieve proper multiplexing from/to attached
5 * devices LUNs.
6 */
7
8/*
9 * Copyright (C) 2014-2016 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef AUDIO_MIXER_H
21#define AUDIO_MIXER_H
22
23#include <iprt/cdefs.h>
24#include <VBox/vmm/pdmaudioifs.h>
25
26/**
27 * Structure for maintaining an audio mixer instance.
28 */
29typedef struct AUDIOMIXER
30{
31 /** Mixer name. */
32 char *pszName;
33 /** Format the mixer should convert/output
34 * data to so that the underlying device emulation
35 * can work with it. */
36 PDMAUDIOSTREAMCFG devFmt;
37 /** The master volume of this mixer. */
38 PDMAUDIOVOLUME VolMaster;
39 /* List of audio mixer sinks. */
40 RTLISTANCHOR lstSinks;
41 /** Number of used audio sinks. */
42 uint8_t cSinks;
43} AUDIOMIXER, *PAUDIOMIXER;
44
45/** No flags specified. */
46#define AUDMIXSTREAM_FLAG_NONE 0
47
48/** Prototype needed for AUDMIXSTREAM struct definition. */
49typedef struct AUDMIXSINK *PAUDMIXSINK;
50
51/**
52 * Structure for maintaining an audio mixer stream.
53 */
54typedef struct AUDMIXSTREAM
55{
56 /** List node. */
57 RTLISTNODE Node;
58 /** Name of this stream. */
59 char *pszName;
60 /** Sink this stream is attached to. */
61 PAUDMIXSINK pSink;
62 /** Stream flags of type AUDMIXSTREAM_FLAG_. */
63 uint32_t fFlags;
64 /** Pointer to audio connector being used. */
65 PPDMIAUDIOCONNECTOR pConn;
66 /** Pointer to PDM audio stream this mixer stream handles. */
67 PPDMAUDIOSTREAM pStream;
68} AUDMIXSTREAM, *PAUDMIXSTREAM;
69
70/** No flags specified. */
71#define AUDMIXSINK_FLAG_NONE 0
72/** Dirty flag. */
73#define AUDMIXSINK_FLAG_DIRTY RT_BIT(0)
74
75/**
76 * Audio mixer sink direction.
77 */
78typedef enum AUDMIXSINKDIR
79{
80 AUDMIXSINKDIR_UNKNOWN = 0,
81 AUDMIXSINKDIR_INPUT,
82 AUDMIXSINKDIR_OUTPUT,
83 /** The usual 32-bit hack. */
84 AUDMIXSINKDIR_32BIT_HACK = 0x7fffffff
85} AUDMIXSINKDIR;
86
87/**
88 * Audio mixer sink command.
89 */
90typedef enum AUDMIXSINKCMD
91{
92 /** Unknown command, do not use. */
93 AUDMIXSINKCMD_UNKNOWN = 0,
94 /** Enables the sink. */
95 AUDMIXSINKCMD_ENABLE,
96 /** Disables the sink. */
97 AUDMIXSINKCMD_DISABLE,
98 /** Pauses the sink. */
99 AUDMIXSINKCMD_PAUSE,
100 /** Resumes the sink. */
101 AUDMIXSINKCMD_RESUME,
102 /** Hack to blow the type up to 32-bit. */
103 AUDMIXSINKCMD_32BIT_HACK = 0x7fffffff
104} AUDMIXSINKCMD;
105
106/**
107 * Structure for maintaining an audio mixer sink.
108 */
109typedef struct AUDMIXSINK
110{
111 RTLISTNODE Node;
112 /** Pointer to mixer object this sink is bound to. */
113 PAUDIOMIXER pParent;
114 /** Name of this sink. */
115 char *pszName;
116 /** The sink direction, that is,
117 * if this sink handles input or output. */
118 AUDMIXSINKDIR enmDir;
119 /** Sink flags of type AUDMIXSINK_FLAG_. */
120 uint32_t fFlags;
121 /** The sink's PCM format. */
122 PDMPCMPROPS PCMProps;
123 /** Number of streams assigned. */
124 uint8_t cStreams;
125 /** List of assigned streams.
126 * Note: All streams have the same PCM properties, so the
127 * mixer does not do any conversion. */
128 /** @todo Use something faster -- vector maybe? */
129 RTLISTANCHOR lstStreams;
130#ifdef VBOX_AUDIO_MIXER_WITH_MIXBUF
131 /** This sink's mixing buffer, acting as
132 * a parent buffer for all streams this sink owns. */
133 PDMAUDIOMIXBUF MixBuf;
134#endif
135 /** The volume of this sink. The volume always will
136 * be combined with the mixer's master volume. */
137 PDMAUDIOVOLUME Volume;
138} AUDMIXSINK, *PAUDMIXSINK;
139
140/**
141 * Audio mixer operation.
142 */
143typedef enum AUDMIXOP
144{
145 /** Invalid operation, do not use. */
146 AUDMIXOP_INVALID = 0,
147 AUDMIXOP_COPY,
148 AUDMIXOP_BLEND,
149 /** The usual 32-bit hack. */
150 AUDMIXOP_32BIT_HACK = 0x7fffffff
151} AUDMIXOP;
152
153/** No flags specified. */
154#define AUDMIXSTRMCTL_FLAG_NONE 0
155
156int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer);
157int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink);
158int AudioMixerCreateStream(PAUDIOMIXER pMixer, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream);
159void AudioMixerDestroy(PAUDIOMIXER pMixer);
160int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
161void AudioMixerInvalidate(PAUDIOMIXER pMixer);
162void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);
163int AudioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
164int AudioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol);
165void AudioMixerDebug(PAUDIOMIXER pMixer, PCDBGFINFOHLP pHlp, const char *pszArgs);
166
167int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream);
168int AudioMixerSinkCtl(PAUDMIXSINK pSink, AUDMIXSINKCMD enmCmd);
169void AudioMixerSinkDestroy(PAUDMIXSINK pSink);
170AUDMIXSINKDIR AudioMixerSinkGetDir(PAUDMIXSINK pSink);
171PAUDMIXSTREAM AudioMixerSinkGetStream(PAUDMIXSINK pSink, uint8_t uIndex);
172uint8_t AudioMixerSinkGetStreamCount(PAUDMIXSINK pSink);
173bool AudioMixerSinkHasData(PAUDMIXSINK pSink);
174int AudioMixerSinkRead(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
175void AudioMixerSinkRemoveStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream);
176void AudioMixerSinkRemoveAllStreams(PAUDMIXSINK pSink);
177int AudioMixerSinkSetFormat(PAUDMIXSINK pSink, PPDMPCMPROPS pPCMProps);
178int AudioMixerSinkSetVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol);
179void AudioMixerSinkTimerUpdate(PAUDMIXSINK pSink, uint64_t cTimerTicks, uint64_t cTicksElapsed, uint32_t *pcbData);
180int AudioMixerSinkWrite(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);
181int AudioMixerSinkUpdate(PAUDMIXSINK pSink);
182
183int AudioMixerStreamCtl(PAUDMIXSTREAM pStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl);
184void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream);
185bool AudioMixerStreamIsActive(PAUDMIXSTREAM pStream);
186bool AudioMixerStreamIsValid(PAUDMIXSTREAM pStream);
187
188#endif /* AUDIO_MIXER_H */
189
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