VirtualBox

Changeset 89504 in vbox


Ignore:
Timestamp:
Jun 4, 2021 11:30:46 AM (3 years ago)
Author:
vboxsync
Message:

Audio: Re-ordering some methods, no real change. bugref:9890

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DrvHostAudioAlsa.cpp

    r89500 r89504  
    939939
    940940/**
     941 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
     942 */
     943static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudAlsaHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
     944                                                                            PPDMAUDIOBACKENDSTREAM pStream)
     945{
     946    RT_NOREF(pInterface);
     947    PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;
     948    AssertPtrReturn(pStreamALSA, PDMHOSTAUDIOSTREAMSTATE_INVALID);
     949
     950    PDMHOSTAUDIOSTREAMSTATE enmStreamState = PDMHOSTAUDIOSTREAMSTATE_OKAY;
     951    snd_pcm_state_t         enmAlsaState   = snd_pcm_state(pStreamALSA->hPCM);
     952    if (enmAlsaState == SND_PCM_STATE_DRAINING)
     953    {
     954        /* We're operating in non-blocking mode, so we must (at least for a demux
     955           config) call snd_pcm_drain again to drive it forward.  Otherwise we
     956           might be stuck in the drain state forever. */
     957        Log5Func(("Calling snd_pcm_drain again...\n"));
     958        snd_pcm_drain(pStreamALSA->hPCM);
     959        enmAlsaState = snd_pcm_state(pStreamALSA->hPCM);
     960    }
     961
     962    if (enmAlsaState == SND_PCM_STATE_DRAINING)
     963        enmStreamState = PDMHOSTAUDIOSTREAMSTATE_DRAINING;
     964#if (((SND_LIB_MAJOR) << 16) | ((SND_LIB_MAJOR) << 8) | (SND_LIB_SUBMINOR)) >= 0x10002 /* was added in 1.0.2 */
     965    else if (enmAlsaState == SND_PCM_STATE_DISCONNECTED)
     966        enmStreamState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING;
     967#endif
     968
     969    Log5Func(("Stream '%s': ALSA state=%s -> %s\n",
     970              pStreamALSA->Cfg.szName, snd_pcm_state_name(enmAlsaState), PDMHostAudioStreamStateGetName(enmStreamState) ));
     971    return enmStreamState;
     972}
     973
     974
     975/**
    941976 * Returns the available audio frames queued.
    942977 *
     
    9861021    *pcFramesAvail = 0;
    9871022    return rc;
    988 }
    989 
    990 
    991 /**
    992  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    993  */
    994 static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    995 {
    996     RT_NOREF(pInterface);
    997     PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;
    998 
    999     uint32_t          cbAvail      = 0;
    1000     snd_pcm_sframes_t cFramesAvail = 0;
    1001     int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail);
    1002     if (RT_SUCCESS(rc))
    1003         cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail);
    1004 
    1005     return cbAvail;
    1006 }
    1007 
    1008 
    1009 /**
    1010  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    1011  */
    1012 static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    1013 {
    1014     RT_NOREF(pInterface);
    1015     PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;
    1016 
    1017     uint32_t          cbAvail      = 0;
    1018     snd_pcm_sframes_t cFramesAvail = 0;
    1019     int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail);
    1020     if (RT_SUCCESS(rc))
    1021         cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail);
    1022 
    1023     return cbAvail;
    10241023}
    10251024
     
    10841083
    10851084/**
    1086  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    1087  */
    1088 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudAlsaHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
    1089                                                                             PPDMAUDIOBACKENDSTREAM pStream)
     1085 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     1086 */
     1087static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    10901088{
    10911089    RT_NOREF(pInterface);
    10921090    PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;
    1093     AssertPtrReturn(pStreamALSA, PDMHOSTAUDIOSTREAMSTATE_INVALID);
    1094 
    1095     PDMHOSTAUDIOSTREAMSTATE enmStreamState = PDMHOSTAUDIOSTREAMSTATE_OKAY;
    1096     snd_pcm_state_t         enmAlsaState   = snd_pcm_state(pStreamALSA->hPCM);
    1097     if (enmAlsaState == SND_PCM_STATE_DRAINING)
    1098     {
    1099         /* We're operating in non-blocking mode, so we must (at least for a demux
    1100            config) call snd_pcm_drain again to drive it forward.  Otherwise we
    1101            might be stuck in the drain state forever. */
    1102         Log5Func(("Calling snd_pcm_drain again...\n"));
    1103         snd_pcm_drain(pStreamALSA->hPCM);
    1104         enmAlsaState = snd_pcm_state(pStreamALSA->hPCM);
    1105     }
    1106 
    1107     if (enmAlsaState == SND_PCM_STATE_DRAINING)
    1108         enmStreamState = PDMHOSTAUDIOSTREAMSTATE_DRAINING;
    1109 #if (((SND_LIB_MAJOR) << 16) | ((SND_LIB_MAJOR) << 8) | (SND_LIB_SUBMINOR)) >= 0x10002 /* was added in 1.0.2 */
    1110     else if (enmAlsaState == SND_PCM_STATE_DISCONNECTED)
    1111         enmStreamState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING;
    1112 #endif
    1113 
    1114     Log5Func(("Stream '%s': ALSA state=%s -> %s\n",
    1115               pStreamALSA->Cfg.szName, snd_pcm_state_name(enmAlsaState), PDMHostAudioStreamStateGetName(enmStreamState) ));
    1116     return enmStreamState;
     1091
     1092    uint32_t          cbAvail      = 0;
     1093    snd_pcm_sframes_t cFramesAvail = 0;
     1094    int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail);
     1095    if (RT_SUCCESS(rc))
     1096        cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail);
     1097
     1098    return cbAvail;
    11171099}
    11181100
     
    12311213    *pcbWritten = 0;
    12321214    return rc;
     1215}
     1216
     1217
     1218/**
     1219 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     1220 */
     1221static DECLCALLBACK(uint32_t) drvHstAudAlsaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1222{
     1223    RT_NOREF(pInterface);
     1224    PDRVHSTAUDALSASTREAM pStreamALSA = (PDRVHSTAUDALSASTREAM)pStream;
     1225
     1226    uint32_t          cbAvail      = 0;
     1227    snd_pcm_sframes_t cFramesAvail = 0;
     1228    int rc = alsaStreamGetAvail(pStreamALSA->hPCM, &cFramesAvail);
     1229    if (RT_SUCCESS(rc))
     1230        cbAvail = PDMAudioPropsFramesToBytes(&pStreamALSA->Cfg.Props, cFramesAvail);
     1231
     1232    return cbAvail;
    12331233}
    12341234
     
    14131413    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    14141414    pThis->IHostAudio.pfnStreamControl              = drvHstAudAlsaHA_StreamControl;
    1415     pThis->IHostAudio.pfnStreamGetReadable          = drvHstAudAlsaHA_StreamGetReadable;
    1416     pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudAlsaHA_StreamGetWritable;
    14171415    pThis->IHostAudio.pfnStreamGetPending           = drvHstAudAlsaHA_StreamGetPending;
    14181416    pThis->IHostAudio.pfnStreamGetState             = drvHstAudAlsaHA_StreamGetState;
     1417    pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudAlsaHA_StreamGetWritable;
    14191418    pThis->IHostAudio.pfnStreamPlay                 = drvHstAudAlsaHA_StreamPlay;
     1419    pThis->IHostAudio.pfnStreamGetReadable          = drvHstAudAlsaHA_StreamGetReadable;
    14201420    pThis->IHostAudio.pfnStreamCapture              = drvHstAudAlsaHA_StreamCapture;
    14211421
  • trunk/src/VBox/Devices/Audio/DrvHostAudioDSound.cpp

    r89500 r89504  
    22282228
    22292229/**
    2230  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    2231  */
    2232 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    2233 {
    2234     /*PDRVHOSTDSOUND  pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio); */ RT_NOREF(pInterface);
    2235     PDSOUNDSTREAM   pStreamDS = (PDSOUNDSTREAM)pStream;
    2236     AssertPtrReturn(pStreamDS, 0);
    2237     Assert(pStreamDS->Cfg.enmDir == PDMAUDIODIR_IN);
    2238 
    2239     if (pStreamDS->fEnabled)
    2240     {
    2241         /* This is the same calculation as for StreamGetPending. */
    2242         AssertPtr(pStreamDS->In.pDSCB);
    2243         DWORD   offCaptureCursor = 0;
    2244         DWORD   offReadCursor    = 0;
    2245         HRESULT hrc = IDirectSoundCaptureBuffer_GetCurrentPosition(pStreamDS->In.pDSCB, &offCaptureCursor, &offReadCursor);
    2246         if (SUCCEEDED(hrc))
    2247         {
    2248             uint32_t cbPending = dsoundRingDistance(offCaptureCursor, offReadCursor, pStreamDS->cbBufSize);
    2249             Log3Func(("cbPending=%RU32\n", cbPending));
    2250             return cbPending;
    2251         }
    2252         AssertMsgFailed(("hrc=%Rhrc\n", hrc));
    2253     }
    2254 
    2255     return 0;
    2256 }
    2257 
    2258 
    2259 /**
    22602230 * Retrieves the number of free bytes available for writing to a DirectSound output stream.
    22612231 *
     
    23392309
    23402310/**
    2341  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    2342  */
    2343 static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    2344 {
    2345     PDRVHOSTDSOUND  pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio);
    2346     PDSOUNDSTREAM   pStreamDS = (PDSOUNDSTREAM)pStream;
    2347     AssertPtrReturn(pStreamDS, 0);
    2348     LogFlowFunc(("Stream '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
    2349 
    2350     DWORD           cbFree    = 0;
    2351     DWORD           offIgn    = 0;
    2352     int rc = dsoundGetFreeOut(pThis, pStreamDS, &cbFree, &offIgn);
    2353     AssertRCReturn(rc, 0);
    2354 
    2355     return cbFree;
     2311 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
     2312 */
     2313static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostDSoundHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
     2314                                                                            PPDMAUDIOBACKENDSTREAM pStream)
     2315{
     2316    RT_NOREF(pInterface);
     2317    PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream;
     2318    AssertPtrReturn(pStreamDS, PDMHOSTAUDIOSTREAMSTATE_INVALID);
     2319
     2320    if (   pStreamDS->Cfg.enmDir != PDMAUDIODIR_OUT
     2321        || !pStreamDS->Out.fDrain)
     2322    {
     2323        LogFlowFunc(("returns OKAY for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
     2324        return PDMHOSTAUDIOSTREAMSTATE_OKAY;
     2325    }
     2326    LogFlowFunc(("returns DRAINING for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
     2327    return PDMHOSTAUDIOSTREAMSTATE_DRAINING;
    23562328}
    23572329
     
    23902362
    23912363/**
    2392  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    2393  */
    2394 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostDSoundHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
    2395                                                                             PPDMAUDIOBACKENDSTREAM pStream)
    2396 {
    2397     RT_NOREF(pInterface);
    2398     PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream;
    2399     AssertPtrReturn(pStreamDS, PDMHOSTAUDIOSTREAMSTATE_INVALID);
    2400 
    2401     if (   pStreamDS->Cfg.enmDir != PDMAUDIODIR_OUT
    2402         || !pStreamDS->Out.fDrain)
    2403     {
    2404         LogFlowFunc(("returns OKAY for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
    2405         return PDMHOSTAUDIOSTREAMSTATE_OKAY;
    2406     }
    2407     LogFlowFunc(("returns DRAINING for '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
    2408     return PDMHOSTAUDIOSTREAMSTATE_DRAINING;
     2364 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     2365 */
     2366static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2367{
     2368    PDRVHOSTDSOUND  pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio);
     2369    PDSOUNDSTREAM   pStreamDS = (PDSOUNDSTREAM)pStream;
     2370    AssertPtrReturn(pStreamDS, 0);
     2371    LogFlowFunc(("Stream '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
     2372
     2373    DWORD           cbFree    = 0;
     2374    DWORD           offIgn    = 0;
     2375    int rc = dsoundGetFreeOut(pThis, pStreamDS, &cbFree, &offIgn);
     2376    AssertRCReturn(rc, 0);
     2377
     2378    return cbFree;
    24092379}
    24102380
     
    25332503
    25342504    return VINF_SUCCESS;
     2505}
     2506
     2507
     2508/**
     2509 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     2510 */
     2511static DECLCALLBACK(uint32_t) drvHostDSoundHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2512{
     2513    /*PDRVHOSTDSOUND  pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio); */ RT_NOREF(pInterface);
     2514    PDSOUNDSTREAM   pStreamDS = (PDSOUNDSTREAM)pStream;
     2515    AssertPtrReturn(pStreamDS, 0);
     2516    Assert(pStreamDS->Cfg.enmDir == PDMAUDIODIR_IN);
     2517
     2518    if (pStreamDS->fEnabled)
     2519    {
     2520        /* This is the same calculation as for StreamGetPending. */
     2521        AssertPtr(pStreamDS->In.pDSCB);
     2522        DWORD   offCaptureCursor = 0;
     2523        DWORD   offReadCursor    = 0;
     2524        HRESULT hrc = IDirectSoundCaptureBuffer_GetCurrentPosition(pStreamDS->In.pDSCB, &offCaptureCursor, &offReadCursor);
     2525        if (SUCCEEDED(hrc))
     2526        {
     2527            uint32_t cbPending = dsoundRingDistance(offCaptureCursor, offReadCursor, pStreamDS->cbBufSize);
     2528            Log3Func(("cbPending=%RU32\n", cbPending));
     2529            return cbPending;
     2530        }
     2531        AssertMsgFailed(("hrc=%Rhrc\n", hrc));
     2532    }
     2533
     2534    return 0;
    25352535}
    25362536
     
    27732773    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    27742774    pThis->IHostAudio.pfnStreamControl              = drvHostDSoundHA_StreamControl;
     2775    pThis->IHostAudio.pfnStreamGetState             = drvHostDSoundHA_StreamGetState;
     2776    pThis->IHostAudio.pfnStreamGetPending           = NULL;
     2777    pThis->IHostAudio.pfnStreamGetWritable          = drvHostDSoundHA_StreamGetWritable;
     2778    pThis->IHostAudio.pfnStreamPlay                 = drvHostDSoundHA_StreamPlay;
    27752779    pThis->IHostAudio.pfnStreamGetReadable          = drvHostDSoundHA_StreamGetReadable;
    2776     pThis->IHostAudio.pfnStreamGetWritable          = drvHostDSoundHA_StreamGetWritable;
    2777     pThis->IHostAudio.pfnStreamGetPending           = NULL;
    2778     pThis->IHostAudio.pfnStreamGetState             = drvHostDSoundHA_StreamGetState;
    2779     pThis->IHostAudio.pfnStreamPlay                 = drvHostDSoundHA_StreamPlay;
    27802780    pThis->IHostAudio.pfnStreamCapture              = drvHostDSoundHA_StreamCapture;
    27812781
  • trunk/src/VBox/Devices/Audio/DrvHostAudioDebug.cpp

    r89487 r89504  
    193193
    194194/**
    195  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    196  */
    197 static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    198 {
    199     RT_NOREF(pInterface);
    200     PDRVHSTAUDDEBUGSTREAM pStreamDbg = (PDRVHSTAUDDEBUGSTREAM)pStream;
    201 
    202     return PDMAudioPropsMilliToBytes(&pStreamDbg->Cfg.Props, 10 /*ms*/);
     195 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
     196 */
     197static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudDebugHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
     198                                                                             PPDMAUDIOBACKENDSTREAM pStream)
     199{
     200    RT_NOREF(pInterface);
     201    AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);
     202    return PDMHOSTAUDIOSTREAMSTATE_OKAY;
     203}
     204
     205
     206/**
     207 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}
     208 */
     209static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     210{
     211    RT_NOREF(pInterface, pStream);
     212    return 0;
    203213}
    204214
     
    211221    RT_NOREF(pInterface, pStream);
    212222    return UINT32_MAX;
    213 }
    214 
    215 
    216 /**
    217  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}
    218  */
    219 static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    220 {
    221     RT_NOREF(pInterface, pStream);
    222     return 0;
    223 }
    224 
    225 
    226 /**
    227  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    228  */
    229 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHstAudDebugHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
    230                                                                              PPDMAUDIOBACKENDSTREAM pStream)
    231 {
    232     RT_NOREF(pInterface);
    233     AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);
    234     return PDMHOSTAUDIOSTREAMSTATE_OKAY;
    235223}
    236224
     
    251239        LogRelMax(32, ("DebugAudio: Writing output failed with %Rrc\n", rc));
    252240    return rc;
     241}
     242
     243
     244/**
     245 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     246 */
     247static DECLCALLBACK(uint32_t) drvHstAudDebugHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     248{
     249    RT_NOREF(pInterface);
     250    PDRVHSTAUDDEBUGSTREAM pStreamDbg = (PDRVHSTAUDDEBUGSTREAM)pStream;
     251
     252    return PDMAudioPropsMilliToBytes(&pStreamDbg->Cfg.Props, 10 /*ms*/);
    253253}
    254254
     
    327327    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    328328    pThis->IHostAudio.pfnStreamControl              = drvHstAudDebugHA_StreamControl;
     329    pThis->IHostAudio.pfnStreamGetState             = drvHstAudDebugHA_StreamGetState;
     330    pThis->IHostAudio.pfnStreamGetPending           = drvHstAudDebugHA_StreamGetPending;
     331    pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudDebugHA_StreamGetWritable;
     332    pThis->IHostAudio.pfnStreamPlay                 = drvHstAudDebugHA_StreamPlay;
    329333    pThis->IHostAudio.pfnStreamGetReadable          = drvHstAudDebugHA_StreamGetReadable;
    330     pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudDebugHA_StreamGetWritable;
    331     pThis->IHostAudio.pfnStreamGetPending           = drvHstAudDebugHA_StreamGetPending;
    332     pThis->IHostAudio.pfnStreamGetState             = drvHstAudDebugHA_StreamGetState;
    333     pThis->IHostAudio.pfnStreamPlay                 = drvHstAudDebugHA_StreamPlay;
    334334    pThis->IHostAudio.pfnStreamCapture              = drvHstAudDebugHA_StreamCapture;
    335335
  • trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp

    r89489 r89504  
    150150
    151151/**
    152  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    153  */
    154 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    155 {
    156     RT_NOREF(pInterface, pStream);
    157     /** @todo rate limit this?   */
    158     return UINT32_MAX;
    159 }
    160 
    161 
    162 /**
    163  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    164  */
    165 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    166 {
    167     RT_NOREF(pInterface, pStream);
    168     return UINT32_MAX;
    169 }
    170 
    171 
    172 /**
    173  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}
    174  */
    175 static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    176 {
    177     RT_NOREF(pInterface, pStream);
    178     return 0;
    179 }
    180 
    181 
    182 /**
    183152 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    184153 */
     
    199168
    200169/**
     170 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetPending}
     171 */
     172static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetPending(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     173{
     174    RT_NOREF(pInterface, pStream);
     175    return 0;
     176}
     177
     178
     179/**
     180 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     181 */
     182static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     183{
     184    RT_NOREF(pInterface, pStream);
     185    return UINT32_MAX;
     186}
     187
     188
     189/**
    201190 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
    202191 */
     
    209198    *pcbWritten = cbBuf;
    210199    return VINF_SUCCESS;
     200}
     201
     202
     203/**
     204 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     205 */
     206static DECLCALLBACK(uint32_t) drvHstAudNullHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     207{
     208    RT_NOREF(pInterface, pStream);
     209    /** @todo rate limit this?   */
     210    return UINT32_MAX;
    211211}
    212212
  • trunk/src/VBox/Devices/Audio/DrvHostAudioOss.cpp

    r89487 r89504  
    677677
    678678/**
    679  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    680  */
    681 static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    682 {
    683     RT_NOREF(pInterface, pStream);
    684     Log4Func(("returns UINT32_MAX\n"));
    685     return UINT32_MAX;
    686 }
    687 
    688 
    689 /**
    690  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    691  */
    692 static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    693 {
    694     RT_NOREF(pInterface);
    695     PDRVHSTAUDOSSSTREAM pStreamOSS = (PDRVHSTAUDOSSSTREAM)pStream;
    696     AssertPtr(pStreamOSS);
    697 
    698     /*
    699      * Note! This logic was found in StreamPlay and corrected a little.
    700      *
    701      * The logic here must match what StreamPlay does.
    702      */
    703     audio_buf_info BufInfo = { 0, 0, 0, 0 };
    704     int rc2 = ioctl(pStreamOSS->hFile, SNDCTL_DSP_GETOSPACE, &BufInfo);
    705     AssertMsgReturn(rc2 >= 0, ("SNDCTL_DSP_GETOSPACE failed: %s (%d)\n", strerror(errno), errno), 0);
    706 
    707 #if 0 /** @todo we could return BufInfo.bytes here iff StreamPlay didn't use the fragmented approach */
    708     /** @todo r=bird: WTF do we make a fuss over BufInfo.bytes for when we don't
    709      *        even use it?!? */
    710     AssertLogRelMsgReturn(BufInfo.bytes >= 0, ("OSS: Warning: Invalid available size: %d\n", BufInfo.bytes), VERR_INTERNAL_ERROR_3);
    711     if ((unsigned)BufInfo.bytes > cbBuf)
    712     {
    713         LogRel2(("OSS: Warning: Too big output size (%d > %RU32), limiting to %RU32\n", BufInfo.bytes, cbBuf, cbBuf));
    714         BufInfo.bytes = cbBuf;
    715         /* Keep going. */
    716     }
    717 #endif
    718 
    719     uint32_t cbRet = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);
    720     Log4Func(("returns %#x (%u)\n", cbRet, cbRet));
    721     return cbRet;
    722 }
    723 
    724 
    725 /**
    726679 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    727680 */
     
    739692
    740693/**
     694 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     695 */
     696static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     697{
     698    RT_NOREF(pInterface);
     699    PDRVHSTAUDOSSSTREAM pStreamOSS = (PDRVHSTAUDOSSSTREAM)pStream;
     700    AssertPtr(pStreamOSS);
     701
     702    /*
     703     * Note! This logic was found in StreamPlay and corrected a little.
     704     *
     705     * The logic here must match what StreamPlay does.
     706     */
     707    audio_buf_info BufInfo = { 0, 0, 0, 0 };
     708    int rc2 = ioctl(pStreamOSS->hFile, SNDCTL_DSP_GETOSPACE, &BufInfo);
     709    AssertMsgReturn(rc2 >= 0, ("SNDCTL_DSP_GETOSPACE failed: %s (%d)\n", strerror(errno), errno), 0);
     710
     711#if 0 /** @todo we could return BufInfo.bytes here iff StreamPlay didn't use the fragmented approach */
     712    /** @todo r=bird: WTF do we make a fuss over BufInfo.bytes for when we don't
     713     *        even use it?!? */
     714    AssertLogRelMsgReturn(BufInfo.bytes >= 0, ("OSS: Warning: Invalid available size: %d\n", BufInfo.bytes), VERR_INTERNAL_ERROR_3);
     715    if ((unsigned)BufInfo.bytes > cbBuf)
     716    {
     717        LogRel2(("OSS: Warning: Too big output size (%d > %RU32), limiting to %RU32\n", BufInfo.bytes, cbBuf, cbBuf));
     718        BufInfo.bytes = cbBuf;
     719        /* Keep going. */
     720    }
     721#endif
     722
     723    uint32_t cbRet = (uint32_t)(BufInfo.fragments * BufInfo.fragsize);
     724    Log4Func(("returns %#x (%u)\n", cbRet, cbRet));
     725    return cbRet;
     726}
     727
     728
     729/**
    741730 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
    742731 */
     
    820809    *pcbWritten = offChunk;
    821810    return VINF_SUCCESS;
     811}
     812
     813
     814/**
     815 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     816 */
     817static DECLCALLBACK(uint32_t) drvHstAudOssHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     818{
     819    RT_NOREF(pInterface, pStream);
     820    Log4Func(("returns UINT32_MAX\n"));
     821    return UINT32_MAX;
    822822}
    823823
     
    913913    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    914914    pThis->IHostAudio.pfnStreamControl              = drvHstAudOssHA_StreamControl;
     915    pThis->IHostAudio.pfnStreamGetState             = drvHstAudOssHA_StreamGetState;
     916    pThis->IHostAudio.pfnStreamGetPending           = NULL;
     917    pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudOssHA_StreamGetWritable;
     918    pThis->IHostAudio.pfnStreamPlay                 = drvHstAudOssHA_StreamPlay;
    915919    pThis->IHostAudio.pfnStreamGetReadable          = drvHstAudOssHA_StreamGetReadable;
    916     pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudOssHA_StreamGetWritable;
    917     pThis->IHostAudio.pfnStreamGetPending           = NULL;
    918     pThis->IHostAudio.pfnStreamGetState             = drvHstAudOssHA_StreamGetState;
    919     pThis->IHostAudio.pfnStreamPlay                 = drvHstAudOssHA_StreamPlay;
    920920    pThis->IHostAudio.pfnStreamCapture              = drvHstAudOssHA_StreamCapture;
    921921
  • trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp

    r89500 r89504  
    15901590
    15911591/**
    1592  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    1593  */
    1594 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    1595 {
    1596     PDRVHSTAUDPA        pThis      = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio);
    1597     PDRVHSTAUDPASTREAM  pStreamPA  = (PDRVHSTAUDPASTREAM)pStream;
    1598     uint32_t            cbReadable = 0;
    1599     if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_IN)
    1600     {
    1601         pa_threaded_mainloop_lock(pThis->pMainLoop);
    1602 
    1603         pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream);
    1604         if (PA_STREAM_IS_GOOD(enmState))
    1605         {
    1606             size_t cbReadablePa = pa_stream_readable_size(pStreamPA->pStream);
    1607             if (cbReadablePa != (size_t)-1)
    1608                 cbReadable = (uint32_t)cbReadablePa;
    1609             else
    1610                 drvHstAudPaError(pThis, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName);
    1611         }
    1612         else
    1613             LogFunc(("non-good stream state: %d\n", enmState));
    1614 
    1615         pa_threaded_mainloop_unlock(pThis->pMainLoop);
    1616     }
    1617     Log3Func(("returns %#x (%u)\n", cbReadable, cbReadable));
    1618     return cbReadable;
    1619 }
    1620 
    1621 
    1622 /**
    1623  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    1624  */
    1625 static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    1626 {
    1627     PDRVHSTAUDPA        pThis      = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio);
    1628     PDRVHSTAUDPASTREAM  pStreamPA  = (PDRVHSTAUDPASTREAM)pStream;
    1629     uint32_t            cbWritable = 0;
    1630     if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_OUT)
    1631     {
    1632         pa_threaded_mainloop_lock(pThis->pMainLoop);
    1633 
    1634         pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream);
    1635         if (PA_STREAM_IS_GOOD(enmState))
    1636         {
    1637             size_t cbWritablePa = pa_stream_writable_size(pStreamPA->pStream);
    1638             if (cbWritablePa != (size_t)-1)
    1639                 cbWritable = cbWritablePa <= UINT32_MAX ? (uint32_t)cbWritablePa : UINT32_MAX;
    1640             else
    1641                 drvHstAudPaError(pThis, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName);
    1642         }
    1643         else
    1644             LogFunc(("non-good stream state: %d\n", enmState));
    1645 
    1646         pa_threaded_mainloop_unlock(pThis->pMainLoop);
    1647     }
    1648     Log3Func(("returns %#x (%u) [max=%#RX32 min=%#RX32]\n",
    1649               cbWritable, cbWritable, pStreamPA->BufAttr.maxlength, pStreamPA->BufAttr.minreq));
    1650     return cbWritable;
    1651 }
    1652 
    1653 
    1654 /**
    16551592 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    16561593 */
     
    16991636
    17001637/**
     1638 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     1639 */
     1640static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1641{
     1642    PDRVHSTAUDPA        pThis      = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio);
     1643    PDRVHSTAUDPASTREAM  pStreamPA  = (PDRVHSTAUDPASTREAM)pStream;
     1644    uint32_t            cbWritable = 0;
     1645    if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_OUT)
     1646    {
     1647        pa_threaded_mainloop_lock(pThis->pMainLoop);
     1648
     1649        pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream);
     1650        if (PA_STREAM_IS_GOOD(enmState))
     1651        {
     1652            size_t cbWritablePa = pa_stream_writable_size(pStreamPA->pStream);
     1653            if (cbWritablePa != (size_t)-1)
     1654                cbWritable = cbWritablePa <= UINT32_MAX ? (uint32_t)cbWritablePa : UINT32_MAX;
     1655            else
     1656                drvHstAudPaError(pThis, "pa_stream_writable_size failed on '%s'", pStreamPA->Cfg.szName);
     1657        }
     1658        else
     1659            LogFunc(("non-good stream state: %d\n", enmState));
     1660
     1661        pa_threaded_mainloop_unlock(pThis->pMainLoop);
     1662    }
     1663    Log3Func(("returns %#x (%u) [max=%#RX32 min=%#RX32]\n",
     1664              cbWritable, cbWritable, pStreamPA->BufAttr.maxlength, pStreamPA->BufAttr.minreq));
     1665    return cbWritable;
     1666}
     1667
     1668
     1669/**
    17011670 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
    17021671 */
     
    17741743    Log3Func(("returns %Rrc *pcbWritten=%#x iLoop=%u\n", rc, cbTotalWritten, iLoop));
    17751744    return rc;
     1745}
     1746
     1747
     1748/**
     1749 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     1750 */
     1751static DECLCALLBACK(uint32_t) drvHstAudPaHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1752{
     1753    PDRVHSTAUDPA        pThis      = RT_FROM_MEMBER(pInterface, DRVHSTAUDPA, IHostAudio);
     1754    PDRVHSTAUDPASTREAM  pStreamPA  = (PDRVHSTAUDPASTREAM)pStream;
     1755    uint32_t            cbReadable = 0;
     1756    if (pStreamPA->Cfg.enmDir == PDMAUDIODIR_IN)
     1757    {
     1758        pa_threaded_mainloop_lock(pThis->pMainLoop);
     1759
     1760        pa_stream_state_t const enmState = pa_stream_get_state(pStreamPA->pStream);
     1761        if (PA_STREAM_IS_GOOD(enmState))
     1762        {
     1763            size_t cbReadablePa = pa_stream_readable_size(pStreamPA->pStream);
     1764            if (cbReadablePa != (size_t)-1)
     1765                cbReadable = (uint32_t)cbReadablePa;
     1766            else
     1767                drvHstAudPaError(pThis, "pa_stream_readable_size failed on '%s'", pStreamPA->Cfg.szName);
     1768        }
     1769        else
     1770            LogFunc(("non-good stream state: %d\n", enmState));
     1771
     1772        pa_threaded_mainloop_unlock(pThis->pMainLoop);
     1773    }
     1774    Log3Func(("returns %#x (%u)\n", cbReadable, cbReadable));
     1775    return cbReadable;
    17761776}
    17771777
     
    20432043    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    20442044    pThis->IHostAudio.pfnStreamControl              = drvHstAudPaHA_StreamControl;
     2045    pThis->IHostAudio.pfnStreamGetState             = drvHstAudPaHA_StreamGetState;
     2046    pThis->IHostAudio.pfnStreamGetPending           = NULL;
     2047    pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudPaHA_StreamGetWritable;
     2048    pThis->IHostAudio.pfnStreamPlay                 = drvHstAudPaHA_StreamPlay;
    20452049    pThis->IHostAudio.pfnStreamGetReadable          = drvHstAudPaHA_StreamGetReadable;
    2046     pThis->IHostAudio.pfnStreamGetWritable          = drvHstAudPaHA_StreamGetWritable;
    2047     pThis->IHostAudio.pfnStreamGetPending           = NULL;
    2048     pThis->IHostAudio.pfnStreamGetState             = drvHstAudPaHA_StreamGetState;
    2049     pThis->IHostAudio.pfnStreamPlay                 = drvHstAudPaHA_StreamPlay;
    20502050    pThis->IHostAudio.pfnStreamCapture              = drvHstAudPaHA_StreamCapture;
    20512051
  • trunk/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp

    r89500 r89504  
    23752375
    23762376/**
    2377  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    2378  */
    2379 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2377 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
     2378 */
     2379static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAudioWasHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
     2380                                                                              PPDMAUDIOBACKENDSTREAM pStream)
    23802381{
    23812382    RT_NOREF(pInterface);
    23822383    PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream;
    2383     AssertPtrReturn(pStreamWas, 0);
    2384     Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_IN);
    2385 
    2386     uint32_t cbReadable = 0;
    2387     RTCritSectEnter(&pStreamWas->CritSect);
    2388 
    2389     if (pStreamWas->pDevCfg->pIAudioCaptureClient /* paranoia */)
    2390     {
    2391         UINT32  cFramesPending = 0;
    2392         HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending);
    2393         if (SUCCEEDED(hrc))
    2394         {
    2395             /* An unreleased buffer is included in the pending frame count, so subtract
    2396                whatever we've got hanging around since the previous pfnStreamCapture call. */
    2397             AssertMsgStmt(cFramesPending >= pStreamWas->cFramesCaptureToRelease,
    2398                           ("%#x vs %#x\n", cFramesPending, pStreamWas->cFramesCaptureToRelease),
    2399                           cFramesPending = pStreamWas->cFramesCaptureToRelease);
    2400             cFramesPending -= pStreamWas->cFramesCaptureToRelease;
    2401 
    2402             /* Add what we've got left in said buffer. */
    2403             uint32_t cFramesCurPacket = PDMAudioPropsBytesToFrames(&pStreamWas->Cfg.Props, pStreamWas->cbCapture);
    2404             cFramesPending += cFramesCurPacket;
    2405 
    2406             /* Paranoia: Make sure we don't exceed the buffer size. */
    2407             AssertMsgStmt(cFramesPending <= pStreamWas->Cfg.Backend.cFramesBufferSize,
    2408                           ("cFramesPending=%#x cFramesCaptureToRelease=%#x cFramesCurPacket=%#x cFramesBufferSize=%#x\n",
    2409                            cFramesPending, pStreamWas->cFramesCaptureToRelease, cFramesCurPacket,
    2410                            pStreamWas->Cfg.Backend.cFramesBufferSize),
    2411                           cFramesPending = pStreamWas->Cfg.Backend.cFramesBufferSize);
    2412 
    2413             cbReadable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props, cFramesPending);
    2414         }
     2384    AssertPtrReturn(pStreamWas, PDMHOSTAUDIOSTREAMSTATE_INVALID);
     2385
     2386    PDMHOSTAUDIOSTREAMSTATE enmState;
     2387    AssertPtr(pStreamWas->pDevCfg);
     2388    if (pStreamWas->pDevCfg /*paranoia*/)
     2389    {
     2390        if (RT_SUCCESS(pStreamWas->pDevCfg->rcSetup))
     2391        {
     2392            if (!pStreamWas->fDraining)
     2393                enmState = PDMHOSTAUDIOSTREAMSTATE_OKAY;
     2394            else
     2395            {
     2396                Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT);
     2397                enmState = PDMHOSTAUDIOSTREAMSTATE_DRAINING;
     2398            }
     2399        }
     2400        else if (   pStreamWas->pDevCfg->rcSetup == VERR_AUDIO_STREAM_INIT_IN_PROGRESS
     2401                 || pStreamWas->fSwitchingDevice )
     2402            enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING;
    24152403        else
    2416             LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc));
    2417     }
    2418 
    2419     RTCritSectLeave(&pStreamWas->CritSect);
    2420 
    2421     LogFlowFunc(("returns %#x (%u) {%s}\n", cbReadable, cbReadable, drvHostWasStreamStatusString(pStreamWas)));
    2422     return cbReadable;
    2423 }
    2424 
    2425 
    2426 /**
    2427  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    2428  */
    2429 static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    2430 {
    2431     RT_NOREF(pInterface);
    2432     PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream;
    2433     AssertPtrReturn(pStreamWas, 0);
    2434     LogFlowFunc(("Stream '%s' {%s}\n", pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas)));
    2435     Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT);
    2436 
    2437     uint32_t cbWritable = 0;
    2438     RTCritSectEnter(&pStreamWas->CritSect);
    2439 
    2440     if (   pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT
    2441         && pStreamWas->pDevCfg->pIAudioClient /* paranoia */)
    2442     {
    2443         UINT32  cFramesPending = 0;
    2444         HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending);
    2445         if (SUCCEEDED(hrc))
    2446         {
    2447             if (cFramesPending < pStreamWas->Cfg.Backend.cFramesBufferSize)
    2448                 cbWritable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props,
    2449                                                         pStreamWas->Cfg.Backend.cFramesBufferSize - cFramesPending);
    2450             else if (cFramesPending > pStreamWas->Cfg.Backend.cFramesBufferSize)
    2451             {
    2452                 LogRelMax(64, ("WasAPI: Warning! GetCurrentPadding('%s') return too high: cFramesPending=%#x > cFramesBufferSize=%#x\n",
    2453                                pStreamWas->Cfg.szName, cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize));
    2454                 AssertMsgFailed(("cFramesPending=%#x > cFramesBufferSize=%#x\n",
    2455                                  cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize));
    2456             }
    2457         }
    2458         else
    2459             LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc));
    2460     }
    2461 
    2462     RTCritSectLeave(&pStreamWas->CritSect);
    2463 
    2464     LogFlowFunc(("returns %#x (%u) {%s}\n", cbWritable, cbWritable, drvHostWasStreamStatusString(pStreamWas)));
    2465     return cbWritable;
     2404            enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING;
     2405    }
     2406    else if (pStreamWas->fSwitchingDevice)
     2407        enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING;
     2408    else
     2409        enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING;
     2410
     2411    LogFlowFunc(("returns %d for '%s' {%s}\n", enmState, pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas)));
     2412    return enmState;
    24662413}
    24672414
     
    25082455
    25092456/**
    2510  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    2511  */
    2512 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvHostAudioWasHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
    2513                                                                               PPDMAUDIOBACKENDSTREAM pStream)
     2457 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     2458 */
     2459static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    25142460{
    25152461    RT_NOREF(pInterface);
    25162462    PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream;
    2517     AssertPtrReturn(pStreamWas, PDMHOSTAUDIOSTREAMSTATE_INVALID);
    2518 
    2519     PDMHOSTAUDIOSTREAMSTATE enmState;
    2520     AssertPtr(pStreamWas->pDevCfg);
    2521     if (pStreamWas->pDevCfg /*paranoia*/)
    2522     {
    2523         if (RT_SUCCESS(pStreamWas->pDevCfg->rcSetup))
    2524         {
    2525             if (!pStreamWas->fDraining)
    2526                 enmState = PDMHOSTAUDIOSTREAMSTATE_OKAY;
    2527             else
     2463    AssertPtrReturn(pStreamWas, 0);
     2464    LogFlowFunc(("Stream '%s' {%s}\n", pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas)));
     2465    Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT);
     2466
     2467    uint32_t cbWritable = 0;
     2468    RTCritSectEnter(&pStreamWas->CritSect);
     2469
     2470    if (   pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT
     2471        && pStreamWas->pDevCfg->pIAudioClient /* paranoia */)
     2472    {
     2473        UINT32  cFramesPending = 0;
     2474        HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending);
     2475        if (SUCCEEDED(hrc))
     2476        {
     2477            if (cFramesPending < pStreamWas->Cfg.Backend.cFramesBufferSize)
     2478                cbWritable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props,
     2479                                                        pStreamWas->Cfg.Backend.cFramesBufferSize - cFramesPending);
     2480            else if (cFramesPending > pStreamWas->Cfg.Backend.cFramesBufferSize)
    25282481            {
    2529                 Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_OUT);
    2530                 enmState = PDMHOSTAUDIOSTREAMSTATE_DRAINING;
     2482                LogRelMax(64, ("WasAPI: Warning! GetCurrentPadding('%s') return too high: cFramesPending=%#x > cFramesBufferSize=%#x\n",
     2483                               pStreamWas->Cfg.szName, cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize));
     2484                AssertMsgFailed(("cFramesPending=%#x > cFramesBufferSize=%#x\n",
     2485                                 cFramesPending, pStreamWas->Cfg.Backend.cFramesBufferSize));
    25312486            }
    25322487        }
    2533         else if (   pStreamWas->pDevCfg->rcSetup == VERR_AUDIO_STREAM_INIT_IN_PROGRESS
    2534                  || pStreamWas->fSwitchingDevice )
    2535             enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING;
    25362488        else
    2537             enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING;
    2538     }
    2539     else if (pStreamWas->fSwitchingDevice)
    2540         enmState = PDMHOSTAUDIOSTREAMSTATE_INITIALIZING;
    2541     else
    2542         enmState = PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING;
    2543 
    2544     LogFlowFunc(("returns %d for '%s' {%s}\n", enmState, pStreamWas->Cfg.szName, drvHostWasStreamStatusString(pStreamWas)));
    2545     return enmState;
     2489            LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc));
     2490    }
     2491
     2492    RTCritSectLeave(&pStreamWas->CritSect);
     2493
     2494    LogFlowFunc(("returns %#x (%u) {%s}\n", cbWritable, cbWritable, drvHostWasStreamStatusString(pStreamWas)));
     2495    return cbWritable;
    25462496}
    25472497
     
    27022652                 msPrev ? msNow - msPrev : 0, msPrev, pStreamWas->msLastTransfer, drvHostWasStreamStatusString(pStreamWas) ));
    27032653    return rc;
     2654}
     2655
     2656
     2657/**
     2658 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     2659 */
     2660static DECLCALLBACK(uint32_t) drvHostAudioWasHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2661{
     2662    RT_NOREF(pInterface);
     2663    PDRVHOSTAUDIOWASSTREAM pStreamWas = (PDRVHOSTAUDIOWASSTREAM)pStream;
     2664    AssertPtrReturn(pStreamWas, 0);
     2665    Assert(pStreamWas->Cfg.enmDir == PDMAUDIODIR_IN);
     2666
     2667    uint32_t cbReadable = 0;
     2668    RTCritSectEnter(&pStreamWas->CritSect);
     2669
     2670    if (pStreamWas->pDevCfg->pIAudioCaptureClient /* paranoia */)
     2671    {
     2672        UINT32  cFramesPending = 0;
     2673        HRESULT hrc = pStreamWas->pDevCfg->pIAudioClient->GetCurrentPadding(&cFramesPending);
     2674        if (SUCCEEDED(hrc))
     2675        {
     2676            /* An unreleased buffer is included in the pending frame count, so subtract
     2677               whatever we've got hanging around since the previous pfnStreamCapture call. */
     2678            AssertMsgStmt(cFramesPending >= pStreamWas->cFramesCaptureToRelease,
     2679                          ("%#x vs %#x\n", cFramesPending, pStreamWas->cFramesCaptureToRelease),
     2680                          cFramesPending = pStreamWas->cFramesCaptureToRelease);
     2681            cFramesPending -= pStreamWas->cFramesCaptureToRelease;
     2682
     2683            /* Add what we've got left in said buffer. */
     2684            uint32_t cFramesCurPacket = PDMAudioPropsBytesToFrames(&pStreamWas->Cfg.Props, pStreamWas->cbCapture);
     2685            cFramesPending += cFramesCurPacket;
     2686
     2687            /* Paranoia: Make sure we don't exceed the buffer size. */
     2688            AssertMsgStmt(cFramesPending <= pStreamWas->Cfg.Backend.cFramesBufferSize,
     2689                          ("cFramesPending=%#x cFramesCaptureToRelease=%#x cFramesCurPacket=%#x cFramesBufferSize=%#x\n",
     2690                           cFramesPending, pStreamWas->cFramesCaptureToRelease, cFramesCurPacket,
     2691                           pStreamWas->Cfg.Backend.cFramesBufferSize),
     2692                          cFramesPending = pStreamWas->Cfg.Backend.cFramesBufferSize);
     2693
     2694            cbReadable = PDMAudioPropsFramesToBytes(&pStreamWas->Cfg.Props, cFramesPending);
     2695        }
     2696        else
     2697            LogRelMax(64, ("WasAPI: GetCurrentPadding failed on '%s': %Rhrc\n", pStreamWas->Cfg.szName, hrc));
     2698    }
     2699
     2700    RTCritSectLeave(&pStreamWas->CritSect);
     2701
     2702    LogFlowFunc(("returns %#x (%u) {%s}\n", cbReadable, cbReadable, drvHostWasStreamStatusString(pStreamWas)));
     2703    return cbReadable;
    27042704}
    27052705
     
    30303030    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = drvHostAudioWasHA_StreamNotifyDeviceChanged;
    30313031    pThis->IHostAudio.pfnStreamControl              = drvHostAudioWasHA_StreamControl;
     3032    pThis->IHostAudio.pfnStreamGetState             = drvHostAudioWasHA_StreamGetState;
     3033    pThis->IHostAudio.pfnStreamGetPending           = drvHostAudioWasHA_StreamGetPending;
     3034    pThis->IHostAudio.pfnStreamGetWritable          = drvHostAudioWasHA_StreamGetWritable;
     3035    pThis->IHostAudio.pfnStreamPlay                 = drvHostAudioWasHA_StreamPlay;
    30323036    pThis->IHostAudio.pfnStreamGetReadable          = drvHostAudioWasHA_StreamGetReadable;
    3033     pThis->IHostAudio.pfnStreamGetWritable          = drvHostAudioWasHA_StreamGetWritable;
    3034     pThis->IHostAudio.pfnStreamGetPending           = drvHostAudioWasHA_StreamGetPending;
    3035     pThis->IHostAudio.pfnStreamGetState             = drvHostAudioWasHA_StreamGetState;
    3036     pThis->IHostAudio.pfnStreamPlay                 = drvHostAudioWasHA_StreamPlay;
    30373037    pThis->IHostAudio.pfnStreamCapture              = drvHostAudioWasHA_StreamCapture;
    30383038
  • trunk/src/VBox/Main/src-client/DrvAudioRec.cpp

    r89487 r89504  
    592592
    593593/**
    594  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    595  */
    596 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    597 {
    598     RT_NOREF(pInterface, pStream);
    599     return 0; /* Video capturing does not provide any input. */
    600 }
    601 
    602 
    603 /**
    604  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
    605  */
    606 static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    607 {
    608     RT_NOREF(pInterface, pStream);
    609     return UINT32_MAX;
    610 }
    611 
    612 
    613 /**
    614594 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    615595 */
     
    620600    AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);
    621601    return PDMHOSTAUDIOSTREAMSTATE_OKAY;
     602}
     603
     604
     605/**
     606 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     607 */
     608static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     609{
     610    RT_NOREF(pInterface, pStream);
     611    return UINT32_MAX;
    622612}
    623613
     
    791781    LogFlowFunc(("csReadTotal=%RU32, rc=%Rrc\n", cbWrittenTotal, rc));
    792782    return rc;
     783}
     784
     785
     786/**
     787 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     788 */
     789static DECLCALLBACK(uint32_t) drvAudioVideoRecHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     790{
     791    RT_NOREF(pInterface, pStream);
     792    return 0; /* Video capturing does not provide any input. */
    793793}
    794794
     
    11151115    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    11161116    pThis->IHostAudio.pfnStreamControl              = drvAudioVideoRecHA_StreamControl;
     1117    pThis->IHostAudio.pfnStreamGetState             = drvAudioVideoRecHA_StreamGetState;
     1118    pThis->IHostAudio.pfnStreamGetPending           = NULL;
     1119    pThis->IHostAudio.pfnStreamGetWritable          = drvAudioVideoRecHA_StreamGetWritable;
     1120    pThis->IHostAudio.pfnStreamPlay                 = drvAudioVideoRecHA_StreamPlay;
    11171121    pThis->IHostAudio.pfnStreamGetReadable          = drvAudioVideoRecHA_StreamGetReadable;
    1118     pThis->IHostAudio.pfnStreamGetWritable          = drvAudioVideoRecHA_StreamGetWritable;
    1119     pThis->IHostAudio.pfnStreamGetPending           = NULL;
    1120     pThis->IHostAudio.pfnStreamGetState             = drvAudioVideoRecHA_StreamGetState;
    1121     pThis->IHostAudio.pfnStreamPlay                 = drvAudioVideoRecHA_StreamPlay;
    11221122    pThis->IHostAudio.pfnStreamCapture              = drvAudioVideoRecHA_StreamCapture;
    11231123
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r89489 r89504  
    557557
    558558/**
    559  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
    560  */
    561 static DECLCALLBACK(uint32_t) drvAudioVrdeHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    562 {
    563     RT_NOREF(pInterface);
    564     PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream;
    565 
    566     if (pStreamVRDE->Cfg.enmDir == PDMAUDIODIR_IN)
    567     {
    568         /* Return frames instead of bytes here
    569          * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */
    570         return PDMAudioPropsBytesToFrames(&pStreamVRDE->Cfg.Props, (uint32_t)RTCircBufUsed(pStreamVRDE->In.pCircBuf));
    571     }
    572     return 0;
     559 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
     560 */
     561static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvAudioVrdeHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
     562                                                                           PPDMAUDIOBACKENDSTREAM pStream)
     563{
     564    PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
     565    AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);
     566
     567    return pDrv->cClients > 0 ? PDMHOSTAUDIOSTREAMSTATE_OKAY : PDMHOSTAUDIOSTREAMSTATE_INACTIVE;
    573568}
    574569
     
    586581        return _16K * sizeof(int64_t) * 2;
    587582    return 0;
    588 }
    589 
    590 
    591 /**
    592  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetState}
    593  */
    594 static DECLCALLBACK(PDMHOSTAUDIOSTREAMSTATE) drvAudioVrdeHA_StreamGetState(PPDMIHOSTAUDIO pInterface,
    595                                                                            PPDMAUDIOBACKENDSTREAM pStream)
    596 {
    597     PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio);
    598     AssertPtrReturn(pStream, PDMHOSTAUDIOSTREAMSTATE_INVALID);
    599 
    600     return pDrv->cClients > 0 ? PDMHOSTAUDIOSTREAMSTATE_OKAY : PDMHOSTAUDIOSTREAMSTATE_INACTIVE;
    601583}
    602584
     
    641623    Assert(*pcbWritten == cbBuf);
    642624    return VINF_SUCCESS;
     625}
     626
     627
     628/**
     629 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     630 */
     631static DECLCALLBACK(uint32_t) drvAudioVrdeHA_StreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     632{
     633    RT_NOREF(pInterface);
     634    PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream;
     635
     636    if (pStreamVRDE->Cfg.enmDir == PDMAUDIODIR_IN)
     637    {
     638        /* Return frames instead of bytes here
     639         * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */
     640        return PDMAudioPropsBytesToFrames(&pStreamVRDE->Cfg.Props, (uint32_t)RTCircBufUsed(pStreamVRDE->In.pCircBuf));
     641    }
     642    return 0;
    643643}
    644644
     
    777777    pThis->IHostAudio.pfnStreamNotifyDeviceChanged  = NULL;
    778778    pThis->IHostAudio.pfnStreamControl              = drvAudioVrdeHA_StreamControl;
     779    pThis->IHostAudio.pfnStreamGetState             = drvAudioVrdeHA_StreamGetState;
     780    pThis->IHostAudio.pfnStreamGetPending           = NULL;
     781    pThis->IHostAudio.pfnStreamGetWritable          = drvAudioVrdeHA_StreamGetWritable;
     782    pThis->IHostAudio.pfnStreamPlay                 = drvAudioVrdeHA_StreamPlay;
    779783    pThis->IHostAudio.pfnStreamGetReadable          = drvAudioVrdeHA_StreamGetReadable;
    780     pThis->IHostAudio.pfnStreamGetWritable          = drvAudioVrdeHA_StreamGetWritable;
    781     pThis->IHostAudio.pfnStreamGetPending           = NULL;
    782     pThis->IHostAudio.pfnStreamGetState             = drvAudioVrdeHA_StreamGetState;
    783     pThis->IHostAudio.pfnStreamPlay                 = drvAudioVrdeHA_StreamPlay;
    784784    pThis->IHostAudio.pfnStreamCapture              = drvAudioVrdeHA_StreamCapture;
    785785
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