VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp@ 56648

Last change on this file since 56648 was 56648, checked in by vboxsync, 10 years ago

Audio: Remove DEV_AUDIO logging group and split it up into per device and driver groups for finer grained logging

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 18.9 KB
Line 
1/* $Id: DrvAudioVRDE.cpp 56648 2015-06-25 21:57:41Z vboxsync $ */
2/** @file
3 * VRDE audio backend for Main.
4 */
5
6/*
7 * Copyright (C) 2013-2015 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
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#define LOG_GROUP LOG_GROUP_DRV_VRDE_AUDIO
23#include <VBox/log.h>
24#include "DrvAudioVRDE.h"
25#include "ConsoleImpl.h"
26#include "ConsoleVRDPServer.h"
27
28#include "Logging.h"
29
30#include "../../Devices/Audio/DrvAudio.h"
31#include "../../Devices/Audio/AudioMixBuffer.h"
32
33#include <iprt/mem.h>
34#include <iprt/cdefs.h>
35#include <iprt/circbuf.h>
36
37#include <VBox/vmm/pdmaudioifs.h>
38#include <VBox/vmm/pdmdrv.h>
39#include <VBox/RemoteDesktop/VRDE.h>
40#include <VBox/vmm/cfgm.h>
41#include <VBox/err.h>
42
43/*******************************************************************************
44* Structures and Typedefs *
45*******************************************************************************/
46/**
47 * Audio VRDE driver instance data.
48 */
49typedef struct DRVAUDIOVRDE
50{
51 /** Pointer to audio VRDE object. */
52 AudioVRDE *pAudioVRDE;
53 PPDMDRVINS pDrvIns;
54 /** Pointer to the driver instance structure. */
55 PDMIHOSTAUDIO IHostAudio;
56 /** Pointer to the VRDP's console object. */
57 ConsoleVRDPServer *pConsoleVRDPServer;
58 /** Pointer to the DrvAudio port interface that is above us. */
59 PPDMIAUDIOCONNECTOR pDrvAudio;
60 /** Whether this driver is enabled or not. */
61 bool fEnabled;
62} DRVAUDIOVRDE, *PDRVAUDIOVRDE;
63
64typedef struct VRDESTREAMIN
65{
66 /** Associated host input stream. */
67 PDMAUDIOHSTSTRMIN HstStrmIn;
68 /** Number of samples captured asynchronously in the
69 * onVRDEInputXXX callbacks. */
70 uint32_t cSamplesCaptured;
71 /** Critical section. */
72 RTCRITSECT CritSect;
73} VRDESTREAMIN, *PVRDESTREAMIN;
74
75typedef struct VRDESTREAMOUT
76{
77 /** Associated host output stream. */
78 PDMAUDIOHSTSTRMOUT HstStrmOut;
79 uint64_t old_ticks;
80 uint64_t cSamplesSentPerSec;
81} VRDESTREAMOUT, *PVRDESTREAMOUT;
82
83
84
85static DECLCALLBACK(int) drvAudioVRDEInit(PPDMIHOSTAUDIO pInterface)
86{
87 LogFlowFuncEnter();
88
89 return VINF_SUCCESS;
90}
91
92static DECLCALLBACK(int) drvAudioVRDEInitIn(PPDMIHOSTAUDIO pInterface,
93 PPDMAUDIOHSTSTRMIN pHstStrmIn, PPDMAUDIOSTREAMCFG pCfg,
94 PDMAUDIORECSOURCE enmRecSource,
95 uint32_t *pcSamples)
96{
97 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
98 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
99
100 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pHstStrmIn;
101 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
102
103 if (pcSamples)
104 *pcSamples = _4K; /** @todo Make this configurable. */
105
106 return drvAudioStreamCfgToProps(pCfg, &pVRDEStrmIn->HstStrmIn.Props);
107}
108
109static DECLCALLBACK(int) drvAudioVRDEInitOut(PPDMIHOSTAUDIO pInterface,
110 PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pCfg,
111 uint32_t *pcSamples)
112{
113 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
114 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
115
116 LogFlowFunc(("pHstStrmOut=%p, pCfg=%p\n", pHstStrmOut, pCfg));
117
118 PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pHstStrmOut;
119 AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
120
121 if (pcSamples)
122 *pcSamples = _4K; /** @todo Make this configurable. */
123
124 return drvAudioStreamCfgToProps(pCfg, &pVRDEStrmOut->HstStrmOut.Props);
125}
126
127static DECLCALLBACK(bool) drvAudioVRDEIsEnabled(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
128{
129 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
130 AssertPtrReturn(pDrv, false);
131
132 NOREF(enmDir);
133
134 if (!pDrv->fEnabled)
135 return false;
136
137 return true;
138}
139
140/**
141 * <Missing brief description>
142 *
143 * Transfers audio input formerly sent by a connected RDP client / VRDE backend
144 * (using the onVRDEInputXXX methods) over to the VRDE host (VM). The audio device
145 * emulation then will read and send the data to the guest.
146 *
147 * @return IPRT status code.
148 * @param pInterface
149 * @param pHstStrmIn
150 * @param pcSamplesCaptured
151 */
152static DECLCALLBACK(int) drvAudioVRDECaptureIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn,
153 uint32_t *pcSamplesCaptured)
154{
155 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
156 AssertPtrReturn(pHstStrmIn, VERR_INVALID_POINTER);
157 AssertPtrReturn(pcSamplesCaptured, VERR_INVALID_POINTER);
158
159 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
160 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
161
162 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pHstStrmIn;
163 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
164
165 /** @todo Use CritSect! */
166
167 int rc;
168
169 uint32_t cProcessed = 0;
170 if (pVRDEStrmIn->cSamplesCaptured)
171 {
172 rc = AudioMixBufMixToParent(&pVRDEStrmIn->HstStrmIn.MixBuf, pVRDEStrmIn->cSamplesCaptured,
173 &cProcessed);
174 }
175 else
176 rc = VINF_SUCCESS;
177
178 if (RT_SUCCESS(rc))
179 {
180 *pcSamplesCaptured = cProcessed;
181
182 Assert(pVRDEStrmIn->cSamplesCaptured >= cProcessed);
183 pVRDEStrmIn->cSamplesCaptured -= cProcessed;
184 }
185
186 LogFlowFunc(("cSamplesCaptured=%RU32, cProcessed=%RU32\n",
187 pVRDEStrmIn->cSamplesCaptured, cProcessed, rc));
188 return rc;
189}
190
191/**
192 * Transfers VM audio output to remote client.
193 *
194 * Transfers VM audio output over to the VRDE instance for playing remotely
195 * on the client.
196 *
197 * @return IPRT status code.
198 * @param pInterface
199 * @param pHstStrmOut
200 * @param pcSamplesPlayed
201 */
202static DECLCALLBACK(int) drvAudioVRDEPlayOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut,
203 uint32_t *pcSamplesPlayed)
204{
205 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
206 AssertPtrReturn(pHstStrmOut, VERR_INVALID_POINTER);
207 /* pcSamplesPlayed is optional. */
208
209 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
210 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
211
212 PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pHstStrmOut;
213 AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
214
215 uint32_t live = drvAudioHstOutSamplesLive(pHstStrmOut, NULL /* pcStreamsLive */);
216 uint64_t now = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);
217 uint64_t ticks = now - pVRDEStrmOut->old_ticks;
218 uint64_t ticks_per_second = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns);
219
220 /* Minimize the rounding error: samples = int((ticks * freq) / ticks_per_second + 0.5). */
221 uint32_t cSamplesPlayed = (int)((2 * ticks * pHstStrmOut->Props.uHz + ticks_per_second) / ticks_per_second / 2);
222
223 /* Don't play more than available. */
224 if (cSamplesPlayed > live)
225 cSamplesPlayed = live;
226
227 /* Remember when samples were consumed. */
228 pVRDEStrmOut->old_ticks = now;
229
230 VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(pHstStrmOut->Props.uHz,
231 pHstStrmOut->Props.cChannels,
232 pHstStrmOut->Props.cBits,
233 pHstStrmOut->Props.fSigned);
234
235 int cSamplesToSend = cSamplesPlayed;
236
237 LogFlowFunc(("uFreq=%RU32, cChan=%RU8, cBits=%RU8, fSigned=%RTbool, enmFormat=%ld, cSamplesToSend=%RU32\n",
238 pHstStrmOut->Props.uHz, pHstStrmOut->Props.cChannels,
239 pHstStrmOut->Props.cBits, pHstStrmOut->Props.fSigned,
240 format, cSamplesToSend));
241
242 /*
243 * Call the VRDP server with the data.
244 */
245 uint32_t cReadTotal = 0;
246
247 PPDMAUDIOSAMPLE pSamples;
248 uint32_t cRead;
249 int rc = AudioMixBufAcquire(&pHstStrmOut->MixBuf, cSamplesToSend,
250 &pSamples, &cRead);
251 if ( RT_SUCCESS(rc)
252 && cRead)
253 {
254 cReadTotal = cRead;
255 pDrv->pConsoleVRDPServer->SendAudioSamples(pSamples, cRead, format);
256
257 if (rc == VINF_TRY_AGAIN)
258 {
259 rc = AudioMixBufAcquire(&pHstStrmOut->MixBuf, cSamplesToSend - cRead,
260 &pSamples, &cRead);
261 if (RT_SUCCESS(rc))
262 pDrv->pConsoleVRDPServer->SendAudioSamples(pSamples, cRead, format);
263
264 cReadTotal += cRead;
265 }
266 }
267
268 AudioMixBufFinish(&pHstStrmOut->MixBuf, cSamplesToSend);
269
270 /*
271 * Always report back all samples acquired, regardless of whether the
272 * VRDP server actually did process those.
273 */
274 if (pcSamplesPlayed)
275 *pcSamplesPlayed = cReadTotal;
276
277 LogFlowFunc(("cReadTotal=%RU32, rc=%Rrc\n", cReadTotal, rc));
278 return rc;
279}
280
281static DECLCALLBACK(int) drvAudioVRDEFiniIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn)
282{
283 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
284 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
285
286 if (pDrv->pConsoleVRDPServer)
287 pDrv->pConsoleVRDPServer->SendAudioInputEnd(NULL);
288
289 return VINF_SUCCESS;
290}
291
292static DECLCALLBACK(int) drvAudioVRDEFiniOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut)
293{
294 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
295 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
296
297 return VINF_SUCCESS;
298}
299
300static DECLCALLBACK(int) drvAudioVRDEControlOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut,
301 PDMAUDIOSTREAMCMD enmStreamCmd)
302{
303 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
304 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
305
306 PVRDESTREAMIN pVRDEStrmOut = (PVRDESTREAMIN)pHstStrmOut;
307 AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
308
309 LogFlowFunc(("enmStreamCmd=%ld\n", enmStreamCmd));
310
311 AudioMixBufReset(&pHstStrmOut->MixBuf);
312
313 return VINF_SUCCESS;
314}
315
316static DECLCALLBACK(int) drvAudioVRDEControlIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn,
317 PDMAUDIOSTREAMCMD enmStreamCmd)
318{
319 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
320 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
321
322 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pHstStrmIn;
323 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
324
325 PPDMAUDIOHSTSTRMIN pThisStrmIn = &pVRDEStrmIn->HstStrmIn;
326
327 LogFlowFunc(("enmStreamCmd=%ld\n", enmStreamCmd));
328
329 if (!pDrv->pConsoleVRDPServer)
330 return VINF_SUCCESS;
331
332 AudioMixBufReset(&pThisStrmIn->MixBuf);
333
334 /* Initialize only if not already done. */
335 int rc;
336 if (enmStreamCmd == PDMAUDIOSTREAMCMD_ENABLE)
337 {
338 rc = pDrv->pConsoleVRDPServer->SendAudioInputBegin(NULL, pVRDEStrmIn, AudioMixBufSize(&pThisStrmIn->MixBuf),
339 pThisStrmIn->Props.uHz,
340 pThisStrmIn->Props.cChannels, pThisStrmIn->Props.cBits);
341 if (rc == VERR_NOT_SUPPORTED)
342 {
343 LogFlowFunc(("No RDP client connected, so no input recording supported\n"));
344 rc = VINF_SUCCESS;
345 }
346 }
347 else if (enmStreamCmd == PDMAUDIOSTREAMCMD_DISABLE)
348 {
349 pDrv->pConsoleVRDPServer->SendAudioInputEnd(NULL /* pvUserCtx */);
350 rc = VINF_SUCCESS;
351 }
352 else
353 rc = VERR_INVALID_PARAMETER;
354
355 return rc;
356}
357
358static DECLCALLBACK(int) drvAudioVRDEGetConf(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg)
359{
360 pCfg->cbStreamOut = sizeof(VRDESTREAMOUT);
361 pCfg->cbStreamIn = sizeof(VRDESTREAMIN);
362 pCfg->cMaxHstStrmsOut = 1;
363 pCfg->cMaxHstStrmsIn = 2; /* Microphone in + Line in. */
364
365 return VINF_SUCCESS;
366}
367
368static DECLCALLBACK(void) drvAudioVRDEShutdown(PPDMIHOSTAUDIO pInterface)
369{
370 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
371 AssertPtrReturnVoid(pDrv);
372
373 if (pDrv->pConsoleVRDPServer)
374 pDrv->pConsoleVRDPServer->SendAudioInputEnd(NULL);
375}
376
377/**
378 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
379 */
380static DECLCALLBACK(void *) drvAudioVRDEQueryInterface(PPDMIBASE pInterface, const char *pszIID)
381{
382 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
383 PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
384
385 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
386 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio);
387 return NULL;
388}
389
390AudioVRDE::AudioVRDE(Console *pConsole)
391 : mpDrv(NULL),
392 mParent(pConsole)
393{
394}
395
396AudioVRDE::~AudioVRDE(void)
397{
398 if (mpDrv)
399 {
400 mpDrv->pAudioVRDE = NULL;
401 mpDrv = NULL;
402 }
403}
404
405int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags)
406{
407 LogFlowThisFunc(("fEnable=%RTbool, uFlags=0x%x\n", fEnable, uFlags));
408
409 if (mpDrv == NULL)
410 return VERR_INVALID_STATE;
411
412 mpDrv->fEnabled = fEnable;
413
414 return VINF_SUCCESS; /* Never veto. */
415}
416
417/**
418 * Marks the beginning of sending captured audio data from a connected
419 * RDP client.
420 *
421 * @return IPRT status code.
422 * @param pvContext The context; in this case a pointer to a
423 * VRDESTREAMIN structure.
424 * @param pVRDEAudioBegin Pointer to a VRDEAUDIOINBEGIN structure.
425 */
426int AudioVRDE::onVRDEInputBegin(void *pvContext, PVRDEAUDIOINBEGIN pVRDEAudioBegin)
427{
428 AssertPtrReturn(pvContext, VERR_INVALID_POINTER);
429 AssertPtrReturn(pVRDEAudioBegin, VERR_INVALID_POINTER);
430
431 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pvContext;
432 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
433
434 VRDEAUDIOFORMAT audioFmt = pVRDEAudioBegin->fmt;
435
436 int iSampleHz = VRDE_AUDIO_FMT_SAMPLE_FREQ(audioFmt);
437 int cChannels = VRDE_AUDIO_FMT_CHANNELS(audioFmt);
438 int cBits = VRDE_AUDIO_FMT_BITS_PER_SAMPLE(audioFmt);
439 bool fUnsigned = VRDE_AUDIO_FMT_SIGNED(audioFmt);
440
441 LogFlowFunc(("cbSample=%RU32, iSampleHz=%d, cChannels=%d, cBits=%d, fUnsigned=%RTbool\n",
442 VRDE_AUDIO_FMT_BYTES_PER_SAMPLE(audioFmt), iSampleHz, cChannels, cBits, fUnsigned));
443
444 return VINF_SUCCESS;
445}
446
447int AudioVRDE::onVRDEInputData(void *pvContext, const void *pvData, uint32_t cbData)
448{
449 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pvContext;
450 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER);
451
452 PPDMAUDIOHSTSTRMIN pHstStrmIn = &pVRDEStrmIn->HstStrmIn;
453 AssertPtrReturn(pHstStrmIn, VERR_INVALID_POINTER);
454
455 /** @todo Use CritSect! */
456
457 uint32_t cWritten;
458 int rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf, pvData, cbData, &cWritten);
459 if (RT_SUCCESS(rc))
460 pVRDEStrmIn->cSamplesCaptured += cWritten;
461
462 LogFlowFunc(("cbData=%RU32, cWritten=%RU32, cSamplesCaptured=%RU32, rc=%Rrc\n",
463 cbData, cWritten, pVRDEStrmIn->cSamplesCaptured, rc));
464 return rc;
465}
466
467int AudioVRDE::onVRDEInputEnd(void *pvContext)
468{
469 NOREF(pvContext);
470
471 return VINF_SUCCESS;
472}
473
474int AudioVRDE::onVRDEInputIntercept(bool fEnabled)
475{
476 return VINF_SUCCESS; /* Never veto. */
477}
478
479/**
480 * Construct a VRDE audio driver instance.
481 *
482 * @copydoc FNPDMDRVCONSTRUCT
483 */
484/* static */
485DECLCALLBACK(int) AudioVRDE::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
486{
487 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
488 PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
489 AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
490 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
491
492 LogRel(("Audio: Initializing VRDE driver\n"));
493 LogFlowFunc(("fFlags=0x%x\n", fFlags));
494
495 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
496 ("Configuration error: Not possible to attach anything to this driver!\n"),
497 VERR_PDM_DRVINS_NO_ATTACH);
498
499 /*
500 * Init the static parts.
501 */
502 pThis->pDrvIns = pDrvIns;
503 /* IBase */
504 pDrvIns->IBase.pfnQueryInterface = drvAudioVRDEQueryInterface;
505 /* IHostAudio */
506 PDMAUDIO_IHOSTAUDIO_CALLBACKS(drvAudioVRDE);
507
508 /* Init defaults. */
509 pThis->fEnabled = false;
510
511 /*
512 * Get the ConsoleVRDPServer object pointer.
513 */
514 void *pvUser;
515 int rc = CFGMR3QueryPtr(pCfg, "ObjectVRDPServer", &pvUser);
516 AssertMsgRCReturn(rc, ("Confguration error: No/bad \"ObjectVRDPServer\" value, rc=%Rrc\n", rc), rc);
517
518 /* CFGM tree saves the pointer to ConsoleVRDPServer in the Object node of AudioVRDE. */
519 pThis->pConsoleVRDPServer = (ConsoleVRDPServer *)pvUser;
520
521 /*
522 * Get the AudioVRDE object pointer.
523 */
524 pvUser = NULL;
525 rc = CFGMR3QueryPtr(pCfg, "Object", &pvUser);
526 AssertMsgRCReturn(rc, ("Confguration error: No/bad \"Object\" value, rc=%Rrc\n", rc), rc);
527
528 pThis->pAudioVRDE = (AudioVRDE *)pvUser;
529 pThis->pAudioVRDE->mpDrv = pThis;
530
531 /*
532 * Get the interface for the above driver (DrvAudio) to make mixer/conversion calls.
533 * Described in CFGM tree.
534 */
535 pThis->pDrvAudio = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIAUDIOCONNECTOR);
536 AssertMsgReturn(pThis->pDrvAudio, ("Configuration error: No upper interface specified!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
537
538 return VINF_SUCCESS;
539}
540
541
542/**
543 * @interface_method_impl{PDMDRVREG,pfnDestruct}
544 */
545/* static */
546DECLCALLBACK(void) AudioVRDE::drvDestruct(PPDMDRVINS pDrvIns)
547{
548 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
549 PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
550 LogFlowFuncEnter();
551
552 /*
553 * If the AudioVRDE object is still alive, we must clear it's reference to
554 * us since we'll be invalid when we return from this method.
555 */
556 if (pThis->pAudioVRDE)
557 {
558 pThis->pAudioVRDE->mpDrv = NULL;
559 pThis->pAudioVRDE = NULL;
560 }
561}
562
563
564/**
565 * VRDE audio driver registration record.
566 */
567const PDMDRVREG AudioVRDE::DrvReg =
568{
569 PDM_DRVREG_VERSION,
570 /* szName */
571 "AudioVRDE",
572 /* szRCMod */
573 "",
574 /* szR0Mod */
575 "",
576 /* pszDescription */
577 "Audio driver for VRDE backend",
578 /* fFlags */
579 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
580 /* fClass. */
581 PDM_DRVREG_CLASS_AUDIO,
582 /* cMaxInstances */
583 ~0U,
584 /* cbInstance */
585 sizeof(DRVAUDIOVRDE),
586 /* pfnConstruct */
587 AudioVRDE::drvConstruct,
588 /* pfnDestruct */
589 AudioVRDE::drvDestruct,
590 /* pfnRelocate */
591 NULL,
592 /* pfnIOCtl */
593 NULL,
594 /* pfnPowerOn */
595 NULL,
596 /* pfnReset */
597 NULL,
598 /* pfnSuspend */
599 NULL,
600 /* pfnResume */
601 NULL,
602 /* pfnAttach */
603 NULL,
604 /* pfnDetach */
605 NULL,
606 /* pfnPowerOff */
607 NULL,
608 /* pfnSoftReset */
609 NULL,
610 /* u32EndVersion */
611 PDM_DRVREG_VERSION
612};
613
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