VirtualBox

Changeset 54230 in vbox


Ignore:
Timestamp:
Feb 17, 2015 1:13:02 PM (10 years ago)
Author:
vboxsync
Message:

PDM/Audio: Update.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/RemoteDesktop/VRDE.h

    r53442 r54230  
    633633
    634634/** Hints what has been intercepted by the application. */
    635 #define VRDE_CLIENT_INTERCEPT_AUDIO     (0x1)
    636 #define VRDE_CLIENT_INTERCEPT_USB       (0x2)
    637 #define VRDE_CLIENT_INTERCEPT_CLIPBOARD (0x4)
    638 #define VRDE_CLIENT_INTERCEPT_AUDIO_INPUT (0x8)
     635#define VRDE_CLIENT_INTERCEPT_AUDIO       RT_BIT(0)
     636#define VRDE_CLIENT_INTERCEPT_USB         RT_BIT(1)
     637#define VRDE_CLIENT_INTERCEPT_CLIPBOARD   RT_BIT(2)
     638#define VRDE_CLIENT_INTERCEPT_AUDIO_INPUT RT_BIT(3)
    639639
    640640
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r53831 r54230  
    44
    55/*
    6  * Copyright (C) 2006-2014 Oracle Corporation
     6 * Copyright (C) 2006-2015 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6464
    6565/**
    66  * Function pointer for device emulation callback.
    67  */
    68 typedef void (*PDMAUDIOCALLBACK_FN) (void *pvContext, uint32_t cbData);
    69 
    70 /**
    71  * Structure holding all necessary callback data to communicate
    72  * with the sound device emulation, e.g. for reading or writing
    73  * audio data.
    74  */
    75 typedef struct PDMAUDIOCALLBACK
    76 {
    77     /** Callback function to use in the device emulation. */
    78     PDMAUDIOCALLBACK_FN fn;
    79     /** Opaque pointer to context data given on callback
    80      *  creation. Set by the device emulation. */
    81     void *pvContext;
    82 } PDMAUDIOCALLBACK, *PPDMAUDIOCALLBACK;
    83 
    84 /**
    8566 * Audio configuration of a certain backend.
    8667 */
     
    142123#endif
    143124
    144 typedef enum
     125typedef enum PDMAUDIODIR
     126{
     127    PDMAUDIODIR_UNKNOWN = 0,
     128    PDMAUDIODIR_IN      = 1,
     129    PDMAUDIODIR_OUT     = 2,
     130    PDMAUDIODIR_BOTH    = 3
     131} PDMAUDIODIR;
     132
     133typedef enum PDMAUDIOMIXERCTL
    145134{
    146135    PDMAUDIOMIXERCTL_UNKNOWN = 0,
     
    152141} PDMAUDIOMIXERCTL;
    153142
    154 typedef enum
     143typedef enum PDMAUDIORECSOURCE
    155144{
    156145    PDMAUDIORECSOURCE_UNKNOWN = 0,
     
    372361    /** Pointer to associated host input stream. */
    373362    PPDMAUDIOHSTSTRMIN     pHstStrmIn;
    374     /**
    375      * Callback set by the device emulation on creation.
    376      * This function is used to mix the guest input samples into the target
    377      * host input recording buffer. */
    378     PDMAUDIOCALLBACK       Callback;
    379363} PDMAUDIOGSTSTRMIN, *PPDMAUDIOGSTSTRMIN;
    380364
     
    397381    /** Pointer to the associated host output stream. */
    398382    PPDMAUDIOHSTSTRMOUT    pHstStrmOut;
    399     /**
    400      * Callback set by the device emulation on creation.
    401      * This function is used to tell the device emulation that we're ready to
    402      * process new samples.
    403      */
    404     PDMAUDIOCALLBACK       Callback;
    405383} PDMAUDIOGSTSTRMOUT, *PPDMAUDIOGSTSTRMOUT;
    406384
     
    414392typedef struct PDMIAUDIOCONNECTOR
    415393{
    416     DECLR3CALLBACKMEMBER(int, pfnQueryData, (PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcbAvailIn, uint32_t *pcbFreeOut, uint32_t *pcSamplesLive));
     394    DECLR3CALLBACKMEMBER(int, pfnQueryStatus, (PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcbAvailIn, uint32_t *pcbFreeOut, uint32_t *pcSamplesLive));
    417395
    418396    /**
     
    476454     * @param   uVolRight       Right audio stream volume.
    477455     */
    478     DECLR3CALLBACKMEMBER(int, pfnIsSetOutVolume, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut,
    479                                                   bool fMute, uint8_t uVolLeft, uint8_t uVolRight));
     456    DECLR3CALLBACKMEMBER(int, pfnSetVolumeOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut,
     457                                                bool fMute, uint8_t uVolLeft, uint8_t uVolRight));
    480458
    481459    /**
     
    534512     * @param   pszName              Name of the audio channel.
    535513     * @param   enmRecSource         Specifies the type of recording source to be opened.
    536      * @param   fnCallback           Callback function to be assigned to this input stream.
    537      * @param   pvCallback           Pointer to parameters assigned to the callback function.
    538514     * @param   pCfg                 Pointer to PDMAUDIOSTREAMCFG to use.
    539515     * @param   ppGstStrmIn          Pointer where to return the guest guest input stream on success.
    540516     */
    541517    DECLR3CALLBACKMEMBER(int, pfnOpenIn, (PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    542                                           PDMAUDIORECSOURCE enmRecSource,
    543                                           PDMAUDIOCALLBACK_FN fnCallback, void *pvCallback,
    544                                           PPDMAUDIOSTREAMCFG pCfg,
     518                                          PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg,
    545519                                          PPDMAUDIOGSTSTRMIN *ppGstStrmIn));
    546520
     
    551525     * @param   pInterface           Pointer to the interface structure containing the called function pointer.
    552526     * @param   pszName              Name of the audio channel.
    553      * @param   fnCallback           Callback function to be assigned to this input stream.
    554      * @param   pvCallback           Pointer to parameters assigned to the callback function.
    555527     * @param   pCfg                 Pointer to PDMAUDIOSTREAMCFG to use.
    556528     * @param   ppGstStrmOut         Pointer where to return the guest guest input stream on success.
    557529     */
    558530    DECLR3CALLBACKMEMBER(int, pfnOpenOut, (PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    559                                            PDMAUDIOCALLBACK_FN fnCallback, void *pvCallback,
    560                                            PPDMAUDIOSTREAMCFG pCfg,
    561                                            PPDMAUDIOGSTSTRMOUT *ppGstStrmOut));
    562 
    563     DECLR3CALLBACKMEMBER(int, pfnPlayOut, (PPDMIAUDIOCONNECTOR pInterface));
     531                                           PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut));
     532
     533    DECLR3CALLBACKMEMBER(int, pfnPlayOut, (PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcSamplesPlayed));
    564534
    565535    /**
     
    585555/** PDMIAUDIOCONNECTOR interface ID. */
    586556#define PDMIAUDIOCONNECTOR_IID                  "a41ca770-ed07-4f57-a0a6-41377d9d484f"
     557
     558/** Defines all needed interface callbacks for an audio backend. */
     559#define PDMAUDIO_IHOSTAUDIOR3_CALLBACKS(_aDrvName) \
     560    pThis->IHostAudioR3.pfnCaptureIn  = _aDrvName##CaptureIn;  \
     561    pThis->IHostAudioR3.pfnControlIn  = _aDrvName##ControlIn;  \
     562    pThis->IHostAudioR3.pfnControlOut = _aDrvName##ControlOut; \
     563    pThis->IHostAudioR3.pfnFiniIn     = _aDrvName##FiniIn;     \
     564    pThis->IHostAudioR3.pfnFiniOut    = _aDrvName##FiniOut;    \
     565    pThis->IHostAudioR3.pfnGetConf    = _aDrvName##GetConf;    \
     566    pThis->IHostAudioR3.pfnInit       = _aDrvName##Init;       \
     567    pThis->IHostAudioR3.pfnInitIn     = _aDrvName##InitIn;     \
     568    pThis->IHostAudioR3.pfnInitOut    = _aDrvName##InitOut;    \
     569    pThis->IHostAudioR3.pfnIsEnabled  = _aDrvName##IsEnabled;  \
     570    pThis->IHostAudioR3.pfnPlayOut    = _aDrvName##PlayOut;
    587571
    588572/** Pointer to a host audio interface. */
     
    661645    DECLR3CALLBACKMEMBER(int, pfnFiniOut, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut));
    662646
    663     /**
    664      * Plays an audio stream.
     647    DECLR3CALLBACKMEMBER(bool, pfnIsEnabled, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
     648
     649    /**
     650     * Plays a host audio stream.
    665651     *
    666652     * @returns VBox status code.
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r54140 r54230  
     1/* $Id$ */
     2/** @file
     3 * VBox audio: TODO
     4 */
     5
     6/*
     7 * Copyright (C) 2014-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 */
    117
    218#include <iprt/asm-math.h>
     
    2238# include <VBox/log.h>
    2339#else
    24  #define AUDMIXBUF_LOG(x)
     40# define AUDMIXBUF_LOG(x)
    2541#endif
    2642
     
    11481164    uint32_t cWritten;
    11491165
    1150 #ifdef DEBUG
     1166#if 0
    11511167    RTFILE fh;
    11521168    rc = RTFileOpen(&fh, "c:\\temp\\test_writeat.pcm",
     
    12661282    }
    12671283
    1268 #ifdef DEBUG_andy
     1284#if 0
    12691285        RTFILE fh;
    12701286        RTFileOpen(&fh, "c:\\temp\\test_writeex.pcm",
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.h

    r53830 r54230  
    55
    66/*
    7  * Copyright (C) 2014 Oracle Corporation
     7 * Copyright (C) 2014-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323
    2424/** Constructs 32 bit value for given frequency, number of channels, bits per sample and signed bit.
    25  *  Note: This currently matches 1:1 the VRDE encoding. */
     25 *  Note: This currently matches 1:1 the VRDE encoding -- this might change in the future, so better don't rely on this fact! */
    2626#define AUDMIXBUF_AUDIO_FMT_MAKE(freq, c, bps, s) ((((s) & 0x1) << 28) + (((bps) & 0xFF) << 20) + (((c) & 0xF) << 16) + ((freq) & 0xFFFF))
    2727
  • trunk/src/VBox/Devices/Audio/AudioMixer.h

    r53442 r54230  
    77
    88/*
    9  * Copyright (C) 2014 Oracle Corporation
     9 * Copyright (C) 2014-2015 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r53831 r54230  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    576576
    577577                    rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector,
    578                                                      pszDesc, PDMAUDIORECSOURCE_LINE_IN,
    579                                                      NULL, pDrv /* pvContext */,
    580                                                      &streamCfg,
    581                                                      &pDrv->LineIn.pStrmIn);
     578                                                     pszDesc, PDMAUDIORECSOURCE_LINE_IN, &streamCfg, &pDrv->LineIn.pStrmIn);
    582579                    LogFlowFunc(("LUN#%RU8: Opened line input with rc=%Rrc\n", uLUN, rc));
    583580                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
     
    606603                    }
    607604
    608                     rc = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszDesc,
    609                                                       NULL, pDrv /* pvContext */,
    610                                                       &streamCfg,
    611                                                       &pDrv->Out.pStrmOut);
     605                    rc = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszDesc, &streamCfg, &pDrv->Out.pStrmOut);
    612606                    LogFlowFunc(("LUN#%RU8: Opened output with rc=%Rrc\n", uLUN, rc));
    613607
     
    629623
    630624                    rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector,
    631                                                      pszDesc, PDMAUDIORECSOURCE_MIC,
    632                                                      NULL, pDrv /* pvContext */,
    633                                                      &streamCfg,
    634                                                      &pDrv->MicIn.pStrmIn);
     625                                                     pszDesc, PDMAUDIORECSOURCE_MIC, &streamCfg, &pDrv->MicIn.pStrmIn);
    635626                    LogFlowFunc(("LUN#%RU8: Opened mic input with rc=%Rrc\n", uLUN, rc));
    636627                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
     
    820811        pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, fEnable);
    821812#else
    822      AUD_set_active_in(pThis->voice_mc, active[MC_INDEX]);
     813    AUD_set_active_in(pThis->voice_mc, active[MC_INDEX]);
    823814#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    824815}
     
    845836    if (index == AC97_Master_Volume_Mute)
    846837    {
    847 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     838#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    848839        RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    849             pDrv->pConnector->pfnIsSetOutVolume(pDrv->pConnector, pDrv->Out.pStrmOut, RT_BOOL(mute), lvol, rvol);
    850 # else
     840            pDrv->pConnector->pfnSetVolumeOut(pDrv->pConnector, pDrv->Out.pStrmOut, RT_BOOL(mute), lvol, rvol);
     841#else
    851842        AUD_set_volume_out(pThis->voice_po, mute, lvol, rvol);
    852 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
     843#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    853844    }
    854845    else
    855846    {
    856 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     847#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    857848        RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    858         {
    859             /** @todo In SetVolume no passing audmixerctl_in as its not used in DrvAudio.cpp. */
    860849            pDrv->pConnector->pfnSetVolume(pDrv->pConnector, RT_BOOL(mute), lvol, rvol);
    861         }
    862 # else
     850#else
    863851        AUD_set_volume(mt, &mute, &lvol, &rvol);
    864 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
     852#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    865853    }
    866854#else /* !SOFT_VOLUME */
    867 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
     855#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    868856    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    869857        pDrv->pConnector->pfnSetVolume(pDrv->pConnector, RT_BOOL(mute), lvol, rvol);
    870 # else
     858#else
    871859    AUD_set_volume(mt, &mute, &lvol, &rvol);
    872 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
     860#endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
    873861#endif /* SOFT_VOLUME */
    874862
     
    10421030}
    10431031
     1032/**
     1033 * Writes data from the device to the host backends.
     1034 *
     1035 * @return  IPRT status code.
     1036 * @return  int
     1037 * @param   pThis
     1038 * @param   pReg
     1039 * @param   cbMax
     1040 * @param   pcbWritten
     1041 */
    10441042static int ichac97WriteAudio(PAC97STATE pThis, PAC97BMREG pReg, uint32_t cbMax, uint32_t *pcbWritten)
    10451043{
     1044    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     1045    AssertPtrReturn(pReg, VERR_INVALID_POINTER);
     1046    AssertReturn(cbMax, VERR_INVALID_PARAMETER);
     1047    AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER);
     1048
    10461049    PPDMDEVINS  pDevIns = ICHAC97STATE_2_DEVINS(pThis);
    10471050
    10481051    uint32_t    addr           = pReg->bd.addr;
    10491052    uint32_t    cbWrittenTotal = 0;
    1050     uint32_t    cbToRead;
     1053    uint32_t    cbToRead       = 0;
    10511054
    10521055    uint32_t cbToWrite = RT_MIN((uint32_t)(pReg->picb << 1), cbMax);
    10531056    if (!cbToWrite)
    1054         return VERR_NO_DATA;
     1057    {
     1058        *pcbWritten = 0;
     1059        return VINF_EOF;
     1060    }
    10551061
    10561062    int rc = VINF_SUCCESS;
    10571063
    1058     LogFlowFunc(("pReg=%p, cbMax=%RU32\n", pReg, cbMax));
     1064    LogFlowFunc(("pReg=%p, cbMax=%RU32, cbToWrite=%RU32\n", pReg, cbMax, cbToWrite));
    10591065
    10601066    while (cbToWrite)
     
    10891095        if (!cbWrittenMin)
    10901096        {
    1091             rc = VERR_NO_DATA;
     1097            rc = VINF_EOF;
    10921098            break;
    10931099        }
     
    11141120                pThis->last_samp = *(uint32_t *)&pThis->pvReadWriteBuf[cbToRead - 4];
    11151121        }
    1116     }
    1117 
    1118     if (RT_SUCCESS(rc))
    1119     {
    1120         if (pcbWritten)
    1121             *pcbWritten = cbWrittenTotal;
     1122
     1123        *pcbWritten = cbWrittenTotal;
    11221124    }
    11231125
     
    11771179}
    11781180
    1179 static int ichac97ReadAudio(PAC97STATE pThis, PAC97BMREG pReg, uint32_t cbMax, uint32_t *pcbWritten)
    1180 {
     1181static int ichac97ReadAudio(PAC97STATE pThis, PAC97BMREG pReg, uint32_t cbMax, uint32_t *pcbRead)
     1182{
     1183    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     1184    AssertPtrReturn(pReg, VERR_INVALID_POINTER);
    11811185    AssertReturn(cbMax, VERR_INVALID_PARAMETER);
     1186    AssertPtrReturn(pcbRead, VERR_INVALID_POINTER);
    11821187
    11831188    PPDMDEVINS pDevIns = ICHAC97STATE_2_DEVINS(pThis);
    11841189
    1185     int rc = VINF_SUCCESS;
     1190    int rc;
    11861191
    11871192#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    11881193    /* Select audio sink to process. */
    1189     PAUDMIXSINK pSink = (pReg - pThis->bm_regs) == MC_INDEX
    1190                       ? pThis->pSinkMicIn : pThis->pSinkLineIn;
     1194    PAUDMIXSINK pSink = (pReg - pThis->bm_regs) == MC_INDEX ? pThis->pSinkMicIn : pThis->pSinkLineIn;
    11911195    AssertPtr(pSink);
    11921196
     
    11971201
    11981202    if (!cbToRead)
    1199         return VERR_NO_DATA;
     1203    {
     1204        *pcbRead = 0;
     1205        return VINF_EOF;
     1206    }
    12001207
    12011208    uint8_t *pvMixBuf = (uint8_t *)RTMemAlloc(cbMixBuf);
     
    12181225    {
    12191226        Assert(cbRead);
    1220         if (pcbWritten)
    1221             *pcbWritten = cbRead;
     1227        *pcbRead = cbRead;
    12221228    }
    12231229
    12241230    return rc;
    12251231#else
     1232    rc = VINF_SUCCESS;
     1233
    12261234    uint32_t    addr = pReg->bd.addr;
    12271235    uint32_t    temp = pReg->picb << 1;
     
    12331241    temp = audio_MIN(temp, (uint32_t)cbMax);
    12341242    if (!temp)
    1235         return VERR_NO_DATA;
     1243    {
     1244        *pcbRead = 0;
     1245        return VINF_EOF;
     1246    }
    12361247
    12371248    uint8_t tmpbuf[4096];
     
    12551266
    12561267    if (RT_SUCCESS(rc))
    1257     {
    1258         if (pcbWritten)
    1259             *pcbWritten = nread;
    1260     }
     1268        *pcbRead = nread;
    12611269
    12621270    return rc;
     
    12681276{
    12691277    PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
    1270     AssertPtr(pThis);
     1278    AssertPtrReturnVoid(pThis);
    12711279
    12721280    STAM_PROFILE_START(&pThis->StatTimer, a);
     
    12781286
    12791287    PAC97DRIVER pDrv;
    1280     uint32_t cbIn, cbOut;
     1288
     1289    LogFlowFuncEnter();
    12811290
    12821291    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    12831292    {
    1284         if (!pDrv->pConnector->pfnIsOutputOK(pDrv->pConnector, pDrv->Out.pStrmOut))
    1285             continue;
    1286 
    1287         rc = pDrv->pConnector->pfnQueryData(pDrv->pConnector, /** @todo Rename QueryStatus */
    1288                                             &cbIn, &cbOut, &pDrv->cSamplesLive);
     1293        uint32_t cbIn, cbOut;
     1294        rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
     1295                                              &cbIn, &cbOut, &pDrv->cSamplesLive);
    12891296        if (RT_SUCCESS(rc))
    12901297        {
    1291             if (cbIn || cbOut)
    1292                 LogFlowFunc(("\tLUN#%RU8: cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, cbIn, cbOut));
     1298            LogFlowFunc(("\tLUN#%RU8: [1] cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, cbIn, cbOut));
     1299
     1300            if (pDrv->cSamplesLive)
     1301            {
     1302                uint32_t cSamplesPlayed;
     1303                int rc2 = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, &cSamplesPlayed);
     1304                if (RT_SUCCESS(rc2))
     1305                {
     1306                    LogFlowFunc(("LUN#%RU8: cSamplesLive=%RU32, cSamplesPlayed=%RU32\n",
     1307                                 pDrv->uLUN, pDrv->cSamplesLive, cSamplesPlayed));
     1308                    Assert(pDrv->cSamplesLive >= cSamplesPlayed);
     1309                    pDrv->cSamplesLive -= cSamplesPlayed;
     1310                }
     1311
     1312                rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
     1313                                                      &cbIn, &cbOut, &pDrv->cSamplesLive);
     1314                if (RT_SUCCESS(rc))
     1315                    LogFlowFunc(("\tLUN#%RU8: [2] cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, cbIn, cbOut));
     1316            }
    12931317
    12941318            cbInMax  = RT_MAX(cbInMax, cbIn);
     
    12981322            pDrv->cSamplesLive = 0;
    12991323    }
     1324
     1325    LogFlowFunc(("cbInMax=%RU32, cbOutMin=%RU32\n", cbInMax, cbOutMin));
     1326
     1327    if (cbOutMin == UINT32_MAX)
     1328        cbOutMin = 0;
    13001329
    13011330    /*
     
    13061335        Assert(cbOutMin != UINT32_MAX);
    13071336        ichac97TransferAudio(pThis, PO_INDEX, cbOutMin); /** @todo Add rc! */
    1308     }
    1309     else
    1310     {
    1311         RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    1312         {
    1313             if (pDrv->cSamplesLive)
    1314                 pDrv->pConnector->pfnPlayOut(pDrv->pConnector);
    1315         }
    13161337    }
    13171338
     
    13241345    TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTicks);
    13251346
     1347    LogFlowFuncLeave();
     1348
    13261349    STAM_PROFILE_STOP(&pThis->StatTimer, a);
    13271350}
     
    13641387        if (!pReg->picb) /* Got a new buffer descriptor, that is, the position is 0? */
    13651388        {
    1366             LogFlowFunc(("Fresh buffer descriptor %d is empty, addr=%#x, len=%#x, skipping\n",
     1389            LogFlowFunc(("Fresh buffer descriptor %RU8 is empty, addr=%#x, len=%#x, skipping\n",
    13671390                         pReg->civ, pReg->bd.addr, pReg->bd.ctl_len));
    13681391            if (pReg->civ == pReg->lvi)
     
    13711394                pThis->bup_flag = 0;
    13721395
    1373                 rc = VINF_SUCCESS;
     1396                rc = VINF_EOF;
    13741397                break;
    13751398            }
     
    13831406        }
    13841407
    1385         uint32_t cbWritten;
     1408        uint32_t cbTransferred;
    13861409        switch (index)
    13871410        {
    13881411            case PO_INDEX:
    1389             {
    1390                 rc = ichac97WriteAudio(pThis, pReg, cbElapsed, &cbWritten);
    1391                 if (RT_SUCCESS(rc))
    13921412                {
    1393                     cbWrittenTotal += cbWritten;
    1394                     cbElapsed      -= cbWritten;
    1395                     Assert((cbWritten & 1) == 0);    /* Else the following shift won't work */
    1396                     pReg->picb     -= (cbWritten >> 1);
     1413                    rc = ichac97WriteAudio(pThis, pReg, cbElapsed, &cbTransferred);
     1414                    if (RT_SUCCESS(rc)
     1415                        && cbTransferred)
     1416                    {
     1417                        cbWrittenTotal += cbTransferred;
     1418                        Assert(cbElapsed >= cbTransferred);
     1419                        cbElapsed      -= cbTransferred;
     1420                        Assert((cbTransferred & 1) == 0);    /* Else the following shift won't work */
     1421                        pReg->picb     -= (cbTransferred >> 1);
     1422                    }
     1423                    break;
    13971424                }
    1398                 break;
    1399             }
    14001425
    14011426            case PI_INDEX:
    14021427            case MC_INDEX:
    1403             {
    1404                 rc = ichac97ReadAudio(pThis, pReg, cbElapsed, &cbWritten);
    1405                 if (RT_SUCCESS(rc))
    14061428                {
    1407                     cbElapsed  -= cbWritten;
    1408                     Assert((cbWritten & 1) == 0);    /* Else the following shift won't work */
    1409                     pReg->picb -= (cbWritten >> 1);
     1429                    rc = ichac97ReadAudio(pThis, pReg, cbElapsed, &cbTransferred);
     1430                    if (RT_SUCCESS(rc)
     1431                        && cbTransferred)
     1432                    {
     1433                        Assert(cbElapsed >= cbTransferred);
     1434                        cbElapsed  -= cbTransferred;
     1435                        Assert((cbTransferred & 1) == 0);    /* Else the following shift won't work */
     1436                        pReg->picb -= (cbTransferred >> 1);
     1437                    }
     1438                    break;
    14101439                }
    1411                 break;
    1412             }
    14131440
    14141441            default:
     
    14181445        }
    14191446
    1420         LogFlowFunc(("pReg->picb=%RU16, cbWrittenTotal=%RU32\n", pReg->picb, cbWrittenTotal));
     1447        LogFlowFunc(("pReg->picb=%#x, cbWrittenTotal=%RU32\n", pReg->picb, cbWrittenTotal));
    14211448
    14221449        if (!pReg->picb)
     
    14311458            if (pReg->civ == pReg->lvi)
    14321459            {
    1433                 LogFlowFunc(("Underrun civ (%d) == lvi (%d)\n", pReg->civ, pReg->lvi));
     1460                LogFlowFunc(("Underrun civ (%RU8) == lvi (%RU8)\n", pReg->civ, pReg->lvi));
    14341461                new_sr |= SR_LVBCI | SR_DCH | SR_CELV;
    14351462                pThis->bup_flag = (pReg->bd.ctl_len & BD_BUP) ? BUP_LAST : 0;
    14361463
    1437                 rc = VERR_NO_DATA;
     1464                rc = VINF_EOF;
    14381465            }
    14391466            else
     
    14471474        }
    14481475
    1449         if (RT_FAILURE(rc))
    1450         {
    1451             if (rc == VERR_NO_DATA)
    1452                 rc = VINF_SUCCESS;
    1453 
     1476        if (   RT_FAILURE(rc)
     1477            || rc == VINF_EOF) /* All data processed? */
     1478        {
    14541479            break;
    14551480        }
     
    21712196    }
    21722197
     2198    LogFlowFuncLeave();
    21732199    return VINF_SUCCESS;
    21742200}
     
    23192345    RTListInit(&pThis->lstDrv);
    23202346
    2321     uint8_t uLUN = 0;
    2322     do
     2347    uint8_t uLUN;
     2348    for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
    23232349    {
    23242350        LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN));
    2325         rc = ichac97Attach(pDevIns, uLUN++, PDM_TACH_FLAGS_NOT_HOT_PLUG);
     2351        rc = ichac97Attach(pDevIns, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);
    23262352        if (RT_FAILURE(rc))
    23272353        {
     
    23312357        }
    23322358
    2333     } while (0);
     2359        uLUN++;
     2360    }
    23342361
    23352362    LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
     
    24722499    {
    24732500        pThis->cbReadWriteBuf = _4K; /** @todo Make this configurable. */
    2474         pThis->pvReadWriteBuf = (uint8_t *)RTMemAlloc(pThis->cbReadWriteBuf);
     2501        pThis->pvReadWriteBuf = (uint8_t *)RTMemAllocZ(pThis->cbReadWriteBuf);
    24752502        if (!pThis->pvReadWriteBuf)
    24762503            rc = VERR_NO_MEMORY;
     
    25712598#endif /* !IN_RING3 */
    25722599#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
    2573 
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r53853 r54230  
    99
    1010/*
    11  * Copyright (C) 2006-2014 Oracle Corporation
     11 * Copyright (C) 2006-2015 Oracle Corporation
    1212 *
    1313 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5656#endif
    5757#include "DevIchHdaCodec.h"
    58 
    59 #ifdef DEBUG
    60 //#define DEBUG_LUN
    61 # ifdef DEBUG_LUN
    62 #  define DEBUG_LUN_NUM 0
    63 # endif
    64 #endif /* DEBUG */
    6558
    6659/*******************************************************************************
     
    24802473        }
    24812474
    2482         rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector,
    2483                                          pszDesc, enmRecSource,
    2484                                          NULL /* fnCallback */, NULL /* pvCallback */,
    2485                                          pCfg,
    2486                                          &pDrv->LineIn.pStrmIn);
     2475        rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector, pszDesc, enmRecSource, pCfg, &pDrv->LineIn.pStrmIn);
    24872476        LogFlowFunc(("LUN#%RU8: Opened input \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
    24882477        if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
     
    25092498    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    25102499    {
    2511         int rc2 = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszName,
    2512                                                NULL /* fnCallback */, pDrv /* pvCallback */,
    2513                                                pCfg,
    2514                                                &pDrv->Out.pStrmOut);
     2500        int rc2 = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszName, pCfg, &pDrv->Out.pStrmOut);
    25152501        if (RT_FAILURE(rc2))
    25162502        {
     
    25652551    PHDADRIVER pDrv;
    25662552    uint32_t cbIn, cbOut;
    2567 #ifdef DEBUG_LUN
    2568     uint8_t uLUN = 0;
    2569 #endif
     2553
    25702554    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    25712555    {
    25722556        if (!pDrv->pConnector->pfnIsOutputOK(pDrv->pConnector, pDrv->Out.pStrmOut))
     2557        {
     2558            pDrv->cSamplesLive = 0;
    25732559            continue;
    2574 
    2575         rc = pDrv->pConnector->pfnQueryData(pDrv->pConnector, /** @todo Rename QueryStatus */
    2576                                             &cbIn, &cbOut, &pDrv->cSamplesLive);
     2560        }
     2561
     2562        rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
     2563                                              &cbIn, &cbOut, &pDrv->cSamplesLive);
    25772564        if (RT_SUCCESS(rc))
    25782565        {
    2579 #ifdef DEBUG_LUN
    2580             LogFlowFunc(("\tLUN#%RU8: cbIn=%RU32, cbOut=%RU32\n", uLUN, cbIn, cbOut));
    2581 #endif
     2566            if (cbIn || cbOut)
     2567                LogFlowFunc(("\tLUN#%RU8: cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, cbIn, cbOut));
     2568
    25822569            cbInMax  = RT_MAX(cbInMax, cbIn);
    25832570            cbOutMin = RT_MIN(cbOutMin, cbOut);
     
    25852572        else
    25862573            pDrv->cSamplesLive = 0;
    2587 
    2588 #ifdef DEBUG_LUN
    2589         uLUN++;
    2590 #endif
    25912574    }
    25922575
     
    26032586        RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    26042587        {
    2605             if (pDrv->cSamplesLive)
    2606                 pDrv->pConnector->pfnPlayOut(pDrv->pConnector);
     2588            /*if (pDrv->cSamplesLive)
     2589                pDrv->pConnector->pfnPlayOut(pDrv->pConnector);*/
    26072590        }
    26082591    }
     
    38373820    RTListInit(&pThis->lstDrv);
    38383821
    3839     unsigned uLUN = 0;
    3840     do
     3822    uint8_t uLUN;
     3823    for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
    38413824    {
    38423825        LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN));
    3843         rc = hdaAttach(pDevIns, uLUN++, PDM_TACH_FLAGS_NOT_HOT_PLUG);
     3826        rc = hdaAttach(pDevIns, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);
    38443827        if (RT_FAILURE(rc))
    38453828        {
     
    38503833        }
    38513834
    3852     } while (RT_SUCCESS(rc));
     3835        uLUN++;
     3836    }
     3837
     3838    LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
    38533839
    38543840    if (RT_SUCCESS(rc))
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r53916 r54230  
    299299        as.enmEndianness = PDMAUDIOHOSTENDIANESS;
    300300
    301         int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out",
    302                                      sb16AudioCallback /* fnCallback */, s /* pvCallback */,
    303                                      &as,
    304                                      &s->pGstStrmOut);
     301        int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out", &as, &s->pGstStrmOut);
    305302        AssertRC(rc);
    306303#else
     
    459456        as.enmEndianness = PDMAUDIOHOSTENDIANESS;
    460457
    461         int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out",
    462                                      sb16AudioCallback /* fnCallback */, s /* pvCallback */,
    463                                      &as,
    464                                      &s->pGstStrmOut);
     458        int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out", &as, &s->pGstStrmOut);
    465459        AssertRC(rc);
    466460#else
     
    972966    as.enmEndianness = PDMAUDIOHOSTENDIANESS;
    973967
    974     int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out",
    975                                  sb16AudioCallback /* fnCallback */, s /* pvContext */,
    976                                  &as,
    977                                  &s->pGstStrmOut);
     968    int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out", &as, &s->pGstStrmOut);
    978969    AssertRC(rc);
    979970#else
     
    17471738            streamCfg.enmEndianness = PDMAUDIOHOSTENDIANESS;
    17481739
    1749             int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out",
    1750                                          sb16AudioCallback /* fnCallback */, s /* pvContext */,
    1751                                          &streamCfg,
    1752                                          &s->pGstStrmOut);
     1740            int rc = s->pDrv->pfnOpenOut(s->pDrv, "sb16.out", &streamCfg, &s->pGstStrmOut);
    17531741            AssertRC(rc);
    17541742#else
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r53945 r54230  
    9797};
    9898
    99 int drvAudioAddHstOut(PDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg,
    100                       PPDMAUDIOHSTSTRMOUT *ppHstStrmOut)
    101 {
    102     LogFlowFuncEnter();
     99int drvAudioAddHstOut(PDRVAUDIO pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut)
     100{
     101    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     102    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     103    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    103104
    104105    PPDMAUDIOHSTSTRMOUT pHstStrmOut;
     
    108109        && conf.fixed_out.greedy)
    109110    {
    110         rc = drvAudioAllocHstOut(pThis, pCfg, &pHstStrmOut);
     111        rc = drvAudioAllocHstOut(pThis, pszName, pCfg, &pHstStrmOut);
    111112    }
    112113    else
     
    118119        if (!pHstStrmOut)
    119120        {
    120             rc = drvAudioAllocHstOut(pThis, pCfg, &pHstStrmOut);
     121            rc = drvAudioAllocHstOut(pThis, pszName, pCfg, &pHstStrmOut);
    121122            if (RT_FAILURE(rc))
    122123                pHstStrmOut = drvAudioFindAnyHstOut(pThis, NULL /* pHstStrmOut */);
     
    129130        *ppHstStrmOut = pHstStrmOut;
    130131
    131     LogFlowFuncLeaveRC(rc);
    132132    return rc;
    133133}
     
    392392}
    393393
    394 /*
    395  * Guest input stream handling (capturing from the host).
    396  */
    397 
    398 /*
    399  * Host output handling (playing output from the guest).
    400  */
    401 
    402394int drvAudioDestroyHstOut(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMOUT pHstStrmOut)
    403395{
     
    405397    AssertPtrReturn(pHstStrmOut, VERR_INVALID_POINTER);
    406398
    407     LogFlowFunc(("%p\n", pHstStrmOut));
     399    LogFlowFunc(("%s\n", pHstStrmOut->MixBuf.pszName));
    408400
    409401    int rc;
     
    426418        rc = VERR_ACCESS_DENIED;
    427419
    428     LogFlowFunc(("Host output stream %p still being used, rc=%Rrc\n",
    429                  pHstStrmOut, rc));
    430 
     420    LogFlowFunc(("[%s] Still is being used, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc));
    431421    return rc;
    432422}
     
    533523}
    534524
    535 int drvAudioAllocHstOut(PDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg,
    536                         PPDMAUDIOHSTSTRMOUT *ppHstStrmOut)
     525int drvAudioAllocHstOut(PDRVAUDIO pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOHSTSTRMOUT *ppHstStrmOut)
    537526{
    538527    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     528    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
    539529    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
    540530
     
    579569        fInitialized = true;
    580570
    581         rc = audioMixBufInit(&pHstStrmOut->MixBuf, "HostOut", &pHstStrmOut->Props, cSamples);
     571        rc = audioMixBufInit(&pHstStrmOut->MixBuf, pszName, &pHstStrmOut->Props, cSamples);
    582572        if (RT_SUCCESS(rc))
    583573        {
     
    610600                                PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut)
    611601{
     602    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     603    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     604    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
     605
    612606    PPDMAUDIOSTREAMCFG pThisCfg;
    613607    if (conf.fixed_out.enabled)
     
    616610        pThisCfg = pCfg;
    617611
    618     AssertPtrReturn(pThisCfg, VERR_INVALID_PARAMETER);
     612    AssertPtrReturn(pThisCfg, VERR_INVALID_POINTER);
    619613
    620614    LogFlowFunc(("Using fixed audio output settings: %RTbool\n",
     
    625619    if (!pGstStrmOut)
    626620    {
    627         LogFlowFunc(("Failed to allocate memory for guest output stream \"%s\"\n",
    628                      pszName));
     621        LogFlowFunc(("Failed to allocate memory for guest output stream \"%s\"\n", pszName));
    629622        return VERR_NO_MEMORY;
    630623    }
    631624
    632625    PPDMAUDIOHSTSTRMOUT pHstStrmOut;
    633     int rc = drvAudioAddHstOut(pThis, pThisCfg, &pHstStrmOut);
     626    int rc = drvAudioAddHstOut(pThis, pszName, pThisCfg, &pHstStrmOut);
    634627    if (RT_FAILURE(rc))
    635628    {
    636         LogFlowFunc(("Error adding host output stream \"%s\", rc=%Rrc\n",
    637                      pszName, rc));
     629        LogFlowFunc(("Error adding host output stream \"%s\", rc=%Rrc\n", pszName, rc));
    638630
    639631        RTMemFree(pGstStrmOut);
     
    837829{
    838830    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
    839 
    840831    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     832
    841833    AssertPtrReturn(pGstStrmOut, VERR_INVALID_POINTER);
    842834    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
     
    844836    /* pcbWritten is optional. */
    845837
     838    if (!pThis->pHostDrvAudio->pfnIsEnabled(pThis->pHostDrvAudio, PDMAUDIODIR_OUT))
     839        return VERR_NOT_AVAILABLE;
     840
    846841    PPDMAUDIOHSTSTRMOUT pHstStrmOut = pGstStrmOut->pHstStrmOut;
    847842    AssertPtrReturn(pHstStrmOut, VERR_INVALID_POINTER);
    848843
    849844    AssertMsg(pGstStrmOut->pHstStrmOut->fEnabled,
    850               ("Writing to disabled host output stream %p not possible\n",
    851               pGstStrmOut->pHstStrmOut));
     845              ("Writing to disabled host output stream \"%s\" not possible\n",
     846              pHstStrmOut->MixBuf.pszName));
    852847
    853848    /*
     
    856851     */
    857852    uint32_t cWritten;
    858     int rc = audioMixBufWriteAt(&pGstStrmOut->MixBuf,
    859                                 0 /* Offset in samples */,
    860                                 pvBuf, cbBuf,
    861                                 &cWritten);
     853    int rc = audioMixBufWriteAt(&pGstStrmOut->MixBuf, 0 /* Offset in samples */, pvBuf, cbBuf, &cWritten);
    862854
    863855    /*
     
    869861        && cWritten)
    870862    {
    871         rc = audioMixBufMixToParent(&pGstStrmOut->MixBuf,
    872                                     cWritten, &cMixed);
     863        rc = audioMixBufMixToParent(&pGstStrmOut->MixBuf, cWritten, &cMixed);
    873864    }
    874865    else
     
    884875    }
    885876
    886     LogFlowFunc(("Written pvBuf=%p, cbBuf=%zu, cWritten=%RU32 (%RU32 bytes), cMixed=%RU32, rc=%Rrc\n",
    887                  pvBuf, cbBuf, cWritten, AUDIOMIXBUF_S2B(&pGstStrmOut->MixBuf, cWritten),
    888                  cMixed, rc));
     877    LogFlowFunc(("%s -> %s: Written pvBuf=%p, cbBuf=%zu, cWritten=%RU32 (%RU32 bytes), cMixed=%RU32, rc=%Rrc\n",
     878                 pGstStrmOut->MixBuf.pszName, pHstStrmOut->MixBuf.pszName, pvBuf, cbBuf, cWritten,
     879                 AUDIOMIXBUF_S2B(&pGstStrmOut->MixBuf, cWritten), cMixed, rc));
    889880    return rc;
    890881}
     
    931922    AssertPtrReturn(pHstStrmIn, VERR_INVALID_POINTER);
    932923
    933     LogFlowFunc(("%p\n", pHstStrmIn));
     924    LogFlowFunc(("%s\n", pHstStrmIn->MixBuf.pszName));
    934925
    935926    int rc;
     
    951942        rc = VERR_ACCESS_DENIED;
    952943
    953     LogFlowFunc(("Host input stream %p still being used, rc=%Rrc\n",
    954                  pHstStrmIn, rc));
    955 
     944    LogFlowFunc(("[%s] Still is being used, rc=%Rrc\n", pHstStrmIn->MixBuf.pszName, rc));
    956945    return rc;
    957946}
     
    961950    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
    962951
    963     LogFlowFunc(("%p\n", pGstStrmIn));
     952    LogFlowFunc(("%s\n", pGstStrmIn->MixBuf.pszName));
    964953
    965954    if (pGstStrmIn)
     
    984973}
    985974
    986 static DECLCALLBACK(int) drvAudioQueryData(PPDMIAUDIOCONNECTOR pInterface,
    987                                            uint32_t *pcbAvailIn, uint32_t *pcbFreeOut,
    988                                            uint32_t *pcSamplesLive)
     975static DECLCALLBACK(int) drvAudioQueryStatus(PPDMIAUDIOCONNECTOR pInterface,
     976                                             uint32_t *pcbAvailIn, uint32_t *pcbFreeOut,
     977                                             uint32_t *pcSamplesLive)
    989978{
    990979    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     980    /* pcbAvailIn is optional. */
     981    /* pcbFreeOut is optional. */
     982    /* pcSamplesLive is optional. */
    991983
    992984    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
     985
     986    if (!pThis->pHostDrvAudio->pfnIsEnabled(pThis->pHostDrvAudio, PDMAUDIODIR_OUT))
     987        return VERR_NOT_AVAILABLE;
    993988
    994989    int rc = VINF_SUCCESS;
     
    10211016                pHstStrmOut->fPendingDisable = false;
    10221017
    1023                 LogFunc(("%p: Disabling stream\n", pHstStrmOut));
     1018                LogFunc(("[%s] Disabling stream\n", pHstStrmOut->MixBuf.pszName));
    10241019            }
    10251020            else
    1026                 LogFunc(("%p: Backend vetoed against closing output stream, rc=%Rrc\n",
    1027                          pHstStrmOut, rc2));
     1021                LogFunc(("[%s] Backend vetoed against closing output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc2));
    10281022
    10291023            continue;
    10301024        }
    10311025
    1032         LogFlowFunc(("%p: Has %RU32 live samples\n", pHstStrmOut, cSamplesLive));
     1026        LogFlowFunc(("[%s] cSamplesLive=%RU32\n", pHstStrmOut->MixBuf.pszName, cSamplesLive));
    10331027
    10341028        /*
     
    10511045                    cbFree2 = RT_MIN(cbFree2, AUDIOMIXBUF_S2B_RATIO(&pGstStrmOut->MixBuf,
    10521046                                                                    audioMixBufFree(&pGstStrmOut->MixBuf)));
     1047
     1048                    LogFlowFunc(("\t[%s] cbFree=%RU32\n", pGstStrmOut->MixBuf.pszName, cbFree2));
    10531049                }
    10541050            }
    10551051
    10561052            cbFreeOut = RT_MIN(cbFreeOut, cbFree2);
    1057             continue;
    10581053        }
    10591054    }
     
    10811076            cbAvailIn = RT_MAX(cbAvailIn, AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf,
    10821077                                                          audioMixBufMixed(&pHstStrmIn->MixBuf)));
     1078
     1079            LogFlowFunc(("\t[%s] cbFree=%RU32\n", pHstStrmIn->MixBuf.pszName, cbAvailIn));
    10831080        }
    10841081    }
     
    11021099}
    11031100
    1104 static DECLCALLBACK(int) drvAudioPlayOut(PPDMIAUDIOCONNECTOR pInterface)
     1101static DECLCALLBACK(int) drvAudioPlayOut(PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcSamplesPlayed)
    11051102{
    11061103    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    1107     /* pcbFree is optional. */
     1104    /* pcSamplesPlayed is optional. */
    11081105
    11091106    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
    11101107
    11111108    int rc = VINF_SUCCESS;
     1109    uint32_t cSamplesPlayedMax = 0;
    11121110
    11131111    /*
     
    11171115    while ((pHstStrmOut = drvAudioHstFindAnyEnabledOut(pThis, pHstStrmOut)))
    11181116    {
     1117#if 0
    11191118        uint32_t cStreamsLive;
    11201119        uint32_t cSamplesLive = drvAudioHstOutSamplesLive(pHstStrmOut, &cStreamsLive);
     
    11391138            else
    11401139                LogFunc(("\t%p: Backend vetoed against closing output stream, rc=%Rrc\n",
    1141                          rc2, pHstStrmOut));
     1140                         pHstStrmOut, rc2));
    11421141
    11431142            continue;
    11441143        }
    1145 
    1146         uint32_t cSamplesPlayed;
     1144#endif
     1145
     1146        uint32_t cSamplesPlayed = 0;
    11471147        int rc2 = pThis->pHostDrvAudio->pfnPlayOut(pThis->pHostDrvAudio, pHstStrmOut,
    11481148                                                   &cSamplesPlayed);
    1149         LogFlowFunc(("\t%p: cStreamsLive=%RU32, cSamplesLive=%RU32, cSamplesPlayed=%RU32, rc=%Rrc\n",
    1150                      pHstStrmOut, cStreamsLive, cSamplesLive, cSamplesPlayed, rc2));
     1149        if (RT_SUCCESS(rc2))
     1150            cSamplesPlayedMax = RT_MAX(cSamplesPlayed, cSamplesPlayedMax);
     1151
     1152        LogFlowFunc(("\t[%s] cSamplesPlayed=%RU32, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, cSamplesPlayed, rc2));
    11511153
    11521154        bool fNeedsCleanup = false;
     
    11621164            {
    11631165                pGstStrmOut->State.fEmpty = true;
    1164                 fNeedsCleanup |=    !pGstStrmOut->State.fActive
    1165                                  && !pGstStrmOut->Callback.fn;
     1166                fNeedsCleanup |= !pGstStrmOut->State.fActive;
    11661167            }
    11671168        }
     
    11751176            }
    11761177        }
     1178    }
     1179
     1180    if (RT_SUCCESS(rc))
     1181    {
     1182        if (pcSamplesPlayed)
     1183            *pcSamplesPlayed = cSamplesPlayedMax;
    11771184    }
    11781185
     
    13861393{
    13871394    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
    1388 
    13891395    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     1396
    13901397    AssertPtrReturn(pGstStrmIn, VERR_INVALID_POINTER);
    13911398    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
     
    13931400    /* pcbWritten is optional. */
    13941401
     1402    if (!pThis->pHostDrvAudio->pfnIsEnabled(pThis->pHostDrvAudio, PDMAUDIODIR_IN))
     1403        return VERR_NOT_AVAILABLE;
     1404
    13951405    PPDMAUDIOHSTSTRMIN pHstStrmIn = pGstStrmIn->pHstStrmIn;
    13961406    AssertPtrReturn(pHstStrmIn, VERR_INVALID_POINTER);
    13971407
    13981408    AssertMsg(pGstStrmIn->pHstStrmIn->fEnabled,
    1399               ("Reading from disabled host input stream %p not possible\n",
    1400               pGstStrmIn->pHstStrmIn));
     1409              ("Reading from disabled host input stream \"%s\" not possible\n", pGstStrmIn->MixBuf.pszName));
    14011410
    14021411    /*
     
    14231432                                                bool fMute, uint8_t uVolLeft, uint8_t uVolRight)
    14241433{
    1425     LogFlowFunc(("pGstStrmOut=%p, fMute=%RTbool, uVolLeft=%RU8, uVolRight=%RU8\n",
    1426                  pGstStrmOut, fMute, uVolLeft, uVolRight));
     1434    LogFlowFunc(("[%s] fMute=%RTbool, uVolLeft=%RU8, uVolRight=%RU8\n",
     1435                 pGstStrmOut->MixBuf.pszName, fMute, uVolLeft, uVolRight));
    14271436
    14281437    if (pGstStrmOut)
     
    15291538        AssertPtr(pHstStrmIn);
    15301539
    1531         LogFlowFunc(("pHstStrmIn=%p, pGstStrmIn=%p, fEnable=%RTbool\n",
    1532                      pHstStrmIn, pGstStrmIn, fEnable));
     1540        LogFlowFunc(("%s -> %s, fEnable=%RTbool\n",
     1541                     pHstStrmIn->MixBuf.pszName, pGstStrmIn->MixBuf.pszName, fEnable));
    15331542
    15341543        if (pGstStrmIn->State.fActive != fEnable)
     
    15791588
    15801589static DECLCALLBACK(int) drvAudioOpenIn(PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    1581                                         PDMAUDIORECSOURCE enmRecSource,
    1582                                         PDMAUDIOCALLBACK_FN fnCallback, void *pvCallback,
    1583                                         PPDMAUDIOSTREAMCFG pCfg,
     1590                                        PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg,
    15841591                                        PPDMAUDIOGSTSTRMIN *ppGstStrmIn)
    15851592{
     
    16041611        && drvAudioPCMPropsAreEqual(&pGstStrmIn->Props, pCfg))
    16051612    {
    1606         LogFunc(("Input stream %p exists and matches required configuration, skipping creation\n",
    1607                  pGstStrmIn));
     1613        LogFunc(("[%s] Exists and matches required configuration, skipping creation\n",
     1614                 pGstStrmIn->MixBuf.pszName));
    16081615        return VWRN_ALREADY_EXISTS;
    16091616    }
     
    16351642        pGstStrmIn->State.fMuted = RT_BOOL(nominal_volume.mute);
    16361643
    1637         pGstStrmIn->Callback.fn = fnCallback;
    1638         pGstStrmIn->Callback.pvContext = pvCallback;
    1639 
    16401644        *ppGstStrmIn = pGstStrmIn;
    16411645    }
     
    16461650
    16471651DECLCALLBACK(int) drvAudioOpenOut(PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    1648                                   PDMAUDIOCALLBACK_FN fnCallback, void *pvCallback,
    1649                                   PPDMAUDIOSTREAMCFG pCfg,
    1650                                   PPDMAUDIOGSTSTRMOUT *ppGstStrmOut)
     1652                                  PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut)
    16511653{
    16521654    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    16691671        && drvAudioPCMPropsAreEqual(&pGstStrmOut->Props, pCfg))
    16701672    {
    1671         LogFunc(("Output stream %p exists and matches required configuration, skipping creation\n",
    1672                  pGstStrmOut));
     1673        LogFunc(("[%s] Exists and matches required configuration, skipping creation\n",
     1674                 pGstStrmOut->MixBuf.pszName));
    16731675        return VWRN_ALREADY_EXISTS;
    16741676    }
     
    17241726        pGstStrmOut->State.uVolumeRight = nominal_volume.r;
    17251727        pGstStrmOut->State.fMuted       = RT_BOOL(nominal_volume.mute);
    1726         pGstStrmOut->Callback.fn        = fnCallback;
    1727         pGstStrmOut->Callback.pvContext = pvCallback;
    17281728
    17291729        *ppGstStrmOut = pGstStrmOut;
     
    18351835    pDrvIns->IBase.pfnQueryInterface                 = drvAudioQueryInterface;
    18361836    /* IAudio. */
    1837     pThis->IAudioConnector.pfnQueryData              = drvAudioQueryData;
     1837    pThis->IAudioConnector.pfnQueryStatus            = drvAudioQueryStatus;
    18381838    pThis->IAudioConnector.pfnRead                   = drvAudioRead;
    18391839    pThis->IAudioConnector.pfnWrite                  = drvAudioWrite;
     
    18411841    pThis->IAudioConnector.pfnIsOutputOK             = drvAudioIsOutputOK;
    18421842    pThis->IAudioConnector.pfnInitNull               = drvAudioInitNull;
    1843     pThis->IAudioConnector.pfnIsSetOutVolume         = drvAudioIsSetOutVolume;
     1843    pThis->IAudioConnector.pfnSetVolumeOut           = drvAudioIsSetOutVolume;
    18441844    pThis->IAudioConnector.pfnSetVolume              = drvAudioSetVolume;
    18451845    pThis->IAudioConnector.pfnEnableOut              = drvAudioEnableOut;
     
    18701870        LogRel(("Audio: Failed to query interface for underlying host driver\n"));
    18711871        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW,
    1872                                 N_("No audio interface below"));
    1873     }
    1874 
    1875     pThis->pDrvIns = pDrvIns;
     1872                                N_("Host audio backend missing or invalid"));
     1873    }
    18761874
    18771875#ifdef DEBUG_andy
     
    18801878
    18811879    rc = drvAudioInit(pCfgHandle, pDrvIns);
     1880    if (RT_SUCCESS(rc))
     1881    {
     1882        pThis->fTerminate = false;
     1883        pThis->pDrvIns    = pDrvIns;
     1884    }
    18821885
    18831886    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp

    r53624 r54230  
    55
    66/*
    7  * Copyright (C) 2014 Oracle Corporation
     7 * Copyright (C) 2014-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    766766}
    767767
     768static DECLCALLBACK(bool) drvHostOSSAudioIsEnabled(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     769{
     770    NOREF(pInterface);
     771    NOREF(enmDir);
     772    return true; /* Always all enabled. */
     773}
     774
    768775static DECLCALLBACK(int) drvHostOSSAudioPlayOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut,
    769776                                                uint32_t *pcSamplesPlayed)
     
    933940     * Init the static parts.
    934941     */
    935     pThis->pDrvIns                    = pDrvIns;
     942    pThis->pDrvIns                   = pDrvIns;
    936943    /* IBase */
    937     pDrvIns->IBase.pfnQueryInterface  = drvHostOSSAudioQueryInterface;
    938     pThis->IHostAudioR3.pfnInitIn     = drvHostOSSAudioInitIn;
    939     pThis->IHostAudioR3.pfnInitOut    = drvHostOSSAudioInitOut;
    940     pThis->IHostAudioR3.pfnControlIn  = drvHostOSSAudioControlIn;
    941     pThis->IHostAudioR3.pfnControlOut = drvHostOSSAudioControlOut;
    942     pThis->IHostAudioR3.pfnFiniIn     = drvHostOSSAudioFiniIn;
    943     pThis->IHostAudioR3.pfnFiniOut    = drvHostOSSAudioFiniOut;
    944     pThis->IHostAudioR3.pfnCaptureIn  = drvHostOSSAudioCaptureIn;
    945     pThis->IHostAudioR3.pfnPlayOut    = drvHostOSSAudioPlayOut;
    946     pThis->IHostAudioR3.pfnGetConf    = drvHostOSSAudioGetConf;
    947     pThis->IHostAudioR3.pfnInit       = drvHostOSSAudioInit;
     944    pDrvIns->IBase.pfnQueryInterface = drvHostOSSAudioQueryInterface;
     945    /* IHostAudioR3 */
     946    PDMAUDIO_IHOSTAUDIOR3_CALLBACKS(drvHostOSSAudio);
    948947
    949948    return VINF_SUCCESS;
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r54108 r54230  
    14501450#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    14511451        if (mAudioVRDE)
    1452             mAudioVRDE->onVRDEInputIntercept(false /* fIntercept */);
     1452            mAudioVRDE->onVRDEControl(false /* fEnable */, 0 /* uFlags */);
    14531453#else
    14541454        mcAudioRefs--;
     
    15011501#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    15021502    if (mAudioVRDE)
    1503         mAudioVRDE->onVRDEInputIntercept(true /* fIntercept */);
     1503        mAudioVRDE->onVRDEControl(true /* fEnable */, 0 /* uFlags */);
    15041504#else
    15051505    ++mcAudioRefs;
     
    23802380                           (PFNRT)i_unplugCpu, 3,
    23812381                           this, pUVM, (VMCPUID)aCpu);
    2382    
     2382
    23832383        /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    23842384        alock.release();
     
    48214821     */
    48224822    bool fResume = false;
    4823     int rc = i_suspendBeforeConfigChange(pUVM, NULL, &fResume);
    4824     if (FAILED(rc))
    4825         return rc;
     4823    HRESULT hr = i_suspendBeforeConfigChange(pUVM, NULL, &fResume);
     4824    if (FAILED(hr))
     4825        return hr;
    48264826
    48274827    /*
     
    48304830     * here to make requests from under the lock in order to serialize them.
    48314831     */
    4832     PVMREQ pReq;
    4833     int vrc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/,
    4834                                (PFNRT)i_changeNetworkAttachment, 6,
    4835                                this, pUVM, pszDevice, uInstance, uLun, aNetworkAdapter);
     4832    int rc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/,
     4833                              (PFNRT)i_changeNetworkAttachment, 6,
     4834                              this, pUVM, pszDevice, uInstance, uLun, aNetworkAdapter);
    48364835
    48374836    if (fResume)
    48384837        i_resumeAfterConfigChange(pUVM);
    48394838
    4840     if (RT_SUCCESS(vrc))
    4841     {
    4842         LogFlowThisFunc(("Returns S_OK\n"));
     4839    if (RT_SUCCESS(rc))
    48434840        return S_OK;
    4844     }
    48454841
    48464842    return setError(E_FAIL,
    4847                     tr("Could not change the network adaptor attachement type (%Rrc)"),
    4848                     vrc);
     4843                    tr("Could not change the network adaptor attachement type (%Rrc)"), rc);
    48494844}
    48504845
  • trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp

    r53442 r54230  
    11/* $Id$ */
    22/** @file
    3  * VBox Console VRDP Helper class
     3 * VBox Console VRDP helper class.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    651651            size_t cbPortRange = portRange.length() + 1;
    652652
    653             if (cbPortRange >= 0x10000)
    654             {
    655                 /* More than 64K seems to be an  invalid port range string. */
     653            if (cbPortRange >= _64K)
     654            {
     655                /* More than 64K seems to be an invalid port range string. */
    656656                rc = VERR_TOO_MUCH_DATA;
    657657                break;
     
    797797
    798798                HRESULT hrc = server->mConsole->i_machine()->GetExtraData(com::Bstr(extraData).raw(),
    799                                                                         bstrValue.asOutParam());
     799                                                                          bstrValue.asOutParam());
    800800                if (FAILED(hrc) || bstrValue.isEmpty())
    801801                {
     
    805805
    806806                    hrc = server->mConsole->i_machine()->GetExtraData(com::Bstr(extraData).raw(),
    807                                                                     bstrValue.asOutParam());
     807                                                                      bstrValue.asOutParam());
    808808                    if (FAILED(hrc))
    809809                    {
     
    817817                const char *pszPropertyName = &pFeature->achInfo[9];
    818818                HRESULT hrc = server->mConsole->i_getVRDEServer()->GetVRDEProperty(Bstr(pszPropertyName).raw(),
    819                                                                                  bstrValue.asOutParam());
     819                                                                                   bstrValue.asOutParam());
    820820                if (FAILED(hrc))
    821821                {
     
    957957
    958958#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    959         pServer->mConsole->i_getAudioVRDE()->onVRDEInputIntercept(false);
     959        AudioVRDE *pVRDE = pServer->mConsole->i_getAudioVRDE();
     960        if (pVRDE)
     961            pVRDE->onVRDEInputIntercept(false /* fIntercept */);
    960962#else
    961963        PPDMIAUDIOSNIFFERPORT pPort = pServer->mConsole->i_getAudioSniffer()->getAudioSnifferPort();
     
    983985{
    984986    ConsoleVRDPServer *pServer = static_cast<ConsoleVRDPServer*>(pvCallback);
     987    AssertPtrReturn(pServer, VERR_INVALID_POINTER);
    985988
    986989    LogFlowFunc(("%x\n", fu32Intercept));
     
    10181021        case VRDE_CLIENT_INTERCEPT_AUDIO_INPUT:
    10191022        {
    1020             /* This request is processed internally by the ConsoleVRDPServer.
     1023            /*
     1024             * This request is processed internally by the ConsoleVRDPServer.
    10211025             * Only one client is allowed to intercept audio input.
    10221026             */
    10231027            if (ASMAtomicCmpXchgU32(&pServer->mu32AudioInputClientId, u32ClientId, 0) == true)
    10241028            {
    1025                 LogFunc(("Connected client %u\n", u32ClientId));
     1029                LogFunc(("Intercepting audio input by client %RU32\n", u32ClientId));
    10261030#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1027                 pServer->mConsole->i_getAudioVRDE()->onVRDEInputIntercept(true);
     1031                AudioVRDE *pVRDE = pServer->mConsole->i_getAudioVRDE();
     1032                if (pVRDE)
     1033                    pVRDE->onVRDEInputIntercept(true /* fIntercept */);
    10281034#else
    10291035                PPDMIAUDIOSNIFFERPORT pPort = pServer->mConsole->i_getAudioSniffer()->getAudioSnifferPort();
     
    10441050            else
    10451051            {
    1046                 Log(("AUDIOIN: ignored client %u, active client %u\n", u32ClientId, pServer->mu32AudioInputClientId));
     1052                Log(("AUDIOIN: ignored client %RU32, active client %RU32\n", u32ClientId, pServer->mu32AudioInputClientId));
    10471053                rc = VERR_NOT_SUPPORTED;
    10481054            }
     
    13111317#endif
    13121318
     1319    AudioVRDE *pVRDE = pServer->mConsole->i_getAudioVRDE();
     1320    if (!pVRDE) /* Nothing to do, bail out early. */
     1321        return;
     1322
    13131323    switch (u32Event)
    13141324    {
     
    13161326        {
    13171327#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1318             pServer->mConsole->i_getAudioVRDE()->onVRDEInputBegin(pvCtx, (PVRDEAUDIOINBEGIN)pvData);
     1328            pVRDE->onVRDEInputBegin(pvCtx, (PVRDEAUDIOINBEGIN)pvData);
    13191329#else
    13201330            const VRDEAUDIOINBEGIN *pParms = (const VRDEAUDIOINBEGIN *)pvData;
     
    13311341        case VRDE_AUDIOIN_DATA:
    13321342#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1333             pServer->mConsole->i_getAudioVRDE()->onVRDEInputData(pvCtx, pvData, cbData);
     1343            pVRDE->onVRDEInputData(pvCtx, pvData, cbData);
    13341344#else
    13351345            pPort->pfnAudioInputEventData (pPort, pvCtx, pvData, cbData);
     
    13391349        case VRDE_AUDIOIN_END:
    13401350#ifdef VBOX_WITH_PDM_AUDIO_DRIVER
    1341             pServer->mConsole->i_getAudioVRDE()->onVRDEInputEnd(pvCtx);
     1351            pVRDE->onVRDEInputEnd(pvCtx);
    13421352#else
    13431353            pPort->pfnAudioInputEventEnd (pPort, pvCtx);
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r53831 r54230  
    55
    66/*
    7  * Copyright (C) 2013-2014 Oracle Corporation
     7 * Copyright (C) 2013-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5050    /** Pointer to the driver instance structure. */
    5151    PDMIHOSTAUDIO        IHostAudioR3;
     52    /** Pointer to the VRDP's console object. */
    5253    ConsoleVRDPServer   *pConsoleVRDPServer;
    53     /** Pointer to the DrvAudio port interface that is above it. */
     54    /** Pointer to the DrvAudio port interface that is above us. */
    5455    PPDMIAUDIOCONNECTOR  pDrvAudio;
     56    /** Whether this driver is enabled or not. */
     57    bool                 fEnabled;
    5558} DRVAUDIOVRDE, *PDRVAUDIOVRDE;
    5659
     
    6467    /** Critical section. */
    6568    RTCRITSECT           CritSect;
    66 
    6769} VRDESTREAMIN, *PVRDESTREAMIN;
    6870
     
    8284}
    8385
    84 static DECLCALLBACK(int) drvAudioVRDEInitOut(PPDMIHOSTAUDIO pInterface,
    85                                              PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pCfg,
    86                                              uint32_t *pcSamples)
    87 {
    88     PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
    89     AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
    90 
    91     LogFlowFunc(("pHstStrmOut=%p, pCfg=%p\n", pHstStrmOut, pCfg));
    92 
    93     PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pHstStrmOut;
    94     AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
    95 
    96     if (pcSamples)
    97         *pcSamples = _4K; /** @todo Make this configurable. */
    98 
    99     return drvAudioStreamCfgToProps(pCfg, &pVRDEStrmOut->HstStrmOut.Props);
    100 }
    101 
    10286static DECLCALLBACK(int) drvAudioVRDEInitIn(PPDMIHOSTAUDIO pInterface,
    10387                                            PPDMAUDIOHSTSTRMIN pHstStrmIn, PPDMAUDIOSTREAMCFG pCfg,
     
    11599
    116100    return drvAudioStreamCfgToProps(pCfg, &pVRDEStrmIn->HstStrmIn.Props);
     101}
     102
     103static DECLCALLBACK(int) drvAudioVRDEInitOut(PPDMIHOSTAUDIO pInterface,
     104                                             PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pCfg,
     105                                             uint32_t *pcSamples)
     106{
     107    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
     108    AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
     109
     110    LogFlowFunc(("pHstStrmOut=%p, pCfg=%p\n", pHstStrmOut, pCfg));
     111
     112    PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pHstStrmOut;
     113    AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
     114
     115    if (pcSamples)
     116        *pcSamples = _4K; /** @todo Make this configurable. */
     117
     118    return drvAudioStreamCfgToProps(pCfg, &pVRDEStrmOut->HstStrmOut.Props);
     119}
     120
     121static DECLCALLBACK(bool) drvAudioVRDEIsEnabled(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
     122{
     123    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
     124    AssertPtrReturn(pDrv, false);
     125
     126    NOREF(enmDir);
     127
     128    if (!pDrv->fEnabled)
     129        return false;
     130
     131    return true;
    117132}
    118133
     
    184199    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudioR3);
    185200    AssertPtrReturn(pDrv, VERR_INVALID_POINTER);
     201
    186202    PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pHstStrmOut;
    187203    AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
     
    311327
    312328    /* Initialize only if not already done. */
     329    int rc;
    313330    if (enmStreamCmd == PDMAUDIOSTREAMCMD_ENABLE)
    314331    {
    315         int rc2 = pDrv->pConsoleVRDPServer->SendAudioInputBegin(NULL, pVRDEStrmIn, audioMixBufSize(&pThisStrmIn->MixBuf),
    316                                                                 pThisStrmIn->Props.uHz,
    317                                                                 pThisStrmIn->Props.cChannels, pThisStrmIn->Props.cBits);
    318 #ifdef DEBUG
    319         if (rc2 == VERR_NOT_SUPPORTED)
     332        rc = pDrv->pConsoleVRDPServer->SendAudioInputBegin(NULL, pVRDEStrmIn, audioMixBufSize(&pThisStrmIn->MixBuf),
     333                                                           pThisStrmIn->Props.uHz,
     334                                                           pThisStrmIn->Props.cChannels, pThisStrmIn->Props.cBits);
     335        if (rc == VERR_NOT_SUPPORTED)
     336        {
    320337            LogFlowFunc(("No RDP client connected, so no input recording supported\n"));
    321 #endif
     338            rc = VINF_SUCCESS;
     339        }
    322340    }
    323341    else if (enmStreamCmd == PDMAUDIOSTREAMCMD_DISABLE)
    324342    {
    325343        pDrv->pConsoleVRDPServer->SendAudioInputEnd(NULL /* pvUserCtx */);
    326     }
    327 
    328     return VINF_SUCCESS;
     344        rc = VINF_SUCCESS;
     345    }
     346
     347    return rc;
    329348}
    330349
     
    334353    pCfg->cbStreamIn      = sizeof(VRDESTREAMIN);
    335354    pCfg->cMaxHstStrmsOut = 1;
    336     pCfg->cMaxHstStrmsIn  = 2; /* Microphone in + line in. */
     355    pCfg->cMaxHstStrmsIn  = 2; /* Microphone in + Line in. */
    337356
    338357    return VINF_SUCCESS;
     
    367386}
    368387
    369 int AudioVRDE::onVRDEInputIntercept(bool fIntercept)
    370 {
    371     LogFlowThisFunc(("fIntercept=%RTbool\n", fIntercept));
     388int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags)
     389{
     390    LogFlowThisFunc(("fEnable=%RTbool, uFlags=0x%x\n", fEnable, uFlags));
     391
     392    mpDrv->fEnabled = fEnable;
    372393
    373394    return VINF_SUCCESS; /* Never veto. */
     
    398419    bool fUnsigned = VRDE_AUDIO_FMT_SIGNED(audioFmt);
    399420
    400     /*pVRDEStrmIn->cbSample = VRDE_AUDIO_FMT_BYTES_PER_SAMPLE(audioFmt);
    401     pVRDEStrmIn->uHz      = iSampleHz;*/
    402 
    403421    LogFlowFunc(("cbSample=%RU32, iSampleHz=%d, cChannels=%d, cBits=%d, fUnsigned=%RTbool\n",
    404422                 VRDE_AUDIO_FMT_BYTES_PER_SAMPLE(audioFmt), iSampleHz, cChannels, cBits, fUnsigned));
     
    434452}
    435453
     454int AudioVRDE::onVRDEInputIntercept(bool fEnabled)
     455{
     456    return VINF_SUCCESS; /* Never veto. */
     457}
     458
    436459/**
    437460 * Construct a VRDE audio driver instance.
     
    442465DECLCALLBACK(int) AudioVRDE::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    443466{
     467    AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
     468    AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
     469
    444470    PDRVAUDIOVRDE pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVRDE);
     471
    445472    LogRel(("Audio: Initializing VRDE driver\n"));
    446473    LogFlowFunc(("fFlags=0x%x\n", fFlags));
     
    453480     * Init the static parts.
    454481     */
    455     pThis->pDrvIns                    = pDrvIns;
     482    pThis->pDrvIns                   = pDrvIns;
    456483    /* IBase */
    457     pDrvIns->IBase.pfnQueryInterface  = drvAudioVRDEQueryInterface;
     484    pDrvIns->IBase.pfnQueryInterface = drvAudioVRDEQueryInterface;
    458485    /* IHostAudioR3 */
    459     pThis->IHostAudioR3.pfnInitIn     = drvAudioVRDEInitIn;
    460     pThis->IHostAudioR3.pfnInitOut    = drvAudioVRDEInitOut;
    461     pThis->IHostAudioR3.pfnControlOut = drvAudioVRDEControlOut;
    462     pThis->IHostAudioR3.pfnControlIn  = drvAudioVRDEControlIn;
    463     pThis->IHostAudioR3.pfnFiniIn     = drvAudioVRDEFiniIn;
    464     pThis->IHostAudioR3.pfnFiniOut    = drvAudioVRDEFiniOut;
    465     pThis->IHostAudioR3.pfnCaptureIn  = drvAudioVRDECaptureIn;
    466     pThis->IHostAudioR3.pfnPlayOut    = drvAudioVRDEPlayOut;
    467     pThis->IHostAudioR3.pfnGetConf    = drvAudioVRDEGetConf;
    468     pThis->IHostAudioR3.pfnInit       = drvAudioVRDEInit;
    469 
    470     /* Get VRDPServer pointer. */
     486    PDMAUDIO_IHOSTAUDIOR3_CALLBACKS(drvAudioVRDE);
     487
     488    /* Init defaults. */
     489    pThis->fEnabled = false;
     490
     491    /*
     492     * Get the ConsoleVRDPServer object pointer.
     493     */
    471494    void *pvUser;
    472495    int rc = CFGMR3QueryPtr(pCfg, "ObjectVRDPServer", &pvUser);
     
    480503    pThis->pConsoleVRDPServer = (ConsoleVRDPServer *)pvUser;
    481504
     505    /*
     506     * Get the AudioVRDE object pointer.
     507     */
    482508    pvUser = NULL;
    483509    rc = CFGMR3QueryPtr(pCfg, "Object", &pvUser);
  • trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp

    r53442 r54230  
    55
    66/*
    7  * Copyright (C) 2014 Oracle Corporation
     7 * Copyright (C) 2014-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    808808     * Init the static parts.
    809809     */
    810     pThis->pDrvIns                    = pDrvIns;
     810    pThis->pDrvIns                   = pDrvIns;
    811811    /* IBase */
    812     pDrvIns->IBase.pfnQueryInterface  = drvAudioVideoRecQueryInterface;
    813     pThis->IHostAudioR3.pfnInitIn     = drvAudioVideoRecInitIn;
    814     pThis->IHostAudioR3.pfnInitOut    = drvAudioVideoRecInitOut;
    815     pThis->IHostAudioR3.pfnControlOut = drvAudioVideoRecControlOut;
    816     pThis->IHostAudioR3.pfnControlIn  = drvAudioVideoRecControlIn;
    817     pThis->IHostAudioR3.pfnFiniIn     = drvAudioVideoRecFiniIn;
    818     pThis->IHostAudioR3.pfnFiniOut    = drvAudioVideoRecFiniOut;
    819     pThis->IHostAudioR3.pfnCaptureIn  = drvAudioVideoRecCaptureIn;
    820     pThis->IHostAudioR3.pfnPlayOut    = drvAudioVideoRecPlayOut;
    821     pThis->IHostAudioR3.pfnGetConf    = drvAudioVideoRecGetConf;
    822     pThis->IHostAudioR3.pfnInit       = drvAudioVideoRecInit;
     812    pDrvIns->IBase.pfnQueryInterface = drvAudioVideoRecQueryInterface;
     813    /* IHostAudioR3 */
     814    PDMAUDIO_IHOSTAUDIOR3_CALLBACKS(drvAudioVideoRec);
    823815
    824816    /* Get VRDPServer pointer. */
Note: See TracChangeset for help on using the changeset viewer.

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