1 | /* $Id: AudioTest.h 88985 2021-05-11 16:31:00Z 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 | * Structure for handling an audio (sine wave) test tone.
|
---|
30 | */
|
---|
31 | typedef struct AUDIOTESTTONE
|
---|
32 | {
|
---|
33 | /** The PCM properties. */
|
---|
34 | PDMAUDIOPCMPROPS Props;
|
---|
35 | /** Current sample index for generate the sine wave. */
|
---|
36 | uint64_t uSample;
|
---|
37 | /** The fixed portion of the sin() input. */
|
---|
38 | double rdFixed;
|
---|
39 | /** Frequency (in Hz) of the sine wave to generate. */
|
---|
40 | double rdFreqHz;
|
---|
41 | } AUDIOTESTTONE;
|
---|
42 | /** Pointer to an audio test tone. */
|
---|
43 | typedef AUDIOTESTTONE *PAUDIOTESTTONE;
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * Structure for handling audio test tone parameters.
|
---|
47 | */
|
---|
48 | typedef struct AUDIOTESTTONEPARMS
|
---|
49 | {
|
---|
50 | /** The PCM properties. */
|
---|
51 | PDMAUDIOPCMPROPS Props;
|
---|
52 | /** Prequel (in ms) to play silence. Optional and can be set to 0. */
|
---|
53 | RTMSINTERVAL msPrequel;
|
---|
54 | /** Duration (in ms) to play the test tone. */
|
---|
55 | RTMSINTERVAL msDuration;
|
---|
56 | /** Sequel (in ms) to play silence. Optional and can be set to 0. */
|
---|
57 | RTMSINTERVAL msSequel;
|
---|
58 | /** Volume (in percent, 0-100) to use.
|
---|
59 | * If set to 0, the tone is muted (i.e. silent). */
|
---|
60 | uint8_t uVolumePercent;
|
---|
61 | } AUDIOTESTTONEPARMS;
|
---|
62 | /** Pointer to audio test tone parameters. */
|
---|
63 | typedef AUDIOTESTTONEPARMS *PAUDIOTESTTONEPARMS;
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Enumeration for the test set mode.
|
---|
67 | */
|
---|
68 | typedef enum AUDIOTESTSETMODE
|
---|
69 | {
|
---|
70 | /** Invalid test set mode. */
|
---|
71 | AUDIOTESTSETMODE_INVALID = 0,
|
---|
72 | /** Test set is being created (testing in progress). */
|
---|
73 | AUDIOTESTSETMODE_TEST,
|
---|
74 | /** Existing test set is being verified. */
|
---|
75 | AUDIOTESTSETMODE_VERIFY,
|
---|
76 | /** The usual 32-bit hack. */
|
---|
77 | AUDIOTESTSETMODE_32BIT_HACK = 0x7fffffff
|
---|
78 | } AUDIOTESTSETMODE;
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Structure specifying an audio test set.
|
---|
82 | */
|
---|
83 | typedef struct AUDIOTESTSET
|
---|
84 | {
|
---|
85 | /** Absolute path where to store the test audio data. */
|
---|
86 | char szPathAbs[RTPATH_MAX];
|
---|
87 | /** Current mode the test set is in. */
|
---|
88 | AUDIOTESTSETMODE enmMode;
|
---|
89 | union
|
---|
90 | {
|
---|
91 | RTFILE hFile;
|
---|
92 | RTINIFILE hIniFile;
|
---|
93 | } f;
|
---|
94 | } AUDIOTESTSET;
|
---|
95 | /** Pointer to an audio test set. */
|
---|
96 | typedef AUDIOTESTSET *PAUDIOTESTSET;
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Structure for holding a single audio test error entry.
|
---|
100 | */
|
---|
101 | typedef struct AUDIOTESTERRORENTRY
|
---|
102 | {
|
---|
103 | /** The entrie's list node. */
|
---|
104 | RTLISTNODE Node;
|
---|
105 | /** Additional rc. */
|
---|
106 | int rc;
|
---|
107 | /** Actual error description. */
|
---|
108 | char szDesc[128];
|
---|
109 | } AUDIOTESTERRORENTRY;
|
---|
110 | /** Pointer to an audio test error description. */
|
---|
111 | typedef AUDIOTESTERRORENTRY *PAUDIOTESTERRORENTRY;
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Structure for holding an audio test error description.
|
---|
115 | * This can contain multiple errors (FIFO list).
|
---|
116 | */
|
---|
117 | typedef struct AUDIOTESTERRORDESC
|
---|
118 | {
|
---|
119 | RTLISTANCHOR List;
|
---|
120 | uint32_t cErrors;
|
---|
121 | } AUDIOTESTERRORDESC;
|
---|
122 | /** Pointer to an audio test error description. */
|
---|
123 | typedef AUDIOTESTERRORDESC *PAUDIOTESTERRORDESC;
|
---|
124 |
|
---|
125 |
|
---|
126 | double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps);
|
---|
127 | int AudioTestToneWrite(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);
|
---|
128 |
|
---|
129 | int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps);
|
---|
130 |
|
---|
131 | int AudioTestPathCreateTemp(char *pszPath, size_t cbPath, const char *pszUUID);
|
---|
132 | int AudioTestPathCreate(char *pszPath, size_t cbPath, const char *pszUUID);
|
---|
133 |
|
---|
134 | int AudioTestSetCreate(PAUDIOTESTSET pSet, const char *pszPath, const char *pszTag);
|
---|
135 | void AudioTestSetDestroy(PAUDIOTESTSET pSet);
|
---|
136 | int AudioTestSetOpen(PAUDIOTESTSET pSet, const char *pszPath);
|
---|
137 | void AudioTestSetClose(PAUDIOTESTSET pSet);
|
---|
138 | int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir);
|
---|
139 | int AudioTestSetUnpack(const char *pszFile, const char *pszOutDir);
|
---|
140 | int AudioTestSetVerify(PAUDIOTESTSET pSet, const char *pszTag, PAUDIOTESTERRORDESC pErrDesc);
|
---|
141 |
|
---|
142 | bool AudioTestErrorDescFailed(PAUDIOTESTERRORDESC pErr);
|
---|
143 | void AudioTestErrorDescDestroy(PAUDIOTESTERRORDESC pErr);
|
---|
144 |
|
---|
145 | #endif /* !VBOX_INCLUDED_SRC_Audio_AudioTest_h */
|
---|
146 |
|
---|