Changeset 88938 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- May 7, 2021 6:22:22 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 144273
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r88937 r88938 325 325 typedef AC97BMREGS *PAC97BMREGS; 326 326 327 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO328 327 /** 329 328 * Asynchronous I/O state for an AC'97 stream. … … 347 346 /** Pointer to the async I/O state for an AC'97 stream. */ 348 347 typedef AC97STREAMSTATEAIO *PAC97STREAMSTATEAIO; 349 #endif350 348 351 349 … … 364 362 /** The stream's current configuration. */ 365 363 PDMAUDIOSTREAMCFG Cfg; //+108 366 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO367 364 /** Asynchronous I/O state members. */ 368 365 AC97STREAMSTATEAIO AIO; 369 #endif370 366 /** Timestamp of the last DMA data transfer. */ 371 367 uint64_t tsTransferLast; … … 454 450 455 451 456 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO457 452 /** 458 453 * Asynchronous I/O thread context (arguments). … … 471 466 /** Pointer to the context for an async I/O thread. */ 472 467 typedef AC97STREAMTHREADCTX *PAC97STREAMTHREADCTX; 473 #endif474 468 475 469 /** … … 699 693 PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc); 700 694 701 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO702 695 static int ichac97R3StreamAsyncIOCreate(PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC); 703 696 static int ichac97R3StreamAsyncIODestroy(PAC97STATE pThis, PAC97STREAMR3 pStreamCC); … … 705 698 static void ichac97R3StreamAsyncIOUnlock(PAC97STREAMR3 pStreamCC); 706 699 /*static void ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable); Unused */ 707 # endif708 700 709 701 DECLINLINE(PDMAUDIODIR) ichac97GetDirFromSD(uint8_t uSD); … … 984 976 985 977 int rc = VINF_SUCCESS; 986 987 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO988 978 if (fEnable) 989 979 rc = ichac97R3StreamAsyncIOCreate(pThis, pThisCC, pStream, pStreamCC); 990 980 if (RT_SUCCESS(rc)) 981 { 991 982 ichac97R3StreamAsyncIOLock(pStreamCC); 992 # endif 993 994 if (fEnable) 995 { 996 if (pStreamCC->State.pCircBuf) 997 RTCircBufReset(pStreamCC->State.pCircBuf); 998 999 rc = ichac97R3StreamOpen(pDevIns, pThis, pThisCC, pStream, pStreamCC, false /* fForce */); 1000 1001 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 1002 { /* likely */ } 983 if (fEnable) 984 { 985 if (pStreamCC->State.pCircBuf) 986 RTCircBufReset(pStreamCC->State.pCircBuf); 987 988 rc = ichac97R3StreamOpen(pDevIns, pThis, pThisCC, pStream, pStreamCC, false /* fForce */); 989 990 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) 991 { /* likely */ } 992 else 993 { 994 if (!AudioHlpFileIsOpen(pStreamCC->Dbg.Runtime.pFileStream)) 995 { 996 int rc2 = AudioHlpFileOpen(pStreamCC->Dbg.Runtime.pFileStream, AUDIOHLPFILE_DEFAULT_OPEN_FLAGS, 997 &pStreamCC->State.Cfg.Props); 998 AssertRC(rc2); 999 } 1000 1001 if (!AudioHlpFileIsOpen(pStreamCC->Dbg.Runtime.pFileDMA)) 1002 { 1003 int rc2 = AudioHlpFileOpen(pStreamCC->Dbg.Runtime.pFileDMA, AUDIOHLPFILE_DEFAULT_OPEN_FLAGS, 1004 &pStreamCC->State.Cfg.Props); 1005 AssertRC(rc2); 1006 } 1007 } 1008 } 1003 1009 else 1004 { 1005 if (!AudioHlpFileIsOpen(pStreamCC->Dbg.Runtime.pFileStream)) 1006 { 1007 int rc2 = AudioHlpFileOpen(pStreamCC->Dbg.Runtime.pFileStream, AUDIOHLPFILE_DEFAULT_OPEN_FLAGS, 1008 &pStreamCC->State.Cfg.Props); 1009 AssertRC(rc2); 1010 } 1011 1012 if (!AudioHlpFileIsOpen(pStreamCC->Dbg.Runtime.pFileDMA)) 1013 { 1014 int rc2 = AudioHlpFileOpen(pStreamCC->Dbg.Runtime.pFileDMA, AUDIOHLPFILE_DEFAULT_OPEN_FLAGS, 1015 &pStreamCC->State.Cfg.Props); 1016 AssertRC(rc2); 1017 } 1018 } 1019 } 1020 else 1021 rc = ichac97R3StreamClose(pStream); 1022 1023 if (RT_SUCCESS(rc)) 1024 { 1025 /* First, enable or disable the stream and the stream's sink, if any. */ 1026 rc = AudioMixerSinkEnable(ichac97R3IndexToSink(pThisCC, pStream->u8SD), fEnable); 1027 } 1028 1029 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1030 ichac97R3StreamAsyncIOUnlock(pStreamCC); 1031 # endif 1010 rc = ichac97R3StreamClose(pStream); 1011 1012 if (RT_SUCCESS(rc)) 1013 { 1014 /* First, enable or disable the stream and the stream's sink, if any. */ 1015 rc = AudioMixerSinkEnable(ichac97R3IndexToSink(pThisCC, pStream->u8SD), fEnable); 1016 } 1017 1018 ichac97R3StreamAsyncIOUnlock(pStreamCC); 1019 } 1032 1020 1033 1021 /* Make sure to leave the lock before (eventually) starting the timer. */ 1034 1022 ichac97R3StreamUnlock(pStreamCC); 1035 1036 1023 LogFunc(("[SD%RU8] fEnable=%RTbool, rc=%Rrc\n", pStream->u8SD, fEnable, rc)); 1037 1024 return rc; … … 1147 1134 AssertRC(rc2); 1148 1135 1149 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1150 1136 rc2 = ichac97R3StreamAsyncIODestroy(pThis, pStreamCC); 1151 1137 AssertRC(rc2); 1152 # else1153 RT_NOREF(pThis);1154 # endif1155 1138 1156 1139 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) … … 1331 1314 } 1332 1315 1333 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1334 1316 1335 1317 /** … … 1554 1536 } 1555 1537 #endif 1556 # endif /* VBOX_WITH_AUDIO_AC97_ASYNC_IO */1557 1538 1558 1539 # ifdef LOG_ENABLED … … 1594 1575 * 1595 1576 * This routine is called by both, the synchronous and the asynchronous 1596 * (VBOX_WITH_AUDIO_AC97_ASYNC_IO),implementations.1577 * implementations. 1597 1578 * 1598 1579 * When running synchronously, the device DMA transfers *and* the mixer sink … … 1627 1608 if (pStreamCC->State.Cfg.enmDir == PDMAUDIODIR_OUT) /* Output (SDO). */ 1628 1609 { 1629 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1630 1610 if (fInTimer) 1631 # endif1632 1611 { 1633 1612 const uint32_t cbStreamFree = ichac97R3StreamGetFree(pStreamCC); … … 1651 1630 Log3Func(("[SD%RU8] fInTimer=%RTbool\n", pStream->u8SD, fInTimer)); 1652 1631 1653 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1654 1632 rc2 = ichac97R3StreamAsyncIONotify(pStreamCC); 1655 1633 AssertRC(rc2); 1656 # endif 1657 1658 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1634 1659 1635 if (!fInTimer) /* In async I/O thread */ 1660 1636 { 1661 # endif1662 1637 const uint32_t cbSinkWritable = AudioMixerSinkGetWritable(pSink); 1663 1638 const uint32_t cbStreamReadable = ichac97R3StreamGetUsed(pStreamCC); … … 1672 1647 AssertRC(rc2); 1673 1648 } 1674 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1675 } 1676 #endif 1649 } 1677 1650 /* When running synchronously, update the associated sink here. 1678 1651 * Otherwise this will be done in the async I/O thread. */ … … 1682 1655 else /* Input (SDI). */ 1683 1656 { 1684 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1685 1657 if (!fInTimer) 1686 1658 { 1687 # endif1688 1659 rc2 = AudioMixerSinkUpdate(pSink); 1689 1660 AssertRC(rc2); … … 1708 1679 AssertRC(rc2); 1709 1680 } 1710 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO1711 1681 } 1712 1682 else /* fInTimer */ 1713 1683 { 1714 # endif 1715 1716 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1684 1717 1685 const uint64_t tsNowNs = RTTimeNanoTS(); 1718 1686 if (tsNowNs - pStreamCC->State.tsLastUpdateNs >= pStreamCC->State.Cfg.Device.cMsSchedulingHint * RT_NS_1MS) … … 1723 1691 pStreamCC->State.tsLastUpdateNs = tsNowNs; 1724 1692 } 1725 # endif1726 1693 1727 1694 const uint32_t cbStreamUsed = ichac97R3StreamGetUsed(pStreamCC); … … 1733 1700 AssertRC(rc2); 1734 1701 } 1735 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1736 } 1737 # endif 1702 } 1738 1703 } 1739 1704 } … … 4247 4212 return rc; 4248 4213 4249 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO4250 LogRel(("AC97: Asynchronous I/O enabled\n"));4251 # endif4252 4253 4214 /* 4254 4215 * Attach drivers. We ASSUME they are configured consecutively without any
Note:
See TracChangeset
for help on using the changeset viewer.