Changeset 65694 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Feb 9, 2017 11:15:06 AM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r65669 r65694 143 143 * This will get the raw sample data out of a mixing buffer. 144 144 * 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 * 146 147 * @param pMixBuf Mixing buffer to acquire audio samples from. 147 148 * @param cSamplesToRead Number of audio samples to read. … … 173 174 { 174 175 cRead = pMixBuf->cSamples - pMixBuf->offRead; 175 rc = VINF_ TRY_AGAIN;176 rc = VINF_AUDIO_MORE_DATA_AVAILABLE; 176 177 } 177 178 else … … 184 185 { 185 186 cRead = cSampleBuf; 186 rc = VINF_ TRY_AGAIN;187 rc = VINF_AUDIO_MORE_DATA_AVAILABLE; 187 188 } 188 189 … … 193 194 pMixBuf->offRead = (pMixBuf->offRead + cRead) % pMixBuf->cSamples; 194 195 Assert(pMixBuf->offRead <= pMixBuf->cSamples); 195 pMixBuf->cUsed -= RT_MIN(cRead, pMixBuf->cUsed);196 pMixBuf->cUsed -= RT_MIN(cRead, pMixBuf->cUsed); 196 197 } 197 198 -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r65624 r65694 1124 1124 cbRead = RT_MAX(cbRead, cbTotalRead); 1125 1125 1126 PDMAUDIOSTRMSTS strmSts = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream);1126 uint32_t cbReadable = pMixStream->pConn->pfnStreamGetReadable(pMixStream->pConn, pMixStream->pStream); 1127 1127 1128 1128 /* Still some data available? Then sink is not clean (yet). */ 1129 if ( strmSts & PDMAUDIOSTRMSTS_FLAG_DATA_READABLE)1129 if (cbReadable) 1130 1130 fClean = false; 1131 1131 } -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r65660 r65694 172 172 APPEND_FLAG_TO_STR(PAUSED ); 173 173 APPEND_FLAG_TO_STR(PENDING_DISABLE); 174 APPEND_FLAG_TO_STR(DATA_READABLE );175 APPEND_FLAG_TO_STR(DATA_WRITABLE );176 174 APPEND_FLAG_TO_STR(PENDING_REINIT ); 177 175 } while (0); … … 1254 1252 1255 1253 /** 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 */ 1262 static 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 */ 1337 static 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 /** 1256 1407 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamPlay} 1257 1408 */ … … 1273 1424 pStream->szName, pStream->enmDir)); 1274 1425 1275 uint32_t csPlayed = 0;1426 uint32_t csPlayedTotal = 0; 1276 1427 1277 1428 do … … 1297 1448 rc = VERR_NOT_AVAILABLE); 1298 1449 1450 /* 1451 * Check if the backend is ready to operate. 1452 */ 1453 1299 1454 AssertPtr(pThis->pHostDrvAudio->pfnStreamGetStatus); 1300 1301 uint32_t csLive = AudioMixBufUsed(&pHstStream->MixBuf);1302 1303 1455 PDMAUDIOSTRMSTS stsBackend = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream->pvBackend); 1304 1305 1456 #ifdef LOG_ENABLED 1306 1457 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)); 1308 1459 RTStrFree(pszBackendSts); 1309 1460 #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); 1356 1482 1357 1483 #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); 1364 1489 } 1365 1490 1366 1491 #ifdef LOG_ENABLED 1367 1492 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)); 1370 1495 RTStrFree(pszBackendSts); 1371 1496 #endif /* LOG_ENABLED */ … … 1397 1522 { 1398 1523 if (pcSamplesPlayed) 1399 *pcSamplesPlayed = csPlayed ;1524 *pcSamplesPlayed = csPlayedTotal; 1400 1525 } 1401 1526 … … 1440 1565 rc = VERR_NOT_AVAILABLE); 1441 1566 1567 /* 1568 * Check if the backend is ready to operate. 1569 */ 1570 1442 1571 AssertPtr(pThis->pHostDrvAudio->pfnStreamGetStatus); 1443 1572 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)) 1450 1618 { 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 else1462 {1463 Assert(cbCaptured <= sizeof(auBuf));1464 rc = AudioMixBufWriteCirc(&pHstStream->MixBuf, auBuf, cbCaptured, &csCaptured);1465 if (RT_SUCCESS(rc))1466 {1467 1619 #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)); 1474 1624 } 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 } 1486 1626 1487 1627 } while (0); -
trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
r65624 r65694 255 255 256 256 case SND_PCM_FORMAT_U32_LE: 257 pProps->cBits 258 pProps->fSigned 257 pProps->cBits = 32; 258 pProps->fSigned = false; 259 259 break; 260 260 … … 280 280 } 281 281 282 Assert(pProps->cBits); 282 283 Assert(pProps->cChannels); 283 284 pProps->cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pProps->cBits, pProps->cChannels); … … 895 896 { 896 897 AssertPtrReturn(phPCM, VERR_INVALID_POINTER); 897 AssertPtrReturn(pFramesAvail, VERR_INVALID_POINTER);898 /* pFramesAvail is optional. */ 898 899 899 900 int rc; … … 914 915 rc = VINF_SUCCESS; 915 916 916 if (framesAvail >= 0) 917 *pFramesAvail = framesAvail; 917 if (RT_SUCCESS(rc)) 918 { 919 if (pFramesAvail) 920 *pFramesAvail = framesAvail; 921 } 918 922 919 923 return rc; … … 1003 1007 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 1004 1008 */ 1005 static DECLCALLBACK(int) drvHostALSAAudioStreamCapture(PPDMIHOSTAUDIO pInterface, 1006 PPDMAUDIOBACKENDSTREAM pStream,void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead)1009 static DECLCALLBACK(int) drvHostALSAAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 1010 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 1007 1011 { 1008 1012 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1140 1144 } 1141 1145 1142 LogFlowFuncLeaveRC(rc);1143 1146 return rc; 1144 1147 } … … 1158 1161 PALSAAUDIOSTREAM pStreamALSA = (PALSAAUDIOSTREAM)pStream; 1159 1162 1160 int rc = VINF_SUCCESS; 1163 PPDMAUDIOSTREAMCFG pCfg = pStreamALSA->pCfg; 1164 AssertPtr(pCfg); 1165 1166 int rc; 1161 1167 1162 1168 uint32_t cbWrittenTotal = 0; … … 1175 1181 break; 1176 1182 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); 1181 1184 if (!cbToWrite) 1182 1185 break; 1183 1186 1187 /* Do not write more than available. */ 1188 if (cbToWrite > cbBuf) 1189 cbToWrite = cbBuf; 1190 1191 Assert(cbToWrite % 2 == 0); 1184 1192 memcpy(pStreamALSA->pvBuf, pvBuf, cbToWrite); 1185 1193 … … 1244 1252 break; 1245 1253 1246 cbWrittenTotal += cbToWrite;1254 cbWrittenTotal = PDMAUDIOSTREAMCFG_S2B(pCfg, csWritten); 1247 1255 1248 1256 } while (0); … … 1254 1262 } 1255 1263 1256 LogFlowFuncLeaveRC(rc);1257 1264 return rc; 1258 1265 } … … 1321 1328 AssertBreakStmt(cbBuf, rc = VERR_INVALID_PARAMETER); 1322 1329 1323 pStreamALSA->pvBuf = RTMemAlloc (cbBuf);1330 pStreamALSA->pvBuf = RTMemAllocZ(cbBuf); 1324 1331 if (!pStreamALSA->pvBuf) 1325 1332 { … … 1625 1632 1626 1633 /** 1634 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 1635 */ 1636 static 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 */ 1656 static 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 /** 1627 1677 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 1628 1678 */ 1629 1679 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostALSAAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1630 1680 { 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); 1659 1684 } 1660 1685 -
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r65624 r65694 2413 2413 2414 2414 /** 2415 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGet Status}2416 */ 2417 static DECLCALLBACK( PDMAUDIOSTRMSTS) drvHostCoreAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)2415 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 2416 */ 2417 static DECLCALLBACK(uint32_t) drvHostCoreAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2418 2418 { 2419 2419 RT_NOREF(pInterface); … … 2422 2422 PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pStream; 2423 2423 2424 return (ASMAtomicReadU32(&pCAStream->enmStatus) == COREAUDIOSTATUS_INIT) 2425 ? UINT32_MAX : 0; 2426 } 2427 2428 2429 /** 2430 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 2431 */ 2432 static 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 */ 2447 static 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 2424 2454 PDMAUDIOSTRMSTS strmSts = PDMAUDIOSTRMSTS_FLAG_NONE; 2425 2455 … … 2429 2459 if (ASMAtomicReadU32(&pCAStream->enmStatus) == COREAUDIOSTATUS_INIT) 2430 2460 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 else2443 AssertFailed();2444 2461 2445 2462 return strmSts; -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r65676 r65694 2258 2258 2259 2259 /** 2260 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 2261 */ 2262 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDSoundStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2263 { 2260 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 2261 */ 2262 static 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 */ 2279 static DECLCALLBACK(uint32_t) drvHostDSoundStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 2280 { 2281 RT_NOREF(pInterface, pStream); 2282 2264 2283 AssertPtrReturn(pInterface, PDMAUDIOSTRMSTS_FLAG_NONE); 2265 2284 AssertPtrReturn(pStream, PDMAUDIOSTRMSTS_FLAG_NONE); … … 2268 2287 PDSOUNDSTREAM pStreamDS = (PDSOUNDSTREAM)pStream; 2269 2288 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 */ 2308 static 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 2270 2315 if (!pStreamDS->pCfg) /* Not (yet) configured? Skip. */ 2271 2316 return PDMAUDIOSTRMSTS_FLAG_NONE; … … 2275 2320 { 2276 2321 if (pStreamDS->In.fEnabled) 2277 strmSts |= PDMAUDIOSTRMSTS_FLAG_ENABLED | PDMAUDIOSTRMSTS_FLAG_DATA_READABLE;2322 strmSts |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 2278 2323 } 2279 2324 else 2280 2325 { 2281 2326 if (pStreamDS->Out.fEnabled) 2282 {2283 2327 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 }2294 2328 } 2295 2329 -
trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
r65624 r65694 334 334 335 335 336 /** 337 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 338 */ 336 339 static DECLCALLBACK(int) drvHostDebugAudioStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 337 340 { … … 359 362 } 360 363 364 365 /** 366 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 367 */ 361 368 static DECLCALLBACK(int) drvHostDebugAudioStreamControl(PPDMIHOSTAUDIO pInterface, 362 369 PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) … … 369 376 } 370 377 378 379 /** 380 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 381 */ 382 static 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 */ 393 static 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 */ 371 404 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDebugAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 372 405 { 373 406 RT_NOREF(pInterface, pStream); 374 407 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 */ 379 415 static DECLCALLBACK(int) drvHostDebugAudioStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 380 416 { -
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r65655 r65694 278 278 279 279 /** 280 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 281 */ 282 static 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 */ 293 static DECLCALLBACK(uint32_t) drvHostNullAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 294 { 295 RT_NOREF(pInterface, pStream); 296 297 return UINT32_MAX; 298 } 299 300 301 /** 280 302 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 281 303 */ … … 283 305 { 284 306 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; 287 308 } 288 309 -
trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
r65624 r65694 1049 1049 1050 1050 /** 1051 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 1052 */ 1053 static 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 */ 1064 static DECLCALLBACK(uint32_t) drvHostOSSAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1065 { 1066 RT_NOREF(pInterface, pStream); 1067 1068 return UINT32_MAX; 1069 } 1070 1071 1072 /** 1051 1073 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 1052 1074 */ 1053 1075 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostOSSAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1054 1076 { 1055 RT_NOREF(pInterface); 1056 1057 POSSAUDIOSTREAM pStreamOSS = (POSSAUDIOSTREAM)pStream; 1077 RT_NOREF(pInterface, pStream); 1058 1078 1059 1079 PDMAUDIOSTRMSTS strmSts = PDMAUDIOSTRMSTS_FLAG_INITIALIZED 1060 1080 | PDMAUDIOSTRMSTS_FLAG_ENABLED; 1061 1062 strmSts |= pStreamOSS->pCfg->enmDir == PDMAUDIODIR_IN1063 ? PDMAUDIOSTRMSTS_FLAG_DATA_READABLE1064 : PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE;1065 1066 1081 return strmSts; 1067 1082 } -
trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
r65661 r65694 1401 1401 1402 1402 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 1403 static 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 */ 1437 static DECLCALLBACK(uint32_t) drvHostPulseAudioStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 1438 { 1411 1439 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); 1412 1440 PPULSEAUDIOSTREAM pStreamPA = (PPULSEAUDIOSTREAM)pStream; 1441 1442 return paStreamGetAvail(pThis, pStreamPA); 1443 } 1444 1445 1446 /** 1447 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable} 1448 */ 1449 static 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 */ 1462 static 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); 1413 1468 1414 1469 PDMAUDIOSTRMSTS strmSts = PDMAUDIOSTRMSTS_FLAG_NONE; … … 1418 1473 && PA_CONTEXT_IS_GOOD(pa_context_get_state(pThis->pContext))) 1419 1474 { 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 } 1451 1477 1452 1478 return strmSts; -
trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp
r65670 r65694 99 99 { 100 100 RT_NOREF(pInterface); 101 101 102 102 LogFlowFuncLeaveRC(VINF_SUCCESS); 103 103 return VINF_SUCCESS; … … 372 372 } 373 373 374 /** 375 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable} 376 */ 377 static 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 */ 388 static DECLCALLBACK(uint32_t) drvHostVaKitAudioStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 389 { 390 RT_NOREF(pInterface, pStream); 391 392 return UINT32_MAX; 393 } 394 374 395 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostVaKitAudioStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 375 396 { 376 397 RT_NOREF(pInterface, pStream); 377 398 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; 380 400 } 381 401
Note:
See TracChangeset
for help on using the changeset viewer.