1 | /* $Id: AudioMixer.h 61413 2016-06-02 13:24:16Z 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 | 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 | int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
|
---|
101 | uint32_t AudioMixerGetStreamCount(PAUDIOMIXER pMixer);
|
---|
102 | void AudioMixerInvalidate(PAUDIOMIXER pMixer);
|
---|
103 | int AudioMixerProcessSinkIn(PAUDMIXSINK pSink, AUDMIXOP enmOp, void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed);
|
---|
104 | int AudioMixerProcessSinkOut(PAUDMIXSINK pSink, AUDMIXOP enmOp, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbProcessed);
|
---|
105 | void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);
|
---|
106 | void AudioMixerRemoveStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream);
|
---|
107 | int AudioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
|
---|
108 | int AudioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol);
|
---|
109 | int AudioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol);
|
---|
110 | void AudioMixerDebug(PAUDIOMIXER pMixer, PCDBGFINFOHLP pHlp, const char *pszArgs);
|
---|
111 |
|
---|
112 | #endif /* AUDIO_MIXER_H */
|
---|
113 |
|
---|