VirtualBox

Changeset 67438 in vbox for trunk/src


Ignore:
Timestamp:
Jun 16, 2017 1:19:59 PM (8 years ago)
Author:
vboxsync
Message:

Audio/DevHDA: More forward porting / integration stuff. WIP.

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

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

    r67430 r67438  
    10331033static void          hdaStreamDestroy(PHDASTATE pThis, PHDASTREAM pStream);
    10341034static int           hdaStreamEnable(PHDASTATE pThis, PHDASTREAM pStream, bool fEnable);
    1035 uint32_t             hdaStreamGetDataSize(PHDASTREAM pStream);
     1035uint32_t             hdaStreamGetUsed(PHDASTREAM pStream);
     1036uint32_t             hdaStreamGetFree(PHDASTREAM pStream);
    10361037static int           hdaStreamTransfer(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToProcessMax);
    10371038DECLINLINE(uint32_t) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStream, uint32_t u32LPIB);
     
    10391040static void          hdaStreamUnlock(PHDASTREAM pStream);
    10401041static int           hdaStreamRead(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToRead, uint32_t *pcbRead);
    1041 //static int           hdaStreamWrite(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToWrite, uint32_t *pcbWritten);
     1042static int           hdaStreamWrite(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToWrite, uint32_t *pcbWritten);
    10421043static void          hdaStreamUpdate(PHDASTATE pThis, PHDASTREAM pStream, bool fAsync);
    10431044# ifdef HDA_USE_DMA_ACCESS_HANDLER
     
    47934794static void hdaDoTransfers(PHDASTATE pThis)
    47944795{
    4795     //PHDASTREAM pStreamLineIn  = hdaSinkGetStream(pThis, &pThis->SinkLineIn);
     4796    PHDASTREAM pStreamLineIn  = hdaSinkGetStream(pThis, &pThis->SinkLineIn);
    47964797#ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
    47974798    PHDASTREAM pStreamMicIn   = hdaSinkGetStream(pThis, &pThis->SinkMicIn);
     
    48024803#endif
    48034804
    4804     hdaStreamUpdate(pThis, pStreamFront, true /* fSync */);
     4805    hdaStreamUpdate(pThis, pStreamFront,  true /* fInTimer */);
     4806#ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
     4807    hdaStreamUpdate(pThis, pStreamMicIn,  true /* fInTimer */);
     4808#endif
     4809    hdaStreamUpdate(pThis, pStreamLineIn, true /* fInTimer */);
    48054810}
    48064811
     
    48124817 * Retrieves the available size of (buffered) audio data (in bytes) of a given HDA stream.
    48134818 *
    4814  * @returns Data size (in bytes).
     4819 * @returns Available data (in bytes).
    48154820 * @param   pStream             HDA stream to retrieve size for.
    48164821 */
    4817 uint32_t hdaStreamGetDataSize(PHDASTREAM pStream)
     4822uint32_t hdaStreamGetUsed(PHDASTREAM pStream)
    48184823{
    48194824    AssertPtrReturn(pStream, 0);
     
    48254830}
    48264831
    4827 #if 0
     4832/**
     4833 * Retrieves the free size of audio data (in bytes) of a given HDA stream.
     4834 *
     4835 * @returns Free data (in bytes).
     4836 * @param   pStream             HDA stream to retrieve size for.
     4837 */
     4838uint32_t hdaStreamGetFree(PHDASTREAM pStream)
     4839{
     4840    AssertPtrReturn(pStream, 0);
     4841
     4842    if (!pStream->State.pCircBuf)
     4843        return 0;
     4844
     4845    return (uint32_t)RTCircBufFree(pStream->State.pCircBuf);
     4846}
     4847
     4848
    48284849/**
    48294850 * Writes audio data from a mixer sink into an HDA stream's DMA buffer.
     
    48864907    return VINF_SUCCESS;
    48874908}
    4888 #endif
    48894909
    48904910
     
    50005020            }
    50015021
    5002             hdaStreamUpdate(pThis, pStream, false /* fSync */);
     5022            hdaStreamUpdate(pThis, pStream, false /* fInTimer */);
    50035023
    50045024            int rc3 = RTCritSectLeave(&pAIO->CritSect);
     
    54115431 * @param   pThis               HDA state.
    54125432 * @param   pStream             HDA stream to update.
    5413  * @param   fSync               Whether to use this function in an synchronous
    5414  *                              or asynchronous context.
    5415  */
    5416 static void hdaStreamUpdate(PHDASTATE pThis, PHDASTREAM pStream, bool fSync)
     5433 * @param   fInTimer            Whether to this function was called from the timer
     5434 *                              context or an asynchronous I/O stream thread (if supported).
     5435 */
     5436static void hdaStreamUpdate(PHDASTATE pThis, PHDASTREAM pStream, bool fInTimer)
    54175437{
    54185438    PAUDMIXSINK pSink = NULL;
     
    54235443    }
    54245444
    5425     if (!pSink) /* No sink available? Bail out. */
     5445    if (!AudioMixerSinkIsActive(pSink)) /* No sink available? Bail out. */
    54265446        return;
    54275447
     
    54335453        const uint32_t cbWritable = AudioMixerSinkGetWritable(pSink);
    54345454
    5435         if (   fSync
     5455        if (   fInTimer
    54365456            && cbWritable)
    54375457        {
     5458            Log3Func(("[SD%RU8] cbWritable=%RU32\n", pStream->u8SD, cbWritable));
     5459
    54385460            /* When running synchronously, do the DMA data transfers here.
    54395461             * Otherwise this will be done in the device timer. */
     
    54475469        }
    54485470
    5449         /* How much (guest output) data is available at the moment? */
    5450         AssertPtr(pStream->State.pCircBuf);
    5451         uint32_t cbToWrite = hdaStreamGetDataSize(pStream);
    5452 
    5453         /* Do not write more than the sink can hold at the moment.
    5454          * The host sets the overall pace. */
    5455         if (cbToWrite > cbWritable)
    5456             cbToWrite = cbWritable;
    5457 
    5458         if (cbToWrite)
    5459         {
    5460             /* Read (guest output) data and write it to the stream's sink. */
    5461             rc2 = hdaStreamRead(pThis, pStream, cbToWrite, NULL /* pcbWritten */);
    5462             AssertRC(rc2);
    5463         }
    5464 
    5465         if (fSync)
    5466         {
     5471#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     5472        if (!fInTimer)
     5473        {
     5474#endif
     5475            /* How much (guest output) data is available at the moment? */
     5476            uint32_t cbToRead = hdaStreamGetUsed(pStream);
     5477
     5478            /* Do not write more than the sink can hold at the moment.
     5479             * The host sets the overall pace. */
     5480            if (cbToRead > cbWritable)
     5481                cbToRead = cbWritable;
     5482
     5483            if (cbToRead)
     5484            {
     5485                /* Read (guest output) data and write it to the stream's sink. */
     5486                rc2 = hdaStreamRead(pThis, pStream, cbToRead, NULL /* pcbRead */);
     5487                AssertRC(rc2);
     5488            }
     5489
    54675490            /* When running synchronously, update the associated sink here.
    54685491             * Otherwise this will be done in the device timer. */
    54695492            rc2 = AudioMixerSinkUpdate(pSink);
    54705493            AssertRC(rc2);
    5471         }
    5472 
     5494
     5495#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     5496        }
     5497#endif
    54735498    }
    54745499    else /* Input (SDI). */
    54755500    {
    5476 #if 0
    5477         cbToProcess = (uint32_t)RTCircBufFree(pCircBuf);
    5478         if (cbToProcess)
    5479             rc2 = hdaStreamWrite(pThis, pStream, cbToProcess, &cbProcessed);
     5501#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     5502        if (fInTimer)
     5503        {
     5504            rc2 = hdaStreamAsyncIONotify(pThis, pStream);
     5505            AssertRC(rc2);
     5506        }
     5507        else
     5508        {
     5509#endif
     5510            rc2 = AudioMixerSinkUpdate(pSink);
     5511            AssertRC(rc2);
     5512
     5513            /* Is the sink ready to be read (host input data) from? If so, by how much? */
     5514            const uint32_t cbReadable = AudioMixerSinkGetReadable(pSink);
     5515
     5516            Log3Func(("[SD%RU8] cbReadable=%RU32\n", pStream->u8SD, cbReadable));
     5517
     5518            /* How much (guest input) data is free at the moment? */
     5519            uint32_t cbToWrite = hdaStreamGetFree(pStream);
     5520
     5521            /* Do not read more than the sink can provide at the moment.
     5522             * The host sets the overall pace. */
     5523            if (cbToWrite > cbReadable)
     5524                cbToWrite = cbReadable;
     5525
     5526            if (cbToWrite)
     5527            {
     5528                /* Write (guest input) data to the stream which was read from stream's sink before. */
     5529                rc2 = hdaStreamWrite(pThis, pStream, cbToWrite, NULL /* pcbWritten */);
     5530                AssertRC(rc2);
     5531            }
     5532#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     5533        }
     5534#endif
     5535
     5536#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     5537        if (fInTimer)
     5538        {
     5539#endif
     5540            const uint32_t cbReadable = hdaStreamGetUsed(pStream);
     5541            if (cbReadable)
     5542            {
     5543                /* When running synchronously, do the DMA data transfers here.
     5544                 * Otherwise this will be done in the stream's async I/O thread. */
     5545                rc2 = hdaStreamTransfer(pThis, pStream, cbReadable);
     5546                AssertRC(rc2);
     5547            }
     5548#ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     5549        }
    54805550#endif
    54815551    }
  • trunk/src/VBox/Devices/Makefile.kmk

    r67429 r67438  
    581581 # Disabled for AC'97 for now.
    582582 #VBoxDD_DEFS  += VBOX_WITH_AUDIO_AC97_ASYNC_IO
    583  #VBoxDD_DEFS  += VBOX_WITH_AUDIO_HDA_ASYNC_IO
     583 VBoxDD_DEFS  += VBOX_WITH_AUDIO_HDA_ASYNC_IO
    584584
    585585 # Not yet enabled: Callbacks for the device emulation to let the backends
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