VirtualBox

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


Ignore:
Timestamp:
Sep 3, 2018 10:03:11 AM (6 years ago)
Author:
vboxsync
Message:

Audio/AC97: Compile fixes for async I/O support (VBOX_WITH_AUDIO_AC97_ASYNC_IO, currently not enabled), matched the timer / async I/O threading code with the one in the HDA emulation.

File:
1 edited

Legend:

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

    r73833 r74038  
    666666static void               ichac97R3StreamAsyncIOLock(PAC97STREAM pStream);
    667667static void               ichac97R3StreamAsyncIOUnlock(PAC97STREAM pStream);
    668 static void               ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable);
     668/*static void               ichac97R3StreamAsyncIOEnable(PAC97STREAM pStream, bool fEnable); Unused */
    669669# endif
    670670
     
    12981298                RTStrPrintf2(szThreadName, sizeof(szThreadName), "ac97AIO%RU8", pStream->u8SD);
    12991299
    1300                 rc = RTThreadCreate(&pAIO->Thread, ichac97StreamAsyncIOThread, &Ctx,
     1300                rc = RTThreadCreate(&pAIO->Thread, ichac97R3StreamAsyncIOThread, &Ctx,
    13011301                                    0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, szThreadName);
    13021302                if (RT_SUCCESS(rc))
     
    13991399}
    14001400
     1401#if 0 /* Unused */
    14011402/**
    14021403 * Enables (resumes) or disables (pauses) the async I/O thread.
     
    14121413    ASMAtomicXchgBool(&pAIO->fEnabled, fEnable);
    14131414}
     1415#endif
    14141416
    14151417# endif /* VBOX_WITH_AUDIO_AC97_ASYNC_IO */
     
    14791481        if (fDoRead)
    14801482        {
    1481             rc2 = ichac97R3StreamAsyncIONotify(pStream);
     1483            rc2 = ichac97R3StreamAsyncIONotify(pThis, pStream);
    14821484            AssertRC(rc2);
    14831485        }
     
    15131515    {
    15141516# ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
    1515         if (fInTimer)
    1516         {
    1517             rc2 = ichac97R3StreamAsyncIONotify(pThis, pStream);
    1518             AssertRC(rc2);
    1519         }
    1520         else
     1517        if (!fInTimer)
     1518        {
    15211519# endif
    1522         {
    15231520            rc2 = AudioMixerSinkUpdate(pSink);
    15241521            AssertRC(rc2);
    15251522
    15261523            /* Is the sink ready to be read (host input data) from? If so, by how much? */
    1527             const uint32_t cbReadable = AudioMixerSinkGetReadable(pSink);
    1528 
    1529             /* How much (guest input) data is free at the moment? */
    1530             uint32_t cbToTransfer = ichac97R3StreamGetFree(pStream);
    1531 
    1532             Log3Func(("[SD%RU8] cbReadable=%RU32, cbFree=%RU32\n", pStream->u8SD, cbReadable, cbToTransfer));
     1524            uint32_t cbSinkReadable = AudioMixerSinkGetReadable(pSink);
     1525
     1526            /* How much (guest input) data is available for writing at the moment for the AC'97 stream? */
     1527            uint32_t cbStreamFree = ichac97R3StreamGetFree(pStream);
     1528
     1529            Log3Func(("[SD%RU8] cbSinkReadable=%RU32, cbStreamFree=%RU32\n", pStream->u8SD, cbSinkReadable, cbStreamFree));
    15331530
    15341531            /* Do not read more than the sink can provide at the moment.
    15351532             * The host sets the overall pace. */
    1536             if (cbToTransfer > cbReadable)
    1537                 cbToTransfer = cbReadable;
    1538 
    1539             if (cbToTransfer)
     1533            if (cbSinkReadable > cbStreamFree)
     1534                cbSinkReadable = cbStreamFree;
     1535
     1536            if (cbSinkReadable)
    15401537            {
    15411538                /* Write (guest input) data to the stream which was read from stream's sink before. */
    1542                 rc2 = ichac97R3StreamWrite(pThis, pStream, pSink, cbToTransfer, NULL /* pcbWritten */);
     1539                rc2 = ichac97R3StreamWrite(pThis, pStream, pSink, cbSinkReadable, NULL /* pcbWritten */);
    15431540                AssertRC(rc2);
    15441541            }
    1545         }
    1546 
    15471542# ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
    1548         if (fInTimer)
     1543        }
     1544        else /* fInTimer */
     1545        {
    15491546# endif
    1550         {
    1551             const uint32_t cbToTransfer = ichac97R3StreamGetUsed(pStream);
    1552             if (cbToTransfer)
     1547
     1548# ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
     1549            const uint64_t tsNowNs = RTTimeNanoTS();
     1550            if (tsNowNs - pStream->State.tsLastUpdateNs >= pStream->State.Cfg.Device.uSchedulingHintMs * RT_NS_1MS)
     1551            {
     1552                rc2 = ichac97R3StreamAsyncIONotify(pThis, pStream);
     1553                AssertRC(rc2);
     1554
     1555                pStream->State.tsLastUpdateNs = tsNowNs;
     1556            }
     1557# endif
     1558
     1559            const uint32_t cbStreamUsed = ichac97R3StreamGetUsed(pStream);
     1560            if (cbStreamUsed)
    15531561            {
    15541562                /* When running synchronously, do the DMA data transfers here.
    15551563                 * Otherwise this will be done in the stream's async I/O thread. */
    1556                 rc2 = ichac97R3StreamTransfer(pThis, pStream, cbToTransfer);
     1564                rc2 = ichac97R3StreamTransfer(pThis, pStream, cbStreamUsed);
    15571565                AssertRC(rc2);
    15581566            }
    1559         }
     1567# ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO
     1568        }
     1569# endif
    15601570    }
    15611571}
     
    16991709                    PDMAUDIOBACKENDCFG Cfg;
    17001710                    rc = pDrv->pConnector->pfnGetConfig(pDrv->pConnector, &Cfg);
    1701                     if (   RT_SUCCESS(rc)
    1702                         && Cfg.cMaxStreamsIn) /* At least one input source available? */
     1711                    if (RT_SUCCESS(rc))
    17031712                    {
    1704                         rc = AudioMixerSinkSetRecordingSource(pMixSink, pMixStrm);
    1705                         LogFlowFunc(("LUN#%RU8: Recording source is now '%s', rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc));
    1706                         LogRel2(("AC97: Set recording source to '%s'\n", pStreamCfg->szName));
     1713                        if (Cfg.cMaxStreamsIn) /* At least one input source available? */
     1714                        {
     1715                            rc = AudioMixerSinkSetRecordingSource(pMixSink, pMixStrm);
     1716                            LogFlowFunc(("LUN#%RU8: Recording source for '%s' -> '%s', rc=%Rrc\n",
     1717                                         pDrv->uLUN, pStreamCfg->szName, Cfg.szName, rc));
     1718
     1719                            if (RT_SUCCESS(rc))
     1720                                LogRel2(("AC97: Set recording source for '%s' to '%s'\n", pStreamCfg->szName, Cfg.szName));
     1721                        }
     1722                        else
     1723                            LogRel(("AC97: Backend '%s' currently is not offering any recording source for '%s'\n",
     1724                                    Cfg.szName, pStreamCfg->szName));
    17071725                    }
    17081726                    else if (RT_FAILURE(rc))
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