VirtualBox

Changeset 65694 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Feb 9, 2017 11:15:06 AM (8 years ago)
Author:
vboxsync
Message:

Audio: Removed PDMAUDIOSTRMSTS_FLAG_DATA_READABLE / PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE and added IHostAudio::pfnStreamGetReadable() and IHostAudio::pfnStreamGetWritable() instead.

Split up drvAudioStreamPlay() into drvAudioStreamPlayNonInterleaved() and drvAudioStreamPlayRaw() for handling different audio data layouts.

Location:
trunk/src/VBox/Devices/Audio
Files:
11 edited

Legend:

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

    r65669 r65694  
    143143 * This will get the raw sample data out of a mixing buffer.
    144144 *
    145  * @return  IPRT status code. VINF_TRY_AGAIN for getting next pointer at beginning (circular).
     145 * @return  IPRT status code or VINF_AUDIO_MORE_DATA_AVAILABLE if more data is available to read.
     146 *
    146147 * @param   pMixBuf                 Mixing buffer to acquire audio samples from.
    147148 * @param   cSamplesToRead          Number of audio samples to read.
     
    173174    {
    174175        cRead = pMixBuf->cSamples - pMixBuf->offRead;
    175         rc = VINF_TRY_AGAIN;
     176        rc = VINF_AUDIO_MORE_DATA_AVAILABLE;
    176177    }
    177178    else
     
    184185    {
    185186        cRead = cSampleBuf;
    186         rc = VINF_TRY_AGAIN;
     187        rc = VINF_AUDIO_MORE_DATA_AVAILABLE;
    187188    }
    188189
     
    193194        pMixBuf->offRead = (pMixBuf->offRead + cRead) % pMixBuf->cSamples;
    194195        Assert(pMixBuf->offRead <= pMixBuf->cSamples);
    195         pMixBuf->cUsed -= RT_MIN(cRead, pMixBuf->cUsed);
     196        pMixBuf->cUsed  -= RT_MIN(cRead, pMixBuf->cUsed);
    196197    }
    197198
  • trunk/src/VBox/Devices/Audio/AudioMixer.cpp

    r65624 r65694  
    11241124        cbRead = RT_MAX(cbRead, cbTotalRead);
    11251125
    1126         PDMAUDIOSTRMSTS strmSts = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream);
     1126        uint32_t cbReadable = pMixStream->pConn->pfnStreamGetReadable(pMixStream->pConn, pMixStream->pStream);
    11271127
    11281128        /* Still some data available? Then sink is not clean (yet). */
    1129         if (strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE)
     1129        if (cbReadable)
    11301130            fClean = false;
    11311131    }
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r65660 r65694  
    172172        APPEND_FLAG_TO_STR(PAUSED         );
    173173        APPEND_FLAG_TO_STR(PENDING_DISABLE);
    174         APPEND_FLAG_TO_STR(DATA_READABLE  );
    175         APPEND_FLAG_TO_STR(DATA_WRITABLE  );
    176174        APPEND_FLAG_TO_STR(PENDING_REINIT );
    177175    } while (0);
     
    12541252
    12551253/**
     1254 * Plays an audio host output stream which has been configured for non-interleaved (layout) data.
     1255 *
     1256 * @return  IPRT status code.
     1257 * @param   pThis               Pointer to driver instance.
     1258 * @param   pHstStream          Host stream to play.
     1259 * @param   csToPlay            Number of audio samples to play.
     1260 * @param   pcsPlayed           Returns number of audio samples played. Optional.
     1261 */
     1262static int drvAudioStreamPlayNonInterleaved(PDRVAUDIO pThis,
     1263                                            PPDMAUDIOSTREAM pHstStream, uint32_t csToPlay, uint32_t *pcsPlayed)
     1264{
     1265    AssertPtrReturn(pThis,      VERR_INVALID_POINTER);
     1266    AssertPtrReturn(pHstStream, VERR_INVALID_POINTER);
     1267    /* pcsPlayed is optional. */
     1268
     1269    /* Sanity. */
     1270    Assert(pHstStream->enmCtx == PDMAUDIOSTREAMCTX_HOST);
     1271    Assert(pHstStream->enmDir == PDMAUDIODIR_OUT);
     1272    Assert(pHstStream->Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED);
     1273
     1274    if (!csToPlay)
     1275    {
     1276        if (pcsPlayed)
     1277            *pcsPlayed = 0;
     1278        return VINF_SUCCESS;
     1279    }
     1280
     1281    int rc = VINF_SUCCESS;
     1282
     1283    uint32_t csPlayed = 0;
     1284
     1285    AssertPtr(pThis->pHostDrvAudio->pfnStreamGetWritable);
     1286    uint32_t cbWritable = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pHstStream->pvBackend);
     1287    if (cbWritable)
     1288    {
     1289        if (csToPlay > AUDIOMIXBUF_B2S(&pHstStream->MixBuf, cbWritable)) /* More samples available than we can write? Limit. */
     1290            csToPlay = AUDIOMIXBUF_B2S(&pHstStream->MixBuf, cbWritable);
     1291
     1292        if (csToPlay)
     1293        {
     1294            uint8_t u8Buf[_4K]; /** @todo Get rid of this here. */
     1295            AssertReleaseReturn(sizeof(u8Buf) >= AUDIOMIXBUF_S2B(&pHstStream->MixBuf, csToPlay), /** @todo Get rid of this here. */
     1296                                VERR_BUFFER_OVERFLOW);
     1297
     1298            uint32_t csRead = 0;
     1299            rc = AudioMixBufReadCirc(&pHstStream->MixBuf, u8Buf, AUDIOMIXBUF_S2B(&pHstStream->MixBuf, csToPlay), &csRead);
     1300            if (RT_SUCCESS(rc))
     1301            {
     1302                uint32_t cbPlayed;
     1303
     1304                AssertPtr(pThis->pHostDrvAudio->pfnStreamPlay);
     1305                rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream->pvBackend,
     1306                                                         u8Buf, AUDIOMIXBUF_S2B(&pHstStream->MixBuf, csRead),
     1307                                                         &cbPlayed);
     1308                if (RT_SUCCESS(rc))
     1309                {
     1310                    AssertMsg(cbPlayed % 2 == 0,
     1311                              ("Backend for stream '%s' returned uneven played bytes count (csRead=%RU32, cbPlayed=%RU32)\n",
     1312                               pHstStream->szName, csRead, cbPlayed));
     1313
     1314                    csPlayed = AUDIOMIXBUF_B2S(&pHstStream->MixBuf, cbPlayed);
     1315                }
     1316            }
     1317        }
     1318    }
     1319
     1320    Log3Func(("Played %RU32/%RU32 samples, rc=%Rrc\n", csPlayed, csToPlay, rc));
     1321
     1322    if (pcsPlayed)
     1323        *pcsPlayed = csPlayed;
     1324
     1325    return rc;
     1326}
     1327
     1328/**
     1329 * Plays an audio host output stream which has been configured for raw audio (layout) data.
     1330 *
     1331 * @return  IPRT status code.
     1332 * @param   pThis               Pointer to driver instance.
     1333 * @param   pHstStream          Host stream to play.
     1334 * @param   csToPlay            Number of audio samples to play.
     1335 * @param   pcsPlayed           Returns number of audio samples played. Optional.
     1336 */
     1337static int drvAudioStreamPlayRaw(PDRVAUDIO pThis,
     1338                                 PPDMAUDIOSTREAM pHstStream, uint32_t csToPlay, uint32_t *pcsPlayed)
     1339{
     1340    AssertPtrReturn(pThis,      VERR_INVALID_POINTER);
     1341    AssertPtrReturn(pHstStream, VERR_INVALID_POINTER);
     1342    /* pcsPlayed is optional. */
     1343
     1344    /* Sanity. */
     1345    Assert(pHstStream->enmCtx == PDMAUDIOSTREAMCTX_HOST);
     1346    Assert(pHstStream->enmDir == PDMAUDIODIR_OUT);
     1347    Assert(pHstStream->Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_RAW);
     1348
     1349    if (!csToPlay)
     1350    {
     1351        if (pcsPlayed)
     1352            *pcsPlayed = 0;
     1353        return VINF_SUCCESS;
     1354    }
     1355
     1356    int rc = VINF_SUCCESS;
     1357
     1358    uint32_t csPlayed = 0;
     1359
     1360    AssertPtr(pThis->pHostDrvAudio->pfnStreamGetWritable);
     1361    uint32_t csWritable = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, pHstStream->pvBackend);
     1362    if (csWritable)
     1363    {
     1364        if (csToPlay > csWritable) /* More samples available than we can write? Limit. */
     1365            csToPlay = csWritable;
     1366
     1367        PDMAUDIOSAMPLE aSampleBuf[256]; /** @todo Get rid of this here. */
     1368
     1369        uint32_t csLeft = csToPlay;
     1370        while (csLeft)
     1371        {
     1372            uint32_t csRead = 0;
     1373            rc = AudioMixBufPeek(&pHstStream->MixBuf, csLeft, aSampleBuf,
     1374                                 RT_MIN(csLeft, RT_ELEMENTS(aSampleBuf)), &csRead);
     1375
     1376            if (   RT_SUCCESS(rc)
     1377                && csRead)
     1378            {
     1379                uint32_t csPlayedChunk;
     1380
     1381                Assert(csRead <= RT_ELEMENTS(aSampleBuf));
     1382                rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream->pvBackend,
     1383                                                         aSampleBuf, csRead, &csPlayedChunk);
     1384                if (RT_FAILURE(rc))
     1385                    break;
     1386
     1387                csPlayed += csPlayedChunk;
     1388                Assert(csPlayed <= csToPlay);
     1389
     1390                Assert(csLeft >= csRead);
     1391                csLeft        -= csRead;
     1392            }
     1393            else if (RT_FAILURE(rc))
     1394                break;
     1395        }
     1396    }
     1397
     1398    Log3Func(("Played %RU32/%RU32 samples, rc=%Rrc\n", csPlayed, csToPlay, rc));
     1399
     1400    if (pcsPlayed)
     1401        *pcsPlayed = csPlayed;
     1402
     1403    return rc;
     1404}
     1405
     1406/**
    12561407 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamPlay}
    12571408 */
     
    12731424               pStream->szName, pStream->enmDir));
    12741425
    1275     uint32_t csPlayed = 0;
     1426    uint32_t csPlayedTotal = 0;
    12761427
    12771428    do
     
    12971448                                  rc = VERR_NOT_AVAILABLE);
    12981449
     1450        /*
     1451         * Check if the backend is ready to operate.
     1452         */
     1453
    12991454        AssertPtr(pThis->pHostDrvAudio->pfnStreamGetStatus);
    1300 
    1301         uint32_t csLive = AudioMixBufUsed(&pHstStream->MixBuf);
    1302 
    13031455        PDMAUDIOSTRMSTS stsBackend = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream->pvBackend);
    1304 
    13051456#ifdef LOG_ENABLED
    13061457        char *pszBackendSts = dbgAudioStreamStatusToStr(stsBackend);
    1307         Log3Func(("[%s] Start: stsBackend=%s, csLive=%RU32\n", pHstStream->szName, pszBackendSts, csLive));
     1458        Log3Func(("[%s] Start: stsBackend=%s\n", pHstStream->szName, pszBackendSts));
    13081459        RTStrFree(pszBackendSts);
    13091460#endif /* LOG_ENABLED */
    1310 
    1311         if (   csLive
    1312             && (stsBackend & PDMAUDIOSTRMSTS_FLAG_ENABLED)
    1313             && (stsBackend & PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE))
    1314         {
    1315             uint32_t cbPlayed = 0;
    1316 
    1317             AssertPtr(pThis->pHostDrvAudio->pfnStreamPlay);
    1318 
    1319             if (RT_LIKELY(pHstStream->Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED))
    1320             {
    1321                 uint8_t u8Buf[_4K]; /** @todo Get rid of this here. */
    1322 
    1323                 uint32_t csRead = 0;
    1324                 int rc2 = AudioMixBufReadCirc(&pHstStream->MixBuf, u8Buf, sizeof(u8Buf), &csRead);
    1325                 AssertRC(rc2);
    1326 
    1327                 rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream->pvBackend,
    1328                                                          u8Buf, AUDIOMIXBUF_S2B(&pHstStream->MixBuf, csRead),
    1329                                                          &cbPlayed);
    1330                 AssertMsg(cbPlayed % 2 == 0,
    1331                           ("Backend for stream '%s' returned uneven played bytes count (csRead=%RU32, cbPlayed=%RU32)\n",
    1332                            pHstStream->szName, csRead, cbPlayed));
    1333 
    1334                 csPlayed = AUDIOMIXBUF_B2S(&pHstStream->MixBuf, cbPlayed);
    1335             }
    1336             else if (pHstStream->Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_RAW)
    1337             {
    1338                 PDMAUDIOSAMPLE aSampleBuf[128]; /** @todo Get rid of this here. */
    1339 
    1340                 uint32_t csRead = 0;
    1341                 int rc2 = AudioMixBufPeek(&pHstStream->MixBuf, csLive, aSampleBuf,
    1342                                           RT_MIN(csLive, RT_ELEMENTS(aSampleBuf)), &csRead);
    1343                 AssertRC(rc2);
    1344 
    1345                 Assert(csRead <= RT_ELEMENTS(aSampleBuf));
    1346 
    1347                 rc = pThis->pHostDrvAudio->pfnStreamPlay(pThis->pHostDrvAudio, pHstStream->pvBackend,
    1348                                                          aSampleBuf, csRead, &csPlayed);
    1349             }
    1350             else
    1351                 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
    1352 
    1353             if (RT_SUCCESS(rc))
    1354             {
    1355                 AudioMixBufFinish(&pHstStream->MixBuf, csPlayed);
     1461        if (!(stsBackend & PDMAUDIOSTRMSTS_FLAG_ENABLED)) /* Backend disabled? Bail out. */
     1462            break;
     1463
     1464        uint32_t csToPlay = AudioMixBufLive(&pHstStream->MixBuf);
     1465
     1466        if (RT_LIKELY(pHstStream->Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED))
     1467        {
     1468            rc = drvAudioStreamPlayNonInterleaved(pThis, pHstStream, csToPlay, &csPlayedTotal);
     1469        }
     1470        else if (pHstStream->Cfg.enmLayout == PDMAUDIOSTREAMLAYOUT_RAW)
     1471        {
     1472            rc = drvAudioStreamPlayRaw(pThis, pHstStream, csToPlay, &csPlayedTotal);
     1473        }
     1474        else
     1475            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     1476
     1477        uint32_t csLive = 0;
     1478
     1479        if (RT_SUCCESS(rc))
     1480        {
     1481            AudioMixBufFinish(&pHstStream->MixBuf, csPlayedTotal);
    13561482
    13571483#ifdef VBOX_WITH_STATISTICS
    1358                 STAM_COUNTER_ADD(&pThis->Stats.TotalSamplesOut, csPlayed);
    1359                 STAM_PROFILE_ADV_STOP(&pThis->Stats.DelayOut, out);
    1360                 STAM_COUNTER_ADD(&pHstStream->Out.StatSamplesPlayed, csPlayed);
    1361 #endif
    1362                 csLive = AudioMixBufUsed(&pHstStream->MixBuf);
    1363             }
     1484            STAM_COUNTER_ADD(&pThis->Stats.TotalSamplesOut, csPlayedTotal);
     1485            STAM_PROFILE_ADV_STOP(&pThis->Stats.DelayOut, out);
     1486            STAM_COUNTER_ADD(&pHstStream->Out.StatSamplesPlayed, csPlayedTotal);
     1487#endif
     1488            csLive = AudioMixBufLive(&pHstStream->MixBuf);
    13641489        }
    13651490
    13661491#ifdef LOG_ENABLED
    13671492        pszBackendSts = dbgAudioStreamStatusToStr(stsBackend);
    1368         Log3Func(("[%s] End: stsBackend=%s, csLive=%RU32, csPlayed=%RU32, rc=%Rrc\n",
    1369                   pHstStream->szName, pszBackendSts, csLive, csPlayed, rc));
     1493        Log3Func(("[%s] End: stsBackend=%s, csLive=%RU32, csPlayedTotal=%RU32, rc=%Rrc\n",
     1494                  pHstStream->szName, pszBackendSts, csLive, csPlayedTotal, rc));
    13701495        RTStrFree(pszBackendSts);
    13711496#endif /* LOG_ENABLED */
     
    13971522    {
    13981523        if (pcSamplesPlayed)
    1399             *pcSamplesPlayed = csPlayed;
     1524            *pcSamplesPlayed = csPlayedTotal;
    14001525    }
    14011526
     
    14401565                                  rc = VERR_NOT_AVAILABLE);
    14411566
     1567        /*
     1568         * Check if the backend is ready to operate.
     1569         */
     1570
    14421571        AssertPtr(pThis->pHostDrvAudio->pfnStreamGetStatus);
    14431572        PDMAUDIOSTRMSTS stsBackend = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream->pvBackend);
    1444 
    1445         uint32_t csLive = AudioMixBufLive(&pGstStream->MixBuf);
    1446         if (!csLive)
    1447         {
    1448             if (   (stsBackend & PDMAUDIOSTRMSTS_FLAG_ENABLED)
    1449                 && (stsBackend & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE))
     1573#ifdef LOG_ENABLED
     1574        char *pszBackendSts = dbgAudioStreamStatusToStr(stsBackend);
     1575        Log3Func(("[%s] Start: stsBackend=%s\n", pHstStream->szName, pszBackendSts));
     1576        RTStrFree(pszBackendSts);
     1577#endif /* LOG_ENABLED */
     1578        if (!(stsBackend & PDMAUDIOSTRMSTS_FLAG_ENABLED)) /* Backend disabled? Bail out. */
     1579            break;
     1580
     1581        /*
     1582         * Check how much audio data the backend has captured so far.
     1583         */
     1584
     1585        AssertPtr(pThis->pHostDrvAudio->pfnStreamGetReadable);
     1586        uint32_t cbReadable = pThis->pHostDrvAudio->pfnStreamGetReadable(pThis->pHostDrvAudio, pHstStream->pvBackend);
     1587        if (!cbReadable) /* Nothing captured? Bail out. */
     1588            break;
     1589
     1590        /*
     1591         * Check if we have space and limit.
     1592         */
     1593
     1594        uint32_t csFree = AudioMixBufFree(&pHstStream->MixBuf);
     1595        if (csFree)
     1596            break;
     1597
     1598        if (csFree < AUDIOMIXBUF_B2S(&pHstStream->MixBuf, cbReadable)) /* More data captured than we can read? */
     1599        {
     1600            /** @todo Warn? */
     1601        }
     1602
     1603        uint8_t  auBuf[_1K]; /** @todo Get rid of this. */
     1604
     1605        uint32_t cbCaptured;
     1606        rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream->pvBackend,
     1607                                                    auBuf, sizeof(auBuf), &cbCaptured);
     1608        if (RT_FAILURE(rc))
     1609        {
     1610            int rc2 = drvAudioStreamControlInternalBackend(pThis, pHstStream, PDMAUDIOSTREAMCMD_DISABLE);
     1611            AssertRC(rc2);
     1612        }
     1613        else
     1614        {
     1615            Assert(cbCaptured <= sizeof(auBuf));
     1616            rc = AudioMixBufWriteCirc(&pHstStream->MixBuf, auBuf, cbCaptured, &csCaptured);
     1617            if (RT_SUCCESS(rc))
    14501618            {
    1451                 uint8_t  auBuf[_1K];
    1452                 uint32_t cbCaptured;
    1453 
    1454                 rc = pThis->pHostDrvAudio->pfnStreamCapture(pThis->pHostDrvAudio, pHstStream->pvBackend,
    1455                                                             auBuf, sizeof(auBuf), &cbCaptured);
    1456                 if (RT_FAILURE(rc))
    1457                 {
    1458                     int rc2 = drvAudioStreamControlInternalBackend(pThis, pHstStream, PDMAUDIOSTREAMCMD_DISABLE);
    1459                     AssertRC(rc2);
    1460                 }
    1461                 else
    1462                 {
    1463                     Assert(cbCaptured <= sizeof(auBuf));
    1464                     rc = AudioMixBufWriteCirc(&pHstStream->MixBuf, auBuf, cbCaptured, &csCaptured);
    1465                     if (RT_SUCCESS(rc))
    1466                     {
    14671619#ifdef VBOX_WITH_STATISTICS
    1468                         STAM_COUNTER_ADD(&pThis->Stats.TotalSamplesIn,        csCaptured);
    1469                         STAM_COUNTER_ADD(&pHstStream->In.StatSamplesCaptured, csCaptured);
    1470 #endif
    1471                         Log3Func(("[%s] %RU32 samples captured\n", pHstStream->szName, csCaptured));
    1472                     }
    1473                 }
     1620                STAM_COUNTER_ADD(&pThis->Stats.TotalSamplesIn,        csCaptured);
     1621                STAM_COUNTER_ADD(&pHstStream->In.StatSamplesCaptured, csCaptured);
     1622#endif
     1623                Log3Func(("[%s] %RU32 samples captured\n", pHstStream->szName, csCaptured));
    14741624            }
    1475 #ifdef LOG_ENABLED
    1476             else
    1477             {
    1478                 char *pszHstSts = dbgAudioStreamStatusToStr(stsBackend);
    1479                 Log3Func(("[%s] Skipping (backend status %s)\n", pHstStream->szName, pszHstSts));
    1480                 RTStrFree(pszHstSts);
    1481             }
    1482 #endif
    1483         }
    1484         else
    1485             Log3Func(("[%s] Skipping (still has %RU32 live samples)\n", pHstStream->szName, csLive));
     1625        }
    14861626
    14871627    } while (0);
  • trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp

    r65624 r65694  
    255255
    256256        case SND_PCM_FORMAT_U32_LE:
    257             pProps->cBits       = 32;
    258             pProps->fSigned     = false;
     257            pProps->cBits   = 32;
     258            pProps->fSigned = false;
    259259            break;
    260260
     
    280280    }
    281281
     282    Assert(pProps->cBits);
    282283    Assert(pProps->cChannels);
    283284    pProps->cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pProps->cBits, pProps->cChannels);
     
    895896{
    896897    AssertPtrReturn(phPCM, VERR_INVALID_POINTER);
    897     AssertPtrReturn(pFramesAvail, VERR_INVALID_POINTER);
     898    /* pFramesAvail is optional. */
    898899
    899900    int rc;
     
    914915        rc = VINF_SUCCESS;
    915916
    916     if (framesAvail >= 0)
    917         *pFramesAvail = framesAvail;
     917    if (RT_SUCCESS(rc))
     918    {
     919        if (pFramesAvail)
     920            *pFramesAvail = framesAvail;
     921    }
    918922
    919923    return rc;
     
    10031007 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
    10041008 */
    1005 static DECLCALLBACK(int) drvHostALSAAudioStreamCapture(PPDMIHOSTAUDIO pInterface,
    1006                                                        PPDMAUDIOBACKENDSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)
     1009static DECLCALLBACK(int) drvHostALSAAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     1010                                                       void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)
    10071011{
    10081012    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    11401144    }
    11411145
    1142     LogFlowFuncLeaveRC(rc);
    11431146    return rc;
    11441147}
     
    11581161    PALSAAUDIOSTREAM pStreamALSA = (PALSAAUDIOSTREAM)pStream;
    11591162
    1160     int rc = VINF_SUCCESS;
     1163    PPDMAUDIOSTREAMCFG pCfg = pStreamALSA->pCfg;
     1164    AssertPtr(pCfg);
     1165
     1166    int rc;
    11611167
    11621168    uint32_t cbWrittenTotal = 0;
     
    11751181            break;
    11761182
    1177         PPDMAUDIOSTREAMCFG pCfg = pStreamALSA->pCfg;
    1178         AssertPtr(pCfg);
    1179 
    1180         size_t cbToWrite = RT_MIN((unsigned)PDMAUDIOSTREAMCFG_S2B(pCfg, csAvail), RT_MIN(pStreamALSA->cbBuf, cbBuf));
     1183        size_t cbToWrite = RT_MIN((unsigned)PDMAUDIOSTREAMCFG_S2B(pCfg, csAvail), pStreamALSA->cbBuf);
    11811184        if (!cbToWrite)
    11821185            break;
    11831186
     1187        /* Do not write more than available. */
     1188        if (cbToWrite > cbBuf)
     1189            cbToWrite = cbBuf;
     1190
     1191        Assert(cbToWrite % 2 == 0);
    11841192        memcpy(pStreamALSA->pvBuf, pvBuf, cbToWrite);
    11851193
     
    12441252            break;
    12451253
    1246         cbWrittenTotal += cbToWrite;
     1254        cbWrittenTotal = PDMAUDIOSTREAMCFG_S2B(pCfg, csWritten);
    12471255
    12481256    } while (0);
     
    12541262    }
    12551263
    1256     LogFlowFuncLeaveRC(rc);
    12571264    return rc;
    12581265}
     
    13211328        AssertBreakStmt(cbBuf, rc = VERR_INVALID_PARAMETER);
    13221329
    1323         pStreamALSA->pvBuf = RTMemAlloc(cbBuf);
     1330        pStreamALSA->pvBuf = RTMemAllocZ(cbBuf);
    13241331        if (!pStreamALSA->pvBuf)
    13251332        {
     
    16251632
    16261633/**
     1634 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     1635 */
     1636static DECLCALLBACK(uint32_t) drvHostALSAAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1637{
     1638    RT_NOREF(pInterface);
     1639
     1640    PALSAAUDIOSTREAM pStreamALSA = (PALSAAUDIOSTREAM)pStream;
     1641
     1642    uint32_t cbAvail = 0;
     1643
     1644    snd_pcm_sframes_t cFramesAvail;
     1645    int rc = alsaStreamGetAvail(pStreamALSA->phPCM, &cFramesAvail);
     1646    if (RT_SUCCESS(rc))
     1647        cbAvail = PDMAUDIOSTREAMCFG_S2B(pStreamALSA->pCfg, cFramesAvail);
     1648
     1649    return cbAvail;
     1650}
     1651
     1652
     1653/**
     1654 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     1655 */
     1656static DECLCALLBACK(uint32_t) drvHostALSAAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1657{
     1658    RT_NOREF(pInterface);
     1659
     1660    PALSAAUDIOSTREAM pStreamALSA = (PALSAAUDIOSTREAM)pStream;
     1661
     1662    uint32_t cbAvail = 0;
     1663
     1664    snd_pcm_sframes_t cFramesAvail;
     1665    int rc = alsaStreamGetAvail(pStreamALSA->phPCM, &cFramesAvail);
     1666    if (   RT_SUCCESS(rc)
     1667        && cFramesAvail >= pStreamALSA->Out.cSamplesMin)
     1668    {
     1669        cbAvail = PDMAUDIOSTREAMCFG_S2B(pStreamALSA->pCfg, cFramesAvail);
     1670    }
     1671
     1672    return cbAvail;
     1673}
     1674
     1675
     1676/**
    16271677 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    16281678 */
    16291679static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostALSAAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    16301680{
    1631     RT_NOREF(pInterface);
    1632 
    1633     PALSAAUDIOSTREAM pStreamALSA = (PALSAAUDIOSTREAM)pStream;
    1634 
    1635     PDMAUDIOSTRMSTS strmSts =   PDMAUDIOSTRMSTS_FLAG_INITIALIZED
    1636                               | PDMAUDIOSTRMSTS_FLAG_ENABLED;
    1637 
    1638     snd_pcm_t         *phPCM       = pStreamALSA->phPCM;
    1639     snd_pcm_sframes_t  cSamplesMin = 0;
    1640 
    1641     if (pStreamALSA->pCfg->enmDir == PDMAUDIODIR_OUT)
    1642         cSamplesMin = pStreamALSA->Out.cSamplesMin;
    1643 
    1644     if (phPCM)
    1645     {
    1646         snd_pcm_sframes_t cSamplesAvail;
    1647         int rc2 = alsaStreamGetAvail(phPCM, &cSamplesAvail);
    1648         if (RT_SUCCESS(rc2))
    1649         {
    1650             Log3Func(("cAvail=%ld \n", cSamplesAvail));
    1651             if (cSamplesAvail >= cSamplesMin)
    1652                 strmSts |= pStreamALSA->pCfg->enmDir == PDMAUDIODIR_IN
    1653                          ? PDMAUDIOSTRMSTS_FLAG_DATA_READABLE
    1654                          : PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;
    1655         }
    1656     }
    1657 
    1658     return strmSts;
     1681    RT_NOREF(pInterface, pStream);
     1682
     1683    return (PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED);
    16591684}
    16601685
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r65624 r65694  
    24132413
    24142414/**
    2415  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    2416  */
    2417 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostCoreAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2415 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     2416 */
     2417static DECLCALLBACK(uint32_t) drvHostCoreAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    24182418{
    24192419    RT_NOREF(pInterface);
     
    24222422    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pStream;
    24232423
     2424    return   (ASMAtomicReadU32(&pCAStream->enmStatus) == COREAUDIOSTATUS_INIT)
     2425           ? UINT32_MAX : 0;
     2426}
     2427
     2428
     2429/**
     2430 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     2431 */
     2432static DECLCALLBACK(uint32_t) drvHostCoreAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2433{
     2434    RT_NOREF(pInterface);
     2435    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     2436
     2437    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pStream;
     2438
     2439    return   (ASMAtomicReadU32(&pCAStream->enmStatus) == COREAUDIOSTATUS_INIT)
     2440           ? UINT32_MAX : 0;
     2441}
     2442
     2443
     2444/**
     2445 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
     2446 */
     2447static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostCoreAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2448{
     2449    RT_NOREF(pInterface);
     2450    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     2451
     2452    PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pStream;
     2453
    24242454    PDMAUDIOSTRMSTS strmSts = PDMAUDIOSTRMSTS_FLAG_NONE;
    24252455
     
    24292459    if (ASMAtomicReadU32(&pCAStream->enmStatus) == COREAUDIOSTATUS_INIT)
    24302460        strmSts |= PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED;
    2431 
    2432     if (pCAStream->pCfg->enmDir == PDMAUDIODIR_IN)
    2433     {
    2434         if (strmSts & PDMAUDIOSTRMSTS_FLAG_ENABLED)
    2435             strmSts |= PDMAUDIOSTRMSTS_FLAG_DATA_READABLE;
    2436     }
    2437     else if (pCAStream->pCfg->enmDir == PDMAUDIODIR_OUT)
    2438     {
    2439         if (strmSts & PDMAUDIOSTRMSTS_FLAG_ENABLED)
    2440             strmSts |= PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;
    2441     }
    2442     else
    2443         AssertFailed();
    24442461
    24452462    return strmSts;
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r65676 r65694  
    22582258
    22592259/**
    2260  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    2261  */
    2262 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDSoundStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    2263 {
     2260 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     2261 */
     2262static DECLCALLBACK(uint32_t) drvHostDSoundStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2263{
     2264    RT_NOREF(pInterface);
     2265    AssertPtrReturn(pStream, PDMAUDIOSTRMSTS_FLAG_NONE);
     2266
     2267    PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream;
     2268
     2269    if (pStreamDS->In.fEnabled)
     2270        return UINT32_MAX;
     2271
     2272    return 0;
     2273}
     2274
     2275
     2276/**
     2277 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     2278 */
     2279static DECLCALLBACK(uint32_t) drvHostDSoundStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2280{
     2281    RT_NOREF(pInterface, pStream);
     2282
    22642283    AssertPtrReturn(pInterface, PDMAUDIOSTRMSTS_FLAG_NONE);
    22652284    AssertPtrReturn(pStream,    PDMAUDIOSTRMSTS_FLAG_NONE);
     
    22682287    PDSOUNDSTREAM  pStreamDS = (PDSOUNDSTREAM)pStream;
    22692288
     2289    if (pStreamDS->Out.fEnabled)
     2290    {
     2291        DWORD cbFree;
     2292        int rc = dsoundGetPosOut(pThis, pStreamDS, NULL /* cbBuffer */, &cbFree, NULL /* cbPlayPos */);
     2293        if (   RT_SUCCESS(rc)
     2294            && cbFree)
     2295        {
     2296            Log3Func(("cbFree=%ld\n", cbFree));
     2297            return (uint32_t)cbFree;
     2298        }
     2299    }
     2300
     2301    return 0;
     2302}
     2303
     2304
     2305/**
     2306 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
     2307 */
     2308static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDSoundStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     2309{
     2310    RT_NOREF(pInterface);
     2311    AssertPtrReturn(pStream, PDMAUDIOSTRMSTS_FLAG_NONE);
     2312
     2313    PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream;
     2314
    22702315    if (!pStreamDS->pCfg) /* Not (yet) configured? Skip. */
    22712316        return PDMAUDIOSTRMSTS_FLAG_NONE;
     
    22752320    {
    22762321        if (pStreamDS->In.fEnabled)
    2277             strmSts |= PDMAUDIOSTRMSTS_FLAG_ENABLED | PDMAUDIOSTRMSTS_FLAG_DATA_READABLE;
     2322            strmSts |= PDMAUDIOSTRMSTS_FLAG_ENABLED;
    22782323    }
    22792324    else
    22802325    {
    22812326        if (pStreamDS->Out.fEnabled)
    2282         {
    22832327            strmSts |= PDMAUDIOSTRMSTS_FLAG_ENABLED;
    2284 
    2285             DWORD cbFree;
    2286             int rc = dsoundGetPosOut(pThis, pStreamDS, NULL /* cbBuffer */, &cbFree, NULL /* cbPlayPos */);
    2287             if (   RT_SUCCESS(rc)
    2288                 && cbFree)
    2289             {
    2290                 LogFlowFunc(("cbFree=%ld\n", cbFree));
    2291                 strmSts |= PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;
    2292             }
    2293         }
    22942328    }
    22952329
  • trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp

    r65624 r65694  
    334334
    335335
     336/**
     337 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
     338 */
    336339static DECLCALLBACK(int) drvHostDebugAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    337340{
     
    359362}
    360363
     364
     365/**
     366 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
     367 */
    361368static DECLCALLBACK(int) drvHostDebugAudioStreamControl(PPDMIHOSTAUDIO pInterface,
    362369                                                        PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
     
    369376}
    370377
     378
     379/**
     380 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     381 */
     382static DECLCALLBACK(uint32_t) drvHostDebugAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     383{
     384    RT_NOREF(pInterface, pStream);
     385
     386    return UINT32_MAX;
     387}
     388
     389
     390/**
     391 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     392 */
     393static DECLCALLBACK(uint32_t) drvHostDebugAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     394{
     395    RT_NOREF(pInterface, pStream);
     396
     397    return UINT32_MAX;
     398}
     399
     400
     401/**
     402 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     403 */
    371404static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDebugAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    372405{
    373406    RT_NOREF(pInterface, pStream);
    374407
    375     return (  PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED
    376             | PDMAUDIOSTRMSTS_FLAG_DATA_READABLE | PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE);
    377 }
    378 
     408    return (PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED);
     409}
     410
     411
     412/**
     413 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
     414 */
    379415static DECLCALLBACK(int) drvHostDebugAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    380416{
  • trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp

    r65655 r65694  
    278278
    279279/**
     280 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     281 */
     282static DECLCALLBACK(uint32_t) drvHostNullAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     283{
     284    RT_NOREF(pInterface, pStream);
     285
     286    return UINT32_MAX;
     287}
     288
     289
     290/**
     291 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     292 */
     293static DECLCALLBACK(uint32_t) drvHostNullAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     294{
     295    RT_NOREF(pInterface, pStream);
     296
     297    return UINT32_MAX;
     298}
     299
     300
     301/**
    280302 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    281303 */
     
    283305{
    284306    RT_NOREF(pInterface, pStream);
    285     return PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED
    286          | PDMAUDIOSTRMSTS_FLAG_DATA_READABLE | PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;
     307    return PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED;
    287308}
    288309
  • trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp

    r65624 r65694  
    10491049
    10501050/**
     1051 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     1052 */
     1053static DECLCALLBACK(uint32_t) drvHostOSSAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1054{
     1055    RT_NOREF(pInterface, pStream);
     1056
     1057    return UINT32_MAX;
     1058}
     1059
     1060
     1061/**
     1062 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     1063 */
     1064static DECLCALLBACK(uint32_t) drvHostOSSAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1065{
     1066    RT_NOREF(pInterface, pStream);
     1067
     1068    return UINT32_MAX;
     1069}
     1070
     1071
     1072/**
    10511073 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    10521074 */
    10531075static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostOSSAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    10541076{
    1055     RT_NOREF(pInterface);
    1056 
    1057     POSSAUDIOSTREAM pStreamOSS = (POSSAUDIOSTREAM)pStream;
     1077    RT_NOREF(pInterface, pStream);
    10581078
    10591079    PDMAUDIOSTRMSTS strmSts =   PDMAUDIOSTRMSTS_FLAG_INITIALIZED
    10601080                              | PDMAUDIOSTRMSTS_FLAG_ENABLED;
    1061 
    1062     strmSts |=   pStreamOSS->pCfg->enmDir == PDMAUDIODIR_IN
    1063                ? PDMAUDIOSTRMSTS_FLAG_DATA_READABLE
    1064                : PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;
    1065 
    10661081    return strmSts;
    10671082}
  • trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp

    r65661 r65694  
    14011401
    14021402
    1403 /**
    1404  * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
    1405  */
    1406 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostPulseAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    1407 {
    1408     AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    1409     AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    1410 
     1403static uint32_t paStreamGetAvail(PDRVHOSTPULSEAUDIO pThis, PPULSEAUDIOSTREAM pStreamPA)
     1404{
     1405    pa_threaded_mainloop_lock(pThis->pMainLoop);
     1406
     1407    uint32_t cbAvail = 0;
     1408
     1409    if (PA_STREAM_IS_GOOD(pa_stream_get_state(pStreamPA->pStream)))
     1410    {
     1411        if (pStreamPA->pCfg->enmDir == PDMAUDIODIR_IN)
     1412        {
     1413            cbAvail = (uint32_t)pa_stream_readable_size(pStreamPA->pStream);
     1414            Log3Func(("cbReadable=%RU32\n", cbAvail));
     1415        }
     1416        else if (pStreamPA->pCfg->enmDir == PDMAUDIODIR_OUT)
     1417        {
     1418            size_t cbWritable = pa_stream_writable_size(pStreamPA->pStream);
     1419            Log3Func(("cbWritable=%zu, cbMinReq=%RU32\n", cbWritable, pStreamPA->BufAttr.minreq));
     1420
     1421            if (cbWritable >= pStreamPA->BufAttr.minreq)
     1422                cbAvail = (uint32_t)cbWritable;
     1423        }
     1424        else
     1425            AssertFailed();
     1426    }
     1427
     1428    pa_threaded_mainloop_unlock(pThis->pMainLoop);
     1429
     1430    return cbAvail;
     1431}
     1432
     1433
     1434/**
     1435 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     1436 */
     1437static DECLCALLBACK(uint32_t) drvHostPulseAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1438{
    14111439    PDRVHOSTPULSEAUDIO pThis     = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
    14121440    PPULSEAUDIOSTREAM  pStreamPA = (PPULSEAUDIOSTREAM)pStream;
     1441
     1442    return paStreamGetAvail(pThis, pStreamPA);
     1443}
     1444
     1445
     1446/**
     1447 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     1448 */
     1449static DECLCALLBACK(uint32_t) drvHostPulseAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1450{
     1451    PDRVHOSTPULSEAUDIO pThis     = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
     1452    PPULSEAUDIOSTREAM  pStreamPA = (PPULSEAUDIOSTREAM)pStream;
     1453
     1454    return paStreamGetAvail(pThis, pStreamPA);
     1455}
     1456
     1457
     1458
     1459/**
     1460 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
     1461 */
     1462static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostPulseAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1463{
     1464    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     1465    RT_NOREF(pStream);
     1466
     1467    PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface);
    14131468
    14141469    PDMAUDIOSTRMSTS strmSts  = PDMAUDIOSTRMSTS_FLAG_NONE;
     
    14181473        && PA_CONTEXT_IS_GOOD(pa_context_get_state(pThis->pContext)))
    14191474    {
    1420        strmSts = PDMAUDIOSTRMSTS_FLAG_INITIALIZED
    1421                | PDMAUDIOSTRMSTS_FLAG_ENABLED;
    1422     }
    1423 
    1424     pa_threaded_mainloop_lock(pThis->pMainLoop);
    1425 
    1426     /* Check the PulseAudio stream. */
    1427     if (PA_STREAM_IS_GOOD(pa_stream_get_state(pStreamPA->pStream)))
    1428     {
    1429         size_t cbSize;
    1430         if (pStreamPA->pCfg->enmDir == PDMAUDIODIR_IN)
    1431         {
    1432             cbSize = pa_stream_readable_size(pStreamPA->pStream);
    1433             Log3Func(("cbSize=%zu\n", cbSize));
    1434 
    1435             if (cbSize)
    1436                 strmSts |= PDMAUDIOSTRMSTS_FLAG_DATA_READABLE;
    1437         }
    1438         else if (pStreamPA->pCfg->enmDir == PDMAUDIODIR_OUT)
    1439         {
    1440             cbSize = pa_stream_writable_size(pStreamPA->pStream);
    1441             Log3Func(("cbSize=%zu, cbMinReq=%RU32\n", cbSize, pStreamPA->BufAttr.minreq));
    1442 
    1443             if (cbSize >= pStreamPA->BufAttr.minreq)
    1444                 strmSts |= PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;
    1445         }
    1446         else
    1447             AssertFailed();
    1448     }
    1449 
    1450     pa_threaded_mainloop_unlock(pThis->pMainLoop);
     1475       strmSts = PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED;
     1476    }
    14511477
    14521478    return strmSts;
  • trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp

    r65670 r65694  
    9999{
    100100    RT_NOREF(pInterface);
    101    
     101
    102102    LogFlowFuncLeaveRC(VINF_SUCCESS);
    103103    return VINF_SUCCESS;
     
    372372}
    373373
     374/**
     375 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
     376 */
     377static DECLCALLBACK(uint32_t) drvHostVaKitAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     378{
     379    RT_NOREF(pInterface, pStream);
     380
     381    return UINT32_MAX;
     382}
     383
     384
     385/**
     386 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
     387 */
     388static DECLCALLBACK(uint32_t) drvHostVaKitAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     389{
     390    RT_NOREF(pInterface, pStream);
     391
     392    return UINT32_MAX;
     393}
     394
    374395static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostVaKitAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    375396{
    376397    RT_NOREF(pInterface, pStream);
    377398
    378     return (  PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED
    379             | PDMAUDIOSTRMSTS_FLAG_DATA_READABLE | PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE);
     399    return (PDMAUDIOSTRMSTS_FLAG_INITIALIZED | PDMAUDIOSTRMSTS_FLAG_ENABLED;
    380400}
    381401
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