VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTestServiceInternal.h@ 92378

Last change on this file since 92378 was 91999, checked in by vboxsync, 3 years ago

Audio/Validation Kit: Fixed memory leaks found by ASAN, added + renamed some functions to streamline client destruction. bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.5 KB
Line 
1/* $Id: AudioTestServiceInternal.h 91999 2021-10-22 11:43:28Z vboxsync $ */
2/** @file
3 * AudioTestService - Audio test execution server, Internal Header.
4 */
5
6/*
7 * Copyright (C) 2021 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#ifndef VBOX_INCLUDED_SRC_Audio_AudioTestServiceInternal_h
19#define VBOX_INCLUDED_SRC_Audio_AudioTestServiceInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/getopt.h>
25#include <iprt/stream.h>
26
27#include "AudioTestServiceProtocol.h"
28
29RT_C_DECLS_BEGIN
30
31/** Opaque ATS transport layer specific client data. */
32typedef struct ATSTRANSPORTCLIENT *PATSTRANSPORTCLIENT;
33typedef PATSTRANSPORTCLIENT *PPATSTRANSPORTCLIENT;
34
35/** Opaque ATS transport specific instance data. */
36typedef struct ATSTRANSPORTINST *PATSTRANSPORTINST;
37typedef PATSTRANSPORTINST *PPATSTRANSPORTINST;
38
39/**
40 * Transport layer descriptor.
41 */
42typedef struct ATSTRANSPORT
43{
44 /** The name. */
45 char szName[16];
46 /** The description. */
47 const char *pszDesc;
48 /** Pointer to an array of options. */
49 PCRTGETOPTDEF paOpts;
50 /** The number of options in the array. */
51 size_t cOpts;
52
53 /**
54 * Print the usage information for this transport layer.
55 *
56 * @param pStream The stream to print the usage info to.
57 *
58 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
59 */
60 DECLR3CALLBACKMEMBER(void, pfnUsage,(PRTSTREAM pStream));
61
62 /**
63 * Creates a transport instance.
64 *
65 * @returns IPRT status code. On errors, the transport layer shall call
66 * RTMsgError to display the error details to the user.
67 * @param ppThis Where to return the created transport instance on success.
68 */
69 DECLR3CALLBACKMEMBER(int, pfnCreate, (PPATSTRANSPORTINST ppThis));
70
71 /**
72 * Destroys a transport instance.
73 *
74 * On errors, the transport layer shall call RTMsgError to display the error
75 * details to the user.
76 *
77 * @returns IPRT status code. On errors, the transport layer shall call
78 * RTMsgError to display the error details to the user.
79 * @param pThis The transport instance.
80 * The pointer will be invalid on return.
81 */
82 DECLR3CALLBACKMEMBER(int, pfnDestroy, (PATSTRANSPORTINST pThis));
83
84 /**
85 * Handle an option.
86 *
87 * When encountering an options that is not part of the base options, we'll call
88 * this method for each transport layer until one handles it.
89 *
90 * @retval VINF_SUCCESS if handled.
91 * @retval VERR_TRY_AGAIN if not handled.
92 * @retval VERR_INVALID_PARAMETER if we should exit with a non-zero status.
93 *
94 * @param pThis Transport instance to set options for.
95 * @param ch The short option value.
96 * @param pVal Pointer to the value union.
97 *
98 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
99 */
100 DECLR3CALLBACKMEMBER(int, pfnOption,(PATSTRANSPORTINST pThis, int ch, PCRTGETOPTUNION pVal));
101
102 /**
103 * Starts a transport instance.
104 *
105 * @returns IPRT status code. On errors, the transport layer shall call
106 * RTMsgError to display the error details to the user.
107 * @param pThis Transport instance to initialize.
108 */
109 DECLR3CALLBACKMEMBER(int, pfnStart, (PATSTRANSPORTINST pThis));
110
111 /**
112 * Stops a transport instance, closing and freeing resources.
113 *
114 * On errors, the transport layer shall call RTMsgError to display the error
115 * details to the user.
116 *
117 * @param pThis The transport instance.
118 */
119 DECLR3CALLBACKMEMBER(void, pfnStop, (PATSTRANSPORTINST pThis));
120
121 /**
122 * Waits for a new client to connect and returns the client specific data on
123 * success.
124 *
125 * @returns VBox status code.
126 * @param pThis The transport instance.
127 * @param msTimeout Timeout (in ms) waiting for a connection to be established.
128 * Use RT_INDEFINITE_WAIT to wait indefinitely.
129 * This might or might not be supported by the specific transport implementation.
130 * @param pfFromServer Returns \c true if the returned client is from a remote server (called a reverse connection),
131 * or \c false if not (regular client). Optional and can be NULL.
132 * @param ppClientNew Where to return the allocated client on success.
133 * Must be destroyed with pfnDisconnect() when done.
134 */
135 DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, RTMSINTERVAL msTimeout, bool *pfFromServer, PPATSTRANSPORTCLIENT ppClientNew));
136
137 /**
138 * Disconnects a client and frees up its resources.
139 *
140 * @param pThis The transport instance.
141 * @param pClient Client to disconnect.
142 * The pointer will be invalid after calling.
143 */
144 DECLR3CALLBACKMEMBER(void, pfnDisconnect, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
145
146 /**
147 * Polls for incoming packets.
148 *
149 * @returns true if there are pending packets, false if there isn't.
150 * @param pThis The transport instance.
151 * @param pClient The client to poll for data.
152 */
153 DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
154
155 /**
156 * Adds any pollable handles to the poll set.
157 *
158 * @returns IPRT status code.
159 * @param pThis The transport instance.
160 * @param hPollSet The poll set to add them to.
161 * @param pClient The transport client structure.
162 * @param idStart The handle ID to start at.
163 */
164 DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));
165
166 /**
167 * Removes the given client frmo the given pollset.
168 *
169 * @returns IPRT status code.
170 * @param pThis The transport instance.
171 * @param hPollSet The poll set to remove from.
172 * @param pClient The transport client structure.
173 * @param idStart The handle ID to remove.
174 */
175 DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));
176
177 /**
178 * Receives an incoming packet.
179 *
180 * This will block until the data becomes available or we're interrupted by a
181 * signal or something.
182 *
183 * @returns IPRT status code. On error conditions other than VERR_INTERRUPTED,
184 * the current operation will be aborted when applicable. When
185 * interrupted, the transport layer will store the data until the next
186 * receive call.
187 *
188 * @param pThis The transport instance.
189 * @param pClient The transport client structure.
190 * @param ppPktHdr Where to return the pointer to the packet we've
191 * read. This is allocated from the heap using
192 * RTMemAlloc (w/ ATSPKT_ALIGNMENT) and must be
193 * free by calling RTMemFree.
194 */
195 DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PPATSPKTHDR ppPktHdr));
196
197 /**
198 * Sends an outgoing packet.
199 *
200 * This will block until the data has been written.
201 *
202 * @returns IPRT status code.
203 * @retval VERR_INTERRUPTED if interrupted before anything was sent.
204 *
205 * @param pThis The transport instance.
206 * @param pClient The transport client structure.
207 * @param pPktHdr The packet to send. The size is given by
208 * aligning the size in the header by
209 * ATSPKT_ALIGNMENT.
210 */
211 DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr));
212
213 /**
214 * Sends a babble packet and disconnects the client (if applicable).
215 *
216 * @param pThis The transport instance.
217 * @param pClient The transport client structure.
218 * @param pPktHdr The packet to send. The size is given by
219 * aligning the size in the header by
220 * ATSPKT_ALIGNMENT.
221 * @param cMsSendTimeout The send timeout measured in milliseconds.
222 */
223 DECLR3CALLBACKMEMBER(void, pfnBabble, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));
224
225 /**
226 * Notification about a client HOWDY.
227 *
228 * @param pThis The transport instance.
229 * @param pClient The transport client structure.
230 */
231 DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
232
233 /**
234 * Notification about a client BYE.
235 *
236 * For connection oriented transport layers, it would be good to disconnect the
237 * client at this point.
238 *
239 * @param pThis The transport instance.
240 * @param pClient The transport client structure.
241 */
242 DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
243
244 /**
245 * Notification about a REBOOT or SHUTDOWN.
246 *
247 * For connection oriented transport layers, stop listening for and
248 * accepting at this point.
249 *
250 * @param pThis The transport instance.
251 */
252 DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, (PATSTRANSPORTINST pThis));
253
254 /** Non-zero end marker. */
255 uint32_t u32EndMarker;
256} ATSTRANSPORT;
257/** Pointer to a const transport layer descriptor. */
258typedef const struct ATSTRANSPORT *PCATSTRANSPORT;
259
260
261extern ATSTRANSPORT const g_TcpTransport;
262
263RT_C_DECLS_END
264
265#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceInternal_h */
266
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