1 | /* $Id: AudioTest.h 89019 2021-05-12 16:45:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Audio testing routines.
|
---|
4 | * Common code which is being used by the ValidationKit audio test (VKAT)
|
---|
5 | * and the debug / ValdikationKit audio driver(s).
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2021 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 VBOX_INCLUDED_SRC_Audio_AudioTest_h
|
---|
21 | #define VBOX_INCLUDED_SRC_Audio_AudioTest_h
|
---|
22 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
23 | # pragma once
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | #define AUDIOTEST_PATH_PREFIX_STR "audio-test-"
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Enumeration for an audio test tone (wave) type.
|
---|
30 | */
|
---|
31 | typedef enum AUDIOTESTTONETYPE
|
---|
32 | {
|
---|
33 | /** Invalid type. */
|
---|
34 | AUDIOTESTTONETYPE_INVALID = 0,
|
---|
35 | /** Sine wave. */
|
---|
36 | AUDIOTESTTONETYPE_SINE,
|
---|
37 | /** Square wave. Not implemented yet. */
|
---|
38 | AUDIOTESTTONETYPE_SQUARE,
|
---|
39 | /** Triangluar wave. Not implemented yet. */
|
---|
40 | AUDIOTESTTONETYPE_TRIANGLE,
|
---|
41 | /** Sawtooth wave. Not implemented yet. */
|
---|
42 | AUDIOTESTTONETYPE_SAWTOOTH,
|
---|
43 | /** The usual 32-bit hack. */
|
---|
44 | AUDIOTESTTONETYPE_32BIT_HACK = 0x7fffffff
|
---|
45 | } AUDIOTESTTONETYPE;
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Structure for handling an audio (sine wave) test tone.
|
---|
49 | */
|
---|
50 | typedef struct AUDIOTESTTONE
|
---|
51 | {
|
---|
52 | /** The tone's wave type. */
|
---|
53 | AUDIOTESTTONETYPE enmType;
|
---|
54 | /** The PCM properties. */
|
---|
55 | PDMAUDIOPCMPROPS Props;
|
---|
56 | /** Current sample index for generate the sine wave. */
|
---|
57 | uint64_t uSample;
|
---|
58 | /** The fixed portion of the sin() input. */
|
---|
59 | double rdFixed;
|
---|
60 | /** Frequency (in Hz) of the sine wave to generate. */
|
---|
61 | double rdFreqHz;
|
---|
62 | } AUDIOTESTTONE;
|
---|
63 | /** Pointer to an audio test tone. */
|
---|
64 | typedef AUDIOTESTTONE *PAUDIOTESTTONE;
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Structure for handling audio test tone parameters.
|
---|
68 | */
|
---|
69 | typedef struct AUDIOTESTTONEPARMS
|
---|
70 | {
|
---|
71 | /** The PCM properties. */
|
---|
72 | PDMAUDIOPCMPROPS Props;
|
---|
73 | /** Prequel (in ms) to play silence. Optional and can be set to 0. */
|
---|
74 | RTMSINTERVAL msPrequel;
|
---|
75 | /** Duration (in ms) to play the test tone. */
|
---|
76 | RTMSINTERVAL msDuration;
|
---|
77 | /** Sequel (in ms) to play silence. Optional and can be set to 0. */
|
---|
78 | RTMSINTERVAL msSequel;
|
---|
79 | /** Volume (in percent, 0-100) to use.
|
---|
80 | * If set to 0, the tone is muted (i.e. silent). */
|
---|
81 | uint8_t uVolumePercent;
|
---|
82 | } AUDIOTESTTONEPARMS;
|
---|
83 | /** Pointer to audio test tone parameters. */
|
---|
84 | typedef AUDIOTESTTONEPARMS *PAUDIOTESTTONEPARMS;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Structure for keeping an audio test audio stream.
|
---|
88 | */
|
---|
89 | typedef struct AUDIOTESTSTREAM
|
---|
90 | {
|
---|
91 | /** Created flag to avoid double destruction in backends. */
|
---|
92 | bool fCreated;
|
---|
93 | /** Backend-specific stream data. */
|
---|
94 | PDMAUDIOBACKENDSTREAM Backend;
|
---|
95 | } AUDIOTESTSTREAM;
|
---|
96 | /** Pointer to audio test stream. */
|
---|
97 | typedef AUDIOTESTSTREAM *PAUDIOTESTSTREAM;
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Enumeration for the test set mode.
|
---|
101 | */
|
---|
102 | typedef enum AUDIOTESTSETMODE
|
---|
103 | {
|
---|
104 | /** Invalid test set mode. */
|
---|
105 | AUDIOTESTSETMODE_INVALID = 0,
|
---|
106 | /** Test set is being created (testing in progress). */
|
---|
107 | AUDIOTESTSETMODE_TEST,
|
---|
108 | /** Existing test set is being verified. */
|
---|
109 | AUDIOTESTSETMODE_VERIFY,
|
---|
110 | /** The usual 32-bit hack. */
|
---|
111 | AUDIOTESTSETMODE_32BIT_HACK = 0x7fffffff
|
---|
112 | } AUDIOTESTSETMODE;
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Enumeration to specify an audio test type.
|
---|
116 | */
|
---|
117 | typedef enum AUDIOTESTTYPE
|
---|
118 | {
|
---|
119 | /** Invalid test type, do not use. */
|
---|
120 | AUDIOTESTTYPE_INVALID = 0,
|
---|
121 | /** Play a test tone. */
|
---|
122 | AUDIOTESTTYPE_TESTTONE
|
---|
123 | } AUDIOTESTTYPE;
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Audio test request data.
|
---|
127 | */
|
---|
128 | typedef struct AUDIOTESTPARMS
|
---|
129 | {
|
---|
130 | /** Specifies the test to run. */
|
---|
131 | uint32_t idxTest;
|
---|
132 | /** How many iterations the test should be executed. */
|
---|
133 | uint32_t cIterations;
|
---|
134 | /** Audio device to use. */
|
---|
135 | PDMAUDIOHOSTDEV Dev;
|
---|
136 | /** How much to delay (wait, in ms) the test being executed. */
|
---|
137 | RTMSINTERVAL msDelay;
|
---|
138 | /** The test direction. */
|
---|
139 | PDMAUDIODIR enmDir;
|
---|
140 | /** The test type. */
|
---|
141 | AUDIOTESTTYPE enmType;
|
---|
142 | /** Union for test type-specific data. */
|
---|
143 | union
|
---|
144 | {
|
---|
145 | AUDIOTESTTONEPARMS TestTone;
|
---|
146 | };
|
---|
147 | } AUDIOTESTPARMS;
|
---|
148 | /** Pointer to a test parameter structure. */
|
---|
149 | typedef AUDIOTESTPARMS *PAUDIOTESTPARMS;
|
---|
150 |
|
---|
151 | /**
|
---|
152 | * Structure specifying an audio test set.
|
---|
153 | */
|
---|
154 | typedef struct AUDIOTESTSET
|
---|
155 | {
|
---|
156 | /** Absolute path where to store the test audio data. */
|
---|
157 | char szPathAbs[RTPATH_MAX];
|
---|
158 | /** Current mode the test set is in. */
|
---|
159 | AUDIOTESTSETMODE enmMode;
|
---|
160 | union
|
---|
161 | {
|
---|
162 | RTFILE hFile;
|
---|
163 | RTINIFILE hIniFile;
|
---|
164 | } f;
|
---|
165 | } AUDIOTESTSET;
|
---|
166 | /** Pointer to an audio test set. */
|
---|
167 | typedef AUDIOTESTSET *PAUDIOTESTSET;
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Structure for holding a single audio test error entry.
|
---|
171 | */
|
---|
172 | typedef struct AUDIOTESTERRORENTRY
|
---|
173 | {
|
---|
174 | /** The entrie's list node. */
|
---|
175 | RTLISTNODE Node;
|
---|
176 | /** Additional rc. */
|
---|
177 | int rc;
|
---|
178 | /** Actual error description. */
|
---|
179 | char szDesc[128];
|
---|
180 | } AUDIOTESTERRORENTRY;
|
---|
181 | /** Pointer to an audio test error description. */
|
---|
182 | typedef AUDIOTESTERRORENTRY *PAUDIOTESTERRORENTRY;
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * Structure for holding an audio test error description.
|
---|
186 | * This can contain multiple errors (FIFO list).
|
---|
187 | */
|
---|
188 | typedef struct AUDIOTESTERRORDESC
|
---|
189 | {
|
---|
190 | RTLISTANCHOR List;
|
---|
191 | uint32_t cErrors;
|
---|
192 | } AUDIOTESTERRORDESC;
|
---|
193 | /** Pointer to an audio test error description. */
|
---|
194 | typedef AUDIOTESTERRORDESC *PAUDIOTESTERRORDESC;
|
---|
195 |
|
---|
196 |
|
---|
197 | double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps);
|
---|
198 | int AudioTestToneWrite(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);
|
---|
199 |
|
---|
200 | int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps);
|
---|
201 |
|
---|
202 | int AudioTestPathCreateTemp(char *pszPath, size_t cbPath, const char *pszUUID);
|
---|
203 | int AudioTestPathCreate(char *pszPath, size_t cbPath, const char *pszUUID);
|
---|
204 |
|
---|
205 | int AudioTestSetCreate(PAUDIOTESTSET pSet, const char *pszPath, const char *pszTag);
|
---|
206 | void AudioTestSetDestroy(PAUDIOTESTSET pSet);
|
---|
207 | int AudioTestSetOpen(PAUDIOTESTSET pSet, const char *pszPath);
|
---|
208 | void AudioTestSetClose(PAUDIOTESTSET pSet);
|
---|
209 | int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir);
|
---|
210 | int AudioTestSetUnpack(const char *pszFile, const char *pszOutDir);
|
---|
211 | int AudioTestSetVerify(PAUDIOTESTSET pSet, const char *pszTag, PAUDIOTESTERRORDESC pErrDesc);
|
---|
212 |
|
---|
213 | bool AudioTestErrorDescFailed(PAUDIOTESTERRORDESC pErr);
|
---|
214 | void AudioTestErrorDescDestroy(PAUDIOTESTERRORDESC pErr);
|
---|
215 |
|
---|
216 | #endif /* !VBOX_INCLUDED_SRC_Audio_AudioTest_h */
|
---|
217 |
|
---|