Changeset 71741 in vbox for trunk/src/VBox
- Timestamp:
- Apr 7, 2018 10:24:29 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r71738 r71741 205 205 }; 206 206 207 /** Emits registers for a specific (Native Audio Bus Master BAR) NABMBAR. */ 207 /** Emits registers for a specific (Native Audio Bus Master BAR) NABMBAR. 208 * @todo This totally messes with grepping for identifiers and tagging. */ 208 209 #define AC97_NABMBAR_REGS(prefix, off) \ 209 210 enum { \ … … 1064 1065 1065 1066 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1067 1066 1068 /** 1067 1069 * Asynchronous I/O thread for an AC'97 stream. … … 1275 1277 ASMAtomicXchgBool(&pAIO->fEnabled, fEnable); 1276 1278 } 1279 1277 1280 #endif /* VBOX_WITH_AUDIO_AC97_ASYNC_IO */ 1278 1281 … … 1324 1327 } 1325 1328 else 1326 {1327 1329 #endif 1330 { 1328 1331 const uint32_t cbSinkWritable = AudioMixerSinkGetWritable(pSink); 1329 1332 … … 1349 1352 AssertRC(rc2); 1350 1353 1351 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1352 } 1353 #endif 1354 } 1354 1355 } 1355 1356 else /* Input (SDI). */ … … 1362 1363 } 1363 1364 else 1364 {1365 1365 #endif 1366 { 1366 1367 rc2 = AudioMixerSinkUpdate(pSink); 1367 1368 AssertRC(rc2); … … 1386 1387 AssertRC(rc2); 1387 1388 } 1388 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1389 } 1390 #endif 1389 } 1391 1390 1392 1391 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1393 1392 if (fInTimer) 1394 {1395 1393 #endif 1394 { 1396 1395 const uint32_t cbToTransfer = ichac97StreamGetUsed(pStream); 1397 1396 if (cbToTransfer) … … 1402 1401 AssertRC(rc2); 1403 1402 } 1404 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1405 } 1406 #endif 1403 } 1407 1404 } 1408 1405 } … … 1418 1415 static void ichac97MixerSet(PAC97STATE pThis, uint8_t uMixerIdx, uint16_t uVal) 1419 1416 { 1420 if (size_t(uMixerIdx + 2) > sizeof(pThis->mixer_data)) 1421 { 1422 AssertMsgFailed(("Index %RU8 out of bounds(%zu)\n", uMixerIdx, sizeof(pThis->mixer_data))); 1423 return; 1424 } 1425 1417 AssertMsgReturnVoid(uMixerIdx + 2U <= sizeof(pThis->mixer_data), 1418 ("Index %RU8 out of bounds (%zu)\n", uMixerIdx, sizeof(pThis->mixer_data))); 1426 1419 pThis->mixer_data[uMixerIdx + 0] = RT_LO_U8(uVal); 1427 1420 pThis->mixer_data[uMixerIdx + 1] = RT_HI_U8(uVal); … … 1437 1430 static uint16_t ichac97MixerGet(PAC97STATE pThis, uint32_t uMixerIdx) 1438 1431 { 1439 uint16_t uVal; 1440 1441 if (size_t(uMixerIdx + 2) > sizeof(pThis->mixer_data)) 1442 { 1443 AssertMsgFailed(("Index %RU8 out of bounds (%zu)\n", uMixerIdx, sizeof(pThis->mixer_data))); 1444 uVal = UINT16_MAX; 1445 } 1446 else 1447 uVal = RT_MAKE_U16(pThis->mixer_data[uMixerIdx + 0], pThis->mixer_data[uMixerIdx + 1]); 1448 1449 return uVal; 1432 AssertMsgReturn(uMixerIdx + 2U <= sizeof(pThis->mixer_data), 1433 ("Index %RU8 out of bounds (%zu)\n", uMixerIdx, sizeof(pThis->mixer_data)), 1434 UINT16_MAX); 1435 return RT_MAKE_U16(pThis->mixer_data[uMixerIdx + 0], pThis->mixer_data[uMixerIdx + 1]); 1450 1436 } 1451 1437 … … 1664 1650 PPDMAUDIOSTREAMCFG pCfg = &pStream->State.Cfg; 1665 1651 PAUDMIXSINK pMixSink = NULL; 1652 AssertCompile(sizeof(pCfg->szName) >= 8); 1666 1653 1667 1654 switch (pStream->u8SD) … … 1673 1660 pCfg->DestSource.Source = PDMAUDIORECSOURCE_LINE; 1674 1661 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1675 1676 RTStrPrintf2(pCfg->szName, sizeof(pCfg->szName), "Line-In"); 1662 strcpy(pCfg->szName, "Line-In"); 1677 1663 1678 1664 pMixSink = pThis->pSinkLineIn; … … 1686 1672 pCfg->DestSource.Source = PDMAUDIORECSOURCE_MIC; 1687 1673 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1688 1689 RTStrPrintf2(pCfg->szName, sizeof(pCfg->szName), "Mic-In"); 1674 strcpy(pCfg->szName, "Mic-In"); 1690 1675 1691 1676 pMixSink = pThis->pSinkMicIn; … … 1699 1684 pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT; 1700 1685 pCfg->enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 1701 1702 RTStrPrintf2(pCfg->szName, sizeof(pCfg->szName), "Output"); 1686 strcpy(pCfg->szName, "Output"); 1703 1687 1704 1688 pMixSink = pThis->pSinkOut; … … 1990 1974 case AC97SOUNDSOURCE_MC_INDEX: return &pThis->StreamMicIn; 1991 1975 case AC97SOUNDSOURCE_PO_INDEX: return &pThis->StreamOut; 1992 default: break; 1993 } 1994 1995 return NULL; 1976 default: return NULL; 1977 } 1978 1996 1979 } 1997 1980 … … 2127 2110 2128 2111 #ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS 2112 2129 2113 /** 2130 2114 * Starts the internal audio device timer. … … 2297 2281 ichac97TimerMain(pThis); 2298 2282 } 2283 2299 2284 #endif /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */ 2300 2285 … … 2447 2432 if (cbSrc) 2448 2433 { 2434 /** @todo r=bird: Just curious, DevHDA uses PDMDevHlpPCIPhysWrite here. So, 2435 * is AC97 not subject to PCI busmaster enable/disable? */ 2449 2436 int rc2 = PDMDevHlpPhysWrite(pThis->CTX_SUFF(pDevIns), pRegs->bd.addr, (uint8_t *)pvSrc, cbSrc); 2450 2437 AssertRC(rc2); … … 2919 2906 PAC97STATE pThis = (PAC97STATE)pvUser; 2920 2907 2921 DEVAC97_LOCK(pThis); 2908 DEVAC97_LOCK(pThis); /** @todo r=bird: some disconnect between the remark of this function docs and this locking statement. */ 2922 2909 2923 2910 int rc = VINF_SUCCESS; 2924 2911 2925 2912 uint32_t index = uPort - pThis->IOPortBase[0]; 2913 Assert(index < 256); 2926 2914 2927 2915 switch (cbVal) … … 2937 2925 case 2: 2938 2926 { 2939 *pu32Val = UINT32_MAX;2940 2927 pThis->cas = 0; 2941 2942 switch (index) 2943 { 2944 default: 2945 *pu32Val = ichac97MixerGet(pThis, index); 2946 break; 2947 } 2928 *pu32Val = ichac97MixerGet(pThis, index); 2948 2929 break; 2949 2930 } … … 2981 2962 * @remarks Caller enters the device critical section. 2982 2963 */ 2983 static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, 2984 uint32_t u32Val, unsigned cbVal) 2964 static DECLCALLBACK(int) ichac97IOPortNAMWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT uPort, uint32_t u32Val, unsigned cbVal) 2985 2965 { 2986 2966 RT_NOREF(pDevIns); … … 3410 3390 3411 3391 /** 3412 * @interface_method_impl{PDMDEVREG,pfnDestruct}3413 */3414 static DECLCALLBACK(int) ichac97Destruct(PPDMDEVINS pDevIns)3415 {3416 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);3417 3418 LogFlowFuncEnter();3419 3420 PAC97DRIVER pDrv, pDrvNext;3421 RTListForEachSafe(&pThis->lstDrv, pDrv, pDrvNext, AC97DRIVER, Node)3422 {3423 RTListNodeRemove(&pDrv->Node);3424 RTMemFree(pDrv);3425 }3426 3427 /* Sanity. */3428 Assert(RTListIsEmpty(&pThis->lstDrv));3429 3430 return VINF_SUCCESS;3431 }3432 3433 3434 /**3435 3392 * Attach command, internal version. 3436 3393 * … … 3665 3622 3666 3623 /** 3624 * @interface_method_impl{PDMDEVREG,pfnDestruct} 3625 */ 3626 static DECLCALLBACK(int) ichac97Destruct(PPDMDEVINS pDevIns) 3627 { 3628 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); /* this shall come first */ 3629 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); 3630 3631 LogFlowFuncEnter(); 3632 3633 PAC97DRIVER pDrv, pDrvNext; 3634 RTListForEachSafe(&pThis->lstDrv, pDrv, pDrvNext, AC97DRIVER, Node) 3635 { 3636 RTListNodeRemove(&pDrv->Node); 3637 RTMemFree(pDrv); 3638 } 3639 3640 /* Sanity. */ 3641 Assert(RTListIsEmpty(&pThis->lstDrv)); 3642 3643 return VINF_SUCCESS; 3644 } 3645 3646 /** 3667 3647 * @interface_method_impl{PDMDEVREG,pfnConstruct} 3668 3648 */ 3669 3649 static DECLCALLBACK(int) ichac97Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 3670 3650 { 3671 RT_NOREF(iInstance);3651 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); /* this shall come first */ 3672 3652 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); 3673 3674 /* NB: This must be done *before* any possible failure (and running the destructor). */ 3653 Assert(iInstance == 0); RT_NOREF(iInstance); 3654 3655 /* 3656 * Initialize data so we can run the destructor without scewing up. 3657 */ 3675 3658 RTListInit(&pThis->lstDrv); 3676 3659 3677 Assert(iInstance == 0);3678 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);3679 3660 3680 3661 /*
Note:
See TracChangeset
for help on using the changeset viewer.