Changeset 65018 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Dec 28, 2016 11:21:57 AM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r65013 r65018 4647 4647 { 4648 4648 int rc2; 4649 uint32_t cbDMA = 0; 4649 4650 4650 4651 if (hdaGetDirFromSD(pStream->u8SD) == PDMAUDIODIR_OUT) /* Output (SDO). */ … … 4656 4657 */ 4657 4658 4658 uint8_t 4659 uint32_t cbProcessed= 0;4659 uint8_t abFIFO[HDA_FIFO_MAX + 1]; 4660 size_t offFIFO = 0; 4660 4661 4661 4662 /* Do one DMA transfer with FIFOS size at a time. */ 4662 rc2 = hdaStreamDoDMA(pThis, pStream, abFIFO, sizeof(abFIFO), (uint32_t)pStream->u16FIFOS /* cbToProcess */, 4663 &cbProcessed); 4663 rc2 = hdaStreamDoDMA(pThis, pStream, abFIFO, sizeof(abFIFO), (uint32_t)pStream->u16FIFOS /* cbToProcess */, &cbDMA); 4664 4664 AssertRC(rc2); 4665 4665 4666 if (cbProcessed) 4666 uint32_t cbDMALeft = cbDMA; 4667 4668 while ( cbDMALeft 4669 && RTCircBufFree(pCircBuf)) 4667 4670 { 4668 4671 void *pvDst; 4669 4672 size_t cbDst; 4670 4673 4671 Assert(pStream->u16FIFOS); 4672 RTCircBufAcquireWriteBlock(pCircBuf, cbProcessed, &pvDst, &cbDst); 4674 RTCircBufAcquireWriteBlock(pCircBuf, cbDMALeft, &pvDst, &cbDst); 4673 4675 4674 4676 if (cbDst) 4675 4677 { 4676 Assert(cbDst == cbProcessed); 4677 memcpy(pvDst, abFIFO, cbDst); 4678 memcpy(pvDst, abFIFO + offFIFO, cbDst); 4679 4680 offFIFO += cbDst; 4681 Assert(offFIFO <= sizeof(abFIFO)); 4678 4682 } 4679 4683 4680 4684 RTCircBufReleaseWriteBlock(pCircBuf, cbDst); 4685 4686 Assert(cbDst <= cbDMALeft); 4687 cbDMALeft -= (uint32_t)cbDst; 4681 4688 } 4682 4689 4690 #ifdef DEBUG_andy 4691 AssertMsg(cbDMALeft == 0, ("%RU32 bytes of DMA data left, CircBuf=%zu/%zu\n", 4692 cbDMALeft, RTCircBufUsed(pCircBuf), RTCircBufSize(pCircBuf))); 4693 #endif 4683 4694 /* 4684 4695 * Process backends. … … 4692 4703 hdaStreamAsyncIONotify(pThis, pStream); 4693 4704 #else 4705 /* Read audio data from the HDA stream and write to the backends. */ 4694 4706 rc2 = hdaStreamRead(pThis, pStream, cbUsed, NULL /* pcbRead */); 4695 4707 AssertRC(rc2); 4696 4708 #endif 4709 } 4710 4711 /* All DMA transfers done for now? */ 4712 if ( !cbDMA 4713 #ifndef VBOX_WITH_AUDIO_AC97_ASYNC_IO 4714 /* All data read *and* processed for now? */ 4715 && RTCircBufUsed(pCircBuf) == 0 4716 #endif 4717 ) 4718 { 4719 fDone = true; 4697 4720 } 4698 4721 … … 4701 4724 AssertRC(rc2); 4702 4725 #endif 4703 if (!cbProcessed)4704 fDone = true;4705 4706 4726 STAM_PROFILE_STOP(&pThis->StatOut, a); 4707 4727 } … … 4721 4741 AssertRC(rc2); 4722 4742 4743 /* Write read data from the backend to the HDA stream. */ 4723 4744 rc2 = hdaStreamWrite(pThis, pStream, pStream->u16FIFOS, NULL /* pcbWritten */); 4724 4745 AssertRC(rc2); … … 4733 4754 RTCircBufAcquireReadBlock(pCircBuf, pStream->u16FIFOS, &pvSrc, &cbSrc); 4734 4755 4735 uint32_t cbProcessed = 0;4736 4737 4756 if (cbSrc) 4738 4757 { 4739 4758 /* Do one DMA transfer with FIFOS size at a time. */ 4740 rc2 = hdaStreamDoDMA(pThis, pStream, pvSrc, (uint32_t)cbSrc, (uint32_t)cbSrc /* cbToProcess */, &cb Processed);4759 rc2 = hdaStreamDoDMA(pThis, pStream, pvSrc, (uint32_t)cbSrc, (uint32_t)cbSrc /* cbToProcess */, &cbDMA); 4741 4760 AssertRC(rc2); 4742 4761 } 4743 4762 4744 RTCircBufReleaseReadBlock(pCircBuf, cb Processed);4745 4746 if (!cb Processed)4763 RTCircBufReleaseReadBlock(pCircBuf, cbDMA); 4764 4765 if (!cbDMA) 4747 4766 fDone = true; 4748 4767 -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r65014 r65018 66 66 /** Default timer frequency (in Hz). */ 67 67 #define AC97_TIMER_HZ 100 68 69 /** Maximum FIFO size (in bytes). */ 70 #define AC97_FIFO_MAX 256 68 71 69 72 #define AC97_SR_FIFOE RT_BIT(4) /* rwc, FIFO error. */ … … 473 476 static int ichac97StreamReOpen(PAC97STATE pThis, PAC97STREAM pStream); 474 477 static int ichac97StreamClose(PAC97STATE pThis, PAC97STREAM pStream); 478 static void ichac97StreamReset(PAC97STATE pThis, PAC97STREAM pStream); 475 479 476 480 static DECLCALLBACK(void) ichac97Reset(PPDMDEVINS pDevIns); … … 691 695 pRegs->lvi = 0; 692 696 697 ichac97StreamReset(pThis, pStream); 698 693 699 ichac97StreamEnable(pThis, pStream, false /* fEnable */); 694 700 … … 913 919 int rc2 = AudioMixerSinkWrite(pDstMixSink, AUDMIXOP_COPY, pvSrc, (uint32_t)cbSrc, &cbWritten); 914 920 AssertRC(rc2); 921 922 #ifdef DEBUG_andy 923 Assert(cbWritten == cbSrc); 924 #endif 915 925 } 916 926 … … 1179 1189 bool fDone = false; 1180 1190 1181 Log Func(("[SD%RU8] Started\n", pStream->u8Strm));1191 Log3Func(("[SD%RU8] Started\n", pStream->u8Strm)); 1182 1192 1183 1193 while (!fDone) 1184 1194 { 1185 1195 int rc2; 1186 uint32_t cb Processed= 0;1196 uint32_t cbDMA = 0; 1187 1197 1188 1198 if (pStream->u8Strm == AC97SOUNDSOURCE_PO_INDEX) /* Output. */ … … 1193 1203 * Read from DMA. 1194 1204 */ 1195 1196 void *pvDst; 1197 size_t cbDst; 1198 1199 RTCircBufAcquireWriteBlock(pCircBuf, 256 /** @todo */, &pvDst, &cbDst); 1200 1201 if (cbDst) 1205 uint8_t abFIFO[AC97_FIFO_MAX + 1]; 1206 size_t offFIFO = 0; 1207 1208 /* Do one DMA transfer with FIFOS size at a time. */ 1209 rc2 = ichac97DoDMA(pThis, pStream, abFIFO, sizeof(abFIFO), AC97_FIFO_MAX /** @todo FIFOS? */, &cbDMA); 1210 AssertRC(rc2); 1211 1212 uint32_t cbDMALeft = cbDMA; 1213 1214 while ( cbDMALeft 1215 && RTCircBufFree(pCircBuf)) 1202 1216 { 1203 /* Do one DMA transfer with FIFOS size at a time. */ 1204 rc2 = ichac97DoDMA(pThis, pStream, pvDst, (uint32_t)cbDst, (uint32_t)cbDst /* cbToProcess */, &cbProcessed); 1205 AssertRC(rc2); 1217 Log3Func(("[SD%RU8] cbLeft=%RU32\n", pStream->u8Strm, cbDMALeft)); 1218 1219 void *pvDst; 1220 size_t cbDst; 1221 1222 RTCircBufAcquireWriteBlock(pCircBuf, cbDMALeft, &pvDst, &cbDst); 1223 1224 if (cbDst) 1225 { 1226 memcpy(pvDst, abFIFO + offFIFO, cbDst); 1227 1228 offFIFO += cbDst; 1229 Assert(offFIFO <= sizeof(abFIFO)); 1230 } 1231 1232 RTCircBufReleaseWriteBlock(pCircBuf, cbDst); 1233 1234 Assert(cbDst <= cbDMALeft); 1235 cbDMALeft -= (uint32_t)cbDst; 1206 1236 } 1207 1237 1208 RTCircBufReleaseWriteBlock(pCircBuf, cbProcessed); 1209 1238 #ifdef DEBUG_andy 1239 AssertMsg(cbDMALeft == 0, ("%RU32 bytes of DMA data left, CircBuf=%zu/%zu\n", 1240 cbDMALeft, RTCircBufUsed(pCircBuf), RTCircBufSize(pCircBuf))); 1241 #endif 1210 1242 /* 1211 1243 * Process backends. … … 1216 1248 if (cbUsed) 1217 1249 { 1250 Log3Func(("[SD%RU8] cbUsed=%RU32\n", pStream->u8Strm, cbUsed)); 1251 1218 1252 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1219 1253 /* Let the asynchronous thread know that there is some new data to process. */ … … 1221 1255 #else 1222 1256 /* Read audio data from the AC'97 stream and write to the backends. */ 1223 rc2 = ichac97StreamRead(pThis, pStream, pMixSink, cb Processed, NULL /* pcbRead */);1257 rc2 = ichac97StreamRead(pThis, pStream, pMixSink, cbUsed, NULL /* pcbRead */); 1224 1258 AssertRC(rc2); 1225 1259 #endif … … 1227 1261 1228 1262 /* All DMA transfers done for now? */ 1229 if ( !cb Processed1263 if ( !cbDMA 1230 1264 #ifndef VBOX_WITH_AUDIO_AC97_ASYNC_IO 1231 1265 /* All data read *and* processed for now? */ … … 1266 1300 * Write to DMA. 1267 1301 */ 1268 1269 1302 void *pvSrc; 1270 1303 size_t cbSrc; … … 1275 1308 { 1276 1309 /* Do one DMA transfer with FIFOS size at a time. */ 1277 rc2 = ichac97DoDMA(pThis, pStream, pvSrc, (uint32_t)cbSrc, (uint32_t)cbSrc /* cbToProcess */, &cb Processed);1310 rc2 = ichac97DoDMA(pThis, pStream, pvSrc, (uint32_t)cbSrc, (uint32_t)cbSrc /* cbToProcess */, &cbDMA); 1278 1311 AssertRC(rc2); 1279 1312 } 1280 1313 1281 RTCircBufReleaseReadBlock(pCircBuf, cb Processed);1314 RTCircBufReleaseReadBlock(pCircBuf, cbDMA); 1282 1315 1283 1316 /* All DMA transfers done for now? */ 1284 if (!cb Processed)1317 if (!cbDMA) 1285 1318 fDone = true; 1286 1319 … … 1616 1649 AssertPtrReturnVoid(pStream); 1617 1650 1618 LogF lowFunc(("[SD%RU8]\n", pStream->u8Strm));1651 LogFunc(("[SD%RU8] Reset\n", pStream->u8Strm)); 1619 1652 1620 1653 #ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO … … 1984 2017 uint32_t cbToProcess, uint32_t *pcbProcessed) 1985 2018 { 1986 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1987 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2019 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2020 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2021 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 2022 AssertReturn(cbBuf >= cbToProcess, VERR_INVALID_PARAMETER); 1988 2023 /* pcbProcessed is optional. */ 1989 2024 … … 2101 2136 { 2102 2137 cbTotal += cbChunk; 2138 Assert(cbTotal <= cbToProcess); 2103 2139 Assert(cbLeft >= cbChunk); 2104 2140 cbLeft -= cbChunk;
Note:
See TracChangeset
for help on using the changeset viewer.