- Timestamp:
- Jun 16, 2017 1:19:59 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r67430 r67438 1033 1033 static void hdaStreamDestroy(PHDASTATE pThis, PHDASTREAM pStream); 1034 1034 static int hdaStreamEnable(PHDASTATE pThis, PHDASTREAM pStream, bool fEnable); 1035 uint32_t hdaStreamGetDataSize(PHDASTREAM pStream); 1035 uint32_t hdaStreamGetUsed(PHDASTREAM pStream); 1036 uint32_t hdaStreamGetFree(PHDASTREAM pStream); 1036 1037 static int hdaStreamTransfer(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToProcessMax); 1037 1038 DECLINLINE(uint32_t) hdaStreamUpdateLPIB(PHDASTATE pThis, PHDASTREAM pStream, uint32_t u32LPIB); … … 1039 1040 static void hdaStreamUnlock(PHDASTREAM pStream); 1040 1041 static 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);1042 static int hdaStreamWrite(PHDASTATE pThis, PHDASTREAM pStream, uint32_t cbToWrite, uint32_t *pcbWritten); 1042 1043 static void hdaStreamUpdate(PHDASTATE pThis, PHDASTREAM pStream, bool fAsync); 1043 1044 # ifdef HDA_USE_DMA_ACCESS_HANDLER … … 4793 4794 static void hdaDoTransfers(PHDASTATE pThis) 4794 4795 { 4795 //PHDASTREAM pStreamLineIn = hdaSinkGetStream(pThis, &pThis->SinkLineIn);4796 PHDASTREAM pStreamLineIn = hdaSinkGetStream(pThis, &pThis->SinkLineIn); 4796 4797 #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 4797 4798 PHDASTREAM pStreamMicIn = hdaSinkGetStream(pThis, &pThis->SinkMicIn); … … 4802 4803 #endif 4803 4804 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 */); 4805 4810 } 4806 4811 … … 4812 4817 * Retrieves the available size of (buffered) audio data (in bytes) of a given HDA stream. 4813 4818 * 4814 * @returns Data size(in bytes).4819 * @returns Available data (in bytes). 4815 4820 * @param pStream HDA stream to retrieve size for. 4816 4821 */ 4817 uint32_t hdaStreamGet DataSize(PHDASTREAM pStream)4822 uint32_t hdaStreamGetUsed(PHDASTREAM pStream) 4818 4823 { 4819 4824 AssertPtrReturn(pStream, 0); … … 4825 4830 } 4826 4831 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 */ 4838 uint32_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 4828 4849 /** 4829 4850 * Writes audio data from a mixer sink into an HDA stream's DMA buffer. … … 4886 4907 return VINF_SUCCESS; 4887 4908 } 4888 #endif4889 4909 4890 4910 … … 5000 5020 } 5001 5021 5002 hdaStreamUpdate(pThis, pStream, false /* f Sync*/);5022 hdaStreamUpdate(pThis, pStream, false /* fInTimer */); 5003 5023 5004 5024 int rc3 = RTCritSectLeave(&pAIO->CritSect); … … 5411 5431 * @param pThis HDA state. 5412 5432 * @param pStream HDA stream to update. 5413 * @param f Sync Whether to use this function in an synchronous5414 * or asynchronous context.5415 */ 5416 static void hdaStreamUpdate(PHDASTATE pThis, PHDASTREAM pStream, bool f Sync)5433 * @param fInTimer Whether to this function was called from the timer 5434 * context or an asynchronous I/O stream thread (if supported). 5435 */ 5436 static void hdaStreamUpdate(PHDASTATE pThis, PHDASTREAM pStream, bool fInTimer) 5417 5437 { 5418 5438 PAUDMIXSINK pSink = NULL; … … 5423 5443 } 5424 5444 5425 if (! pSink) /* No sink available? Bail out. */5445 if (!AudioMixerSinkIsActive(pSink)) /* No sink available? Bail out. */ 5426 5446 return; 5427 5447 … … 5433 5453 const uint32_t cbWritable = AudioMixerSinkGetWritable(pSink); 5434 5454 5435 if ( f Sync5455 if ( fInTimer 5436 5456 && cbWritable) 5437 5457 { 5458 Log3Func(("[SD%RU8] cbWritable=%RU32\n", pStream->u8SD, cbWritable)); 5459 5438 5460 /* When running synchronously, do the DMA data transfers here. 5439 5461 * Otherwise this will be done in the device timer. */ … … 5447 5469 } 5448 5470 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 5467 5490 /* When running synchronously, update the associated sink here. 5468 5491 * Otherwise this will be done in the device timer. */ 5469 5492 rc2 = AudioMixerSinkUpdate(pSink); 5470 5493 AssertRC(rc2); 5471 } 5472 5494 5495 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 5496 } 5497 #endif 5473 5498 } 5474 5499 else /* Input (SDI). */ 5475 5500 { 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 } 5480 5550 #endif 5481 5551 } -
trunk/src/VBox/Devices/Makefile.kmk
r67429 r67438 581 581 # Disabled for AC'97 for now. 582 582 #VBoxDD_DEFS += VBOX_WITH_AUDIO_AC97_ASYNC_IO 583 #VBoxDD_DEFS += VBOX_WITH_AUDIO_HDA_ASYNC_IO583 VBoxDD_DEFS += VBOX_WITH_AUDIO_HDA_ASYNC_IO 584 584 585 585 # Not yet enabled: Callbacks for the device emulation to let the backends
Note:
See TracChangeset
for help on using the changeset viewer.