VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTest.h@ 89045

Last change on this file since 89045 was 89043, checked in by vboxsync, 4 years ago

Audio/ValKit: Docs update, use intermediate path in AudioTestPathCreateTemp(). bugref:10008

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette