VirtualBox

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

Last change on this file since 62477 was 62327, checked in by vboxsync, 8 years ago

Audio/DrvAudio: Added some basic statistics for STAM.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: DrvAudio.h 62327 2016-07-19 14:55:37Z vboxsync $ */
2/** @file
3 * Intermediate audio driver header.
4 */
5
6/*
7 * Copyright (C) 2006-2016 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#include <iprt/critsect.h>
50
51#include <VBox/vmm/pdmdev.h>
52#include <VBox/vmm/pdm.h>
53#include <VBox/vmm/pdmaudioifs.h>
54
55typedef enum
56{
57 AUD_OPT_INT,
58 AUD_OPT_FMT,
59 AUD_OPT_STR,
60 AUD_OPT_BOOL
61} audio_option_tag_e;
62
63typedef struct audio_option
64{
65 const char *name;
66 audio_option_tag_e tag;
67 void *valp;
68 const char *descr;
69 int *overridenp;
70 int overriden;
71} audio_option;
72
73#ifdef VBOX_WITH_STATISTICS
74/**
75 * Structure for keeping stream statistics for the
76 * statistic manager (STAM).
77 */
78typedef struct DRVAUDIOSTATS
79{
80 STAMCOUNTER TotalStreamsActive;
81 STAMCOUNTER TotalStreamsCreated;
82 STAMCOUNTER TotalSamplesPlayed;
83 STAMCOUNTER TotalSamplesCaptured;
84 STAMCOUNTER TotalBytesRead;
85 STAMCOUNTER TotalBytesWritten;
86} DRVAUDIOSTATS, *PDRVAUDIOSTATS;
87#endif
88
89/**
90 * Audio driver instance data.
91 *
92 * @implements PDMIAUDIOCONNECTOR
93 */
94typedef struct DRVAUDIO
95{
96 /** Input/output processing thread. */
97 RTTHREAD hThread;
98 /** Critical section for serializing access. */
99 RTCRITSECT CritSect;
100 /** Shutdown indicator. */
101 bool fTerminate;
102 /** Our audio connector interface. */
103 PDMIAUDIOCONNECTOR IAudioConnector;
104 /** Pointer to the driver instance. */
105 PPDMDRVINS pDrvIns;
106 /** Pointer to audio driver below us. */
107 PPDMIHOSTAUDIO pHostDrvAudio;
108 /** List of host input/output audio streams. */
109 RTLISTANCHOR lstHstStreams;
110 /** List of guest input/output audio streams. */
111 RTLISTANCHOR lstGstStreams;
112 /** Max. number of free input streams.
113 * UINT32_MAX for unlimited streams. */
114 uint32_t cStreamsFreeIn;
115 /** Max. number of free output streams.
116 * UINT32_MAX for unlimited streams. */
117 uint32_t cStreamsFreeOut;
118 /** Audio configuration settings retrieved from the backend. */
119 PDMAUDIOBACKENDCFG BackendCfg;
120#ifdef VBOX_WITH_AUDIO_CALLBACKS
121 /** @todo Use a map with primary key set to the callback type? */
122 RTLISTANCHOR lstCBIn;
123 RTLISTANCHOR lstCBOut;
124#endif
125#ifdef VBOX_WITH_STATISTICS
126 /** Statistics for the statistics manager (STAM). */
127 DRVAUDIOSTATS Stats;
128#endif
129} DRVAUDIO, *PDRVAUDIO;
130
131/** Makes a PDRVAUDIO out of a PPDMIAUDIOCONNECTOR. */
132#define PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface) \
133 ( (PDRVAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIO, IAudioConnector)) )
134
135
136bool DrvAudioHlpAudFmtIsSigned(PDMAUDIOFMT enmFmt);
137uint8_t DrvAudioHlpAudFmtToBits(PDMAUDIOFMT enmFmt);
138const char *DrvAudioHlpAudFmtToStr(PDMAUDIOFMT enmFmt);
139void DrvAudioHlpClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cSamples);
140bool DrvAudioHlpPCMPropsAreEqual(PPDMPCMPROPS pPCMProps1, PPDMPCMPROPS pPCMProps2);
141bool DrvAudioHlpPCMPropsAreEqual(PPDMPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg);
142int DrvAudioHlpPCMPropsToStreamCfg(PPDMPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg);
143const char *DrvAudioHlpRecSrcToStr(PDMAUDIORECSOURCE enmRecSource);
144void DrvAudioHlpStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg);
145bool DrvAudioHlpStreamCfgIsValid(PPDMAUDIOSTREAMCFG pCfg);
146int DrvAudioHlpStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);
147PDMAUDIOFMT DrvAudioHlpStrToAudFmt(const char *pszFmt);
148
149#endif /* DRV_AUDIO_H */
150
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