VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTestServiceProtocol.h@ 104171

Last change on this file since 104171 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/* $Id: AudioTestServiceProtocol.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * AudioTestServiceProtocol - Audio test execution server, Protocol Header.
4 */
5
6/*
7 * Copyright (C) 2021-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h
29#define VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <iprt/cdefs.h>
35#include <iprt/list.h>
36
37#include <VBox/vmm/pdmaudioifs.h>
38
39#include "AudioTest.h"
40
41RT_C_DECLS_BEGIN
42
43/** Maximum length (in bytes) an opcode can have. */
44#define ATSPKT_OPCODE_MAX_LEN 8
45/** Packet alignment. */
46#define ATSPKT_ALIGNMENT 16
47/** Max packet size. */
48#define ATSPKT_MAX_SIZE _256K
49
50/**
51 * Common Packet header (for requests and replies).
52 */
53typedef struct ATSPKTHDR
54{
55 /** The unpadded packet length. This include this header. */
56 uint32_t cb;
57 /** The CRC-32 for the packet starting from the opcode field. 0 if the packet
58 * hasn't been CRCed. */
59 uint32_t uCrc32;
60 /** Packet opcode, an unterminated ASCII string. */
61 uint8_t achOpcode[ATSPKT_OPCODE_MAX_LEN];
62} ATSPKTHDR;
63AssertCompileSize(ATSPKTHDR, 16);
64/** Pointer to a packet header. */
65typedef ATSPKTHDR *PATSPKTHDR;
66/** Pointer to a packet header. */
67typedef ATSPKTHDR const *PCATSPKTHDR;
68/** Pointer to a packet header pointer. */
69typedef PATSPKTHDR *PPATSPKTHDR;
70
71#define ATSPKT_OPCODE_HOWDY "HOWDY "
72
73/** 32bit protocol version consisting of a 16bit major and 16bit minor part. */
74#define ATS_PROTOCOL_VS (ATS_PROTOCOL_VS_MAJOR | ATS_PROTOCOL_VS_MINOR)
75/** The major version part of the protocol version. */
76#define ATS_PROTOCOL_VS_MAJOR (1 << 16)
77/** The minor version part of the protocol version. */
78#define ATS_PROTOCOL_VS_MINOR (0)
79
80/**
81 * The HOWDY request structure.
82 */
83typedef struct ATSPKTREQHOWDY
84{
85 /** Embedded packet header. */
86 ATSPKTHDR Hdr;
87 /** Version of the protocol the client wants to use. */
88 uint32_t uVersion;
89 /** Alignment. */
90 uint8_t au8Padding[12];
91} ATSPKTREQHOWDY;
92AssertCompileSizeAlignment(ATSPKTREQHOWDY, ATSPKT_ALIGNMENT);
93/** Pointer to a HOWDY request structure. */
94typedef ATSPKTREQHOWDY *PATSPKTREQHOWDY;
95
96/**
97 * The HOWDY reply structure.
98 */
99typedef struct ATSPKTREPHOWDY
100{
101 /** Packet header. */
102 ATSPKTHDR Hdr;
103 /** Version to use for the established connection. */
104 uint32_t uVersion;
105 /** Padding - reserved. */
106 uint8_t au8Padding[12];
107} ATSPKTREPHOWDY;
108AssertCompileSizeAlignment(ATSPKTREPHOWDY, ATSPKT_ALIGNMENT);
109/** Pointer to a HOWDY reply structure. */
110typedef ATSPKTREPHOWDY *PATSPKTREPHOWDY;
111
112#define ATSPKT_OPCODE_BYE "BYE "
113
114/* No additional structures for BYE. */
115
116#define ATSPKT_OPCODE_TESTSET_BEGIN "TSET BEG"
117
118/**
119 * The TSET BEG (test set begin) request structure.
120 */
121typedef struct ATSPKTREQTSETBEG
122{
123 /** Embedded packet header. */
124 ATSPKTHDR Hdr;
125 /** Audio test set tag to use. */
126 char szTag[AUDIOTEST_TAG_MAX];
127} ATSPKTREQTSETBEG;
128AssertCompileSizeAlignment(ATSPKTREQTSETBEG, ATSPKT_ALIGNMENT);
129/** Pointer to a TSET BEG reply structure. */
130typedef ATSPKTREQTSETBEG *PATSPKTREQTSETBEG;
131
132#define ATSPKT_OPCODE_TESTSET_END "TSET END"
133
134/**
135 * The TSET END (test set end) request structure.
136 */
137typedef struct ATSPKTREQTSETEND
138{
139 /** Embedded packet header. */
140 ATSPKTHDR Hdr;
141 /** Audio test set tag to use. */
142 char szTag[AUDIOTEST_TAG_MAX];
143} ATSPKTREQTSETEND;
144AssertCompileSizeAlignment(ATSPKTREQTSETEND, ATSPKT_ALIGNMENT);
145/** Pointer to a TSET STA reply structure. */
146typedef ATSPKTREQTSETEND *PATSPKTREQTSETEND;
147
148#define ATSPKT_OPCODE_TESTSET_SEND "TSET SND"
149
150/**
151 * The TSET SND (test set send) request structure.
152 */
153typedef struct ATSPKTREQTSETSND
154{
155 /** Embedded packet header. */
156 ATSPKTHDR Hdr;
157 /** Audio test set tag to use. */
158 char szTag[AUDIOTEST_TAG_MAX];
159} ATSPKTREQTSETSND;
160AssertCompileSizeAlignment(ATSPKTREQTSETSND, ATSPKT_ALIGNMENT);
161/** Pointer to a ATSPKTREQTSETSND structure. */
162typedef ATSPKTREQTSETSND *PATSPKTREQTSETSND;
163
164#define ATSPKT_OPCODE_TONE_PLAY "TN PLY "
165
166/**
167 * The TN PLY (tone play) request structure.
168 */
169typedef struct ATSPKTREQTONEPLAY
170{
171 /** Embedded packet header. */
172 ATSPKTHDR Hdr;
173 /** Test tone parameters for playback. */
174 AUDIOTESTTONEPARMS ToneParms;
175#if ARCH_BITS == 64
176 uint8_t aPadding[8];
177#else
178# ifdef RT_OS_WINDOWS
179 uint8_t aPadding[4];
180# else
181 uint8_t aPadding[12];
182# endif
183#endif
184} ATSPKTREQTONEPLAY;
185AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT);
186/** Pointer to a ATSPKTREQTONEPLAY structure. */
187typedef ATSPKTREQTONEPLAY *PATSPKTREQTONEPLAY;
188
189#define ATSPKT_OPCODE_TONE_RECORD "TN REC "
190
191/**
192 * The TN REC (tone record) request structure.
193 */
194typedef struct ATSPKTREQTONEREC
195{
196 /** Embedded packet header. */
197 ATSPKTHDR Hdr;
198 /** Test tone parameters for playback. */
199 AUDIOTESTTONEPARMS ToneParms;
200#if ARCH_BITS == 64
201 uint8_t aPadding[8];
202#else
203# ifdef RT_OS_WINDOWS
204 uint8_t aPadding[4];
205# else
206 uint8_t aPadding[12];
207# endif
208#endif
209} ATSPKTREQTONEREC;
210AssertCompileSizeAlignment(ATSPKTREQTONEREC, ATSPKT_ALIGNMENT);
211/** Pointer to a ATSPKTREQTONEREC structure. */
212typedef ATSPKTREQTONEREC *PATSPKTREQTONEREC;
213
214/* No additional structure for the reply (just standard STATUS packet). */
215
216/**
217 * The failure reply structure.
218 */
219typedef struct ATSPKTREPFAIL
220{
221 /** Embedded packet header. */
222 ATSPKTHDR Hdr;
223 /** Error code (IPRT-style). */
224 int rc;
225 /** Error description. */
226 char ach[256];
227} ATSPKTREPFAIL;
228/** Pointer to a ATSPKTREPFAIL structure. */
229typedef ATSPKTREPFAIL *PATSPKTREPFAIL;
230
231/**
232 * Checks if the two opcodes match.
233 *
234 * @returns true on match, false on mismatch.
235 * @param pPktHdr The packet header.
236 * @param pszOpcode2 The opcode we're comparing with. Does not have
237 * to be the whole 8 chars long.
238 */
239DECLINLINE(bool) atsIsSameOpcode(PCATSPKTHDR pPktHdr, const char *pszOpcode2)
240{
241 if (pPktHdr->achOpcode[0] != pszOpcode2[0])
242 return false;
243 if (pPktHdr->achOpcode[1] != pszOpcode2[1])
244 return false;
245
246 unsigned i = 2;
247 while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
248 && pszOpcode2[i] != '\0')
249 {
250 if (pPktHdr->achOpcode[i] != pszOpcode2[i])
251 break;
252 i++;
253 }
254
255 if ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
256 && pszOpcode2[i] == '\0')
257 {
258 while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
259 && pPktHdr->achOpcode[i] == ' ')
260 i++;
261 }
262
263 return i == RT_SIZEOFMEMB(ATSPKTHDR, achOpcode);
264}
265
266RT_C_DECLS_END
267
268#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h */
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