1 | /* $Id: AudioMixer.h 55065 2015-04-01 09:29:05Z 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-2015 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 | typedef struct AUDIOMIXER
|
---|
27 | {
|
---|
28 | /** Mixer name. */
|
---|
29 | char *pszName;
|
---|
30 | /** Format the mixer should convert/output
|
---|
31 | * data to so that the underlying device emulation
|
---|
32 | * can work with it. */
|
---|
33 | PDMAUDIOSTREAMCFG devFmt;
|
---|
34 | /** The master volume of this mixer. */
|
---|
35 | PDMAUDIOVOLUME VolMaster;
|
---|
36 | /* List of audio mixer sinks. */
|
---|
37 | RTLISTANCHOR lstSinks;
|
---|
38 | /** Number of used audio sinks. */
|
---|
39 | uint8_t cSinks;
|
---|
40 | } AUDIOMIXER, *PAUDIOMIXER;
|
---|
41 |
|
---|
42 | typedef struct AUDMIXSTREAM
|
---|
43 | {
|
---|
44 | RTLISTNODE Node;
|
---|
45 | PPDMIAUDIOCONNECTOR pConn;
|
---|
46 | union
|
---|
47 | {
|
---|
48 | PPDMAUDIOGSTSTRMIN pIn;
|
---|
49 | PPDMAUDIOGSTSTRMOUT pOut;
|
---|
50 | };
|
---|
51 | } AUDMIXSTREAM, *PAUDMIXSTREAM;
|
---|
52 |
|
---|
53 | typedef enum AUDMIXSINKDIR
|
---|
54 | {
|
---|
55 | AUDMIXSINKDIR_UNKNOWN = 0,
|
---|
56 | AUDMIXSINKDIR_INPUT,
|
---|
57 | AUDMIXSINKDIR_OUTPUT,
|
---|
58 | /** The usual 32-bit hack. */
|
---|
59 | AUDMIXSINKDIR_32BIT_HACK = 0x7fffffff
|
---|
60 | } AUDMIXSINKDIR;
|
---|
61 |
|
---|
62 | typedef struct AUDMIXSINK
|
---|
63 | {
|
---|
64 | RTLISTNODE Node;
|
---|
65 | /** Name of this sink. */
|
---|
66 | char *pszName;
|
---|
67 | /** The sink direction, that is,
|
---|
68 | * if this sink handles input or output. */
|
---|
69 | AUDMIXSINKDIR enmDir;
|
---|
70 | /** Pointer to mixer object this sink is bound
|
---|
71 | * to. */
|
---|
72 | PAUDIOMIXER pParent;
|
---|
73 | /** Number of streams assigned. */
|
---|
74 | uint8_t cStreams;
|
---|
75 | /** List of assigned streams. */
|
---|
76 | RTLISTANCHOR lstStreams;
|
---|
77 | /** This sink's mixing buffer. */
|
---|
78 | PDMAUDIOMIXBUF MixBuf;
|
---|
79 | /** The volume of this sink. The volume always will
|
---|
80 | * be combined with the mixer's master volume. */
|
---|
81 | PDMAUDIOVOLUME Volume;
|
---|
82 | } AUDMIXSINK, *PAUDMIXSINK;
|
---|
83 |
|
---|
84 | typedef enum AUDMIXOP
|
---|
85 | {
|
---|
86 | AUDMIXOP_NONE = 0,
|
---|
87 | AUDMIXOP_COPY,
|
---|
88 | AUDMIXOP_BLEND,
|
---|
89 | /** The usual 32-bit hack. */
|
---|
90 | AUDMIXOP_32BIT_HACK = 0x7fffffff
|
---|
91 | } AUDMIXOP;
|
---|
92 |
|
---|
93 |
|
---|
94 | int audioMixerAddSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink);
|
---|
95 | int audioMixerAddStreamIn(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMIN pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
|
---|
96 | int audioMixerAddStreamOut(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMOUT pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
|
---|
97 | int audioMixerControlStream(AUDMIXSTREAM pHandle); /** @todo Implement me. */
|
---|
98 | int audioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer);
|
---|
99 | void audioMixerDestroy(PAUDIOMIXER pMixer);
|
---|
100 | uint32_t audioMixerGetStreamCount(PAUDIOMIXER pMixer);
|
---|
101 | void audioMixerInvalidate(PAUDIOMIXER pMixer);
|
---|
102 | int audioMixerProcessSinkIn(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, size_t cbBuf, uint32_t *pcbProcessed);
|
---|
103 | int audioMixerProcessSinkOut(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, size_t cbBuf, uint32_t *pcbProcessed);
|
---|
104 | void audioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);
|
---|
105 | void audioMixerRemoveStream(PAUDMIXSINK pMixer, PAUDMIXSTREAM pStream);
|
---|
106 | int audioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
|
---|
107 | int audioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol);
|
---|
108 | int audioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol);
|
---|
109 |
|
---|
110 | #endif /* AUDIO_MIXER_H */
|
---|
111 |
|
---|