1 | /* $Id: AudioMixer.h 53442 2014-12-04 13:49:43Z 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 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 | /* List of audio mixer sinks. */
|
---|
35 | RTLISTANCHOR lstSinks;
|
---|
36 | /** Number of used audio sinks. */
|
---|
37 | uint8_t cSinks;
|
---|
38 | } AUDIOMIXER, *PAUDIOMIXER;
|
---|
39 |
|
---|
40 | typedef struct AUDMIXSTREAM
|
---|
41 | {
|
---|
42 | RTLISTNODE Node;
|
---|
43 | PPDMIAUDIOCONNECTOR pConn;
|
---|
44 | /** @todo Add support for output streams. */
|
---|
45 | PPDMAUDIOGSTSTRMIN pStrm;
|
---|
46 | } AUDMIXSTREAM, *PAUDMIXSTREAM;
|
---|
47 |
|
---|
48 | typedef enum AUDMIXSINKDIR
|
---|
49 | {
|
---|
50 | AUDMIXSINKDIR_UNKNOWN = 0,
|
---|
51 | AUDMIXSINKDIR_INPUT,
|
---|
52 | AUDMIXSINKDIR_OUTPUT
|
---|
53 | } AUDMIXSINKDIR;
|
---|
54 |
|
---|
55 | typedef struct AUDMIXSINK
|
---|
56 | {
|
---|
57 | RTLISTNODE Node;
|
---|
58 | /** Name of this sink. */
|
---|
59 | char *pszName;
|
---|
60 | /** The sink direction, that is,
|
---|
61 | * if this sink handles input or output. */
|
---|
62 | AUDMIXSINKDIR enmDir;
|
---|
63 | /** Pointer to mixer object this sink is bound
|
---|
64 | * to. */
|
---|
65 | PAUDIOMIXER pParent;
|
---|
66 | /** Number of streams assigned. */
|
---|
67 | uint8_t cStreams;
|
---|
68 | /** List of assigned streams. */
|
---|
69 | RTLISTANCHOR lstStreams;
|
---|
70 | /** This sink's mixing buffer. */
|
---|
71 | PDMAUDIOMIXBUF MixBuf;
|
---|
72 | } AUDMIXSINK, *PAUDMIXSINK;
|
---|
73 |
|
---|
74 | typedef enum AUDMIXOP
|
---|
75 | {
|
---|
76 | AUDMIXOP_NONE = 0,
|
---|
77 | AUDMIXOP_COPY,
|
---|
78 | AUDMIXOP_BLEND
|
---|
79 | } AUDMIXOP;
|
---|
80 |
|
---|
81 |
|
---|
82 | int audioMixerAddSink(PAUDIOMIXER pMixer, const char *pszName, PAUDMIXSINK *ppSink);
|
---|
83 | int audioMixerAddStreamIn(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOGSTSTRMIN pStream, uint32_t uFlags, PAUDMIXSTREAM *ppStream);
|
---|
84 | int audioMixerControlStream(AUDMIXSTREAM pHandle); /** @todo */
|
---|
85 | int audioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer);
|
---|
86 | void audioMixerDestroy(PAUDIOMIXER pMixer);
|
---|
87 | int audioMixerProcessSamples(AUDMIXOP enmOp, PPDMAUDIOSAMPLE pDst, uint32_t cToWrite, PPDMAUDIOSAMPLE pSrc, uint32_t cToRead, uint32_t *pcRead, uint32_t *pcWritten);
|
---|
88 | int audioMixerProcessSamplesEx(AUDMIXOP enmOp, void *pvParms, size_t cbParms, PPDMAUDIOSAMPLE pDst, uint32_t cToWrite, PPDMAUDIOSAMPLE pSrc, uint32_t cToRead, uint32_t *pcRead, uint32_t *pcWritten);
|
---|
89 | uint32_t audioMixerGetStreamCount(PAUDIOMIXER pMixer);
|
---|
90 | int audioMixerProcessSinkIn(PAUDMIXSINK pSink, void *pvBuf, size_t cbBuf, uint32_t *pcbProcessed);
|
---|
91 | void audioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink);
|
---|
92 | void audioMixerRemoveStream(PAUDMIXSINK pMixer, PAUDMIXSTREAM pStream);
|
---|
93 | int audioMixerSetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg);
|
---|
94 |
|
---|
95 | #endif /* AUDIO_MIXER_H */
|
---|