Changeset 68355 in vbox for trunk/src/VBox
- Timestamp:
- Aug 9, 2017 3:09:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
r68303 r68355 66 66 ( (PDRVHOSTPULSEAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTPULSEAUDIO, IHostAudio)) ) 67 67 68 #define PULSEAUDIO_ASYNC 68 69 69 70 /********************************************************************************************************************************* … … 124 125 /** Current latency (in us). */ 125 126 uint64_t curLatencyUs; 127 #ifdef LOG_ENABLED 126 128 /** Start time stamp (in us) of stream playback / recording. */ 127 129 pa_usec_t tsStartUs; 130 /** Time stamp (in us) when last read from / written to the stream. */ 131 pa_usec_t tsLastReadWrittenUs; 132 #endif 128 133 } PULSEAUDIOSTREAM, *PPULSEAUDIOSTREAM; 129 134 … … 590 595 } 591 596 597 #ifdef LOG_ENABLED 592 598 pStreamPA->tsStartUs = pa_rtclock_now(); 593 599 #endif 594 600 if (RT_FAILURE(rc)) 595 601 break; … … 745 751 pStreamPA->SampleSpec.channels = pCfgReq->Props.cChannels; 746 752 747 pStreamPA->curLatencyUs = 100 * 1000; /** 10 0ms latency by default. @todo Make this configurable. */748 749 LogRel2(("PulseAudio: Initial output latency is %RU64ms\n", pStreamPA->curLatencyUs / 1000 /* ms */));750 751 const uint32_t mixsize = pa_usec_to_bytes(pStreamPA->curLatencyUs, &pStreamPA->SampleSpec);752 753 pStreamPA->BufAttr. maxlength = mixsize * 4;754 pStreamPA->BufAttr. tlength = mixsize;755 pStreamPA->BufAttr.prebuf = mixsize * 2;756 pStreamPA->BufAttr.minreq = mixsize;753 pStreamPA->curLatencyUs = 100 * 1000; /** 10ms latency by default. @todo Make this configurable. */ 754 755 const uint32_t cbLatency = pa_usec_to_bytes(pStreamPA->curLatencyUs, &pStreamPA->SampleSpec); 756 757 LogRel2(("PulseAudio: Initial output latency is %RU64ms (%RU32 bytes)\n", pStreamPA->curLatencyUs / 1000 /* ms */, cbLatency)); 758 759 pStreamPA->BufAttr.tlength = cbLatency; 760 pStreamPA->BufAttr.maxlength = (pStreamPA->BufAttr.tlength * 3) / 2; 761 pStreamPA->BufAttr.prebuf = cbLatency; 762 pStreamPA->BufAttr.minreq = (uint32_t)-1; /* PulseAudio should set something sensible for minreq on it's own. */ 757 763 758 764 LogFunc(("BufAttr tlength=%RU32, maxLength=%RU32, minReq=%RU32\n", … … 951 957 uint32_t *pcxWritten) 952 958 { 953 RT_NOREF(pvBuf, cxBuf);954 959 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 955 960 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 967 972 pa_threaded_mainloop_lock(pThis->pMainLoop); 968 973 974 #ifdef LOG_ENABLED 975 const pa_usec_t tsNowUs = pa_rtclock_now(); 976 const pa_usec_t tsDeltaPlayedUs = tsNowUs - pPAStream->tsLastReadWrittenUs; 977 978 Log3Func(("tsDeltaPlayedMs=%RU64\n", tsDeltaPlayedUs / 1000 /* ms */)); 979 980 pPAStream->tsLastReadWrittenUs = tsNowUs; 981 #endif 982 969 983 do 970 984 { … … 977 991 978 992 size_t cbLeft = RT_MIN(cbWriteable, cxBuf); 993 Assert(cbLeft); /* At this point we better have *something* to write. */ 979 994 980 995 while (cbLeft) 981 996 { 982 size_t cbToWrite = RT_MIN(cbLeft, pa_stream_writable_size(pPAStream->pStream)); 983 if (cbToWrite <= (size_t)0) 984 break; 985 986 if (pa_stream_write(pPAStream->pStream, (uint8_t *)pvBuf + cbWrittenTotal, cbToWrite, NULL /* Cleanup callback */, 997 uint32_t cbChunk = cbLeft; /* Write all at once for now. */ 998 999 if (pa_stream_write(pPAStream->pStream, (uint8_t *)pvBuf + cbWrittenTotal, cbChunk, NULL /* Cleanup callback */, 987 1000 0, PA_SEEK_RELATIVE) < 0) 988 1001 { … … 991 1004 } 992 1005 993 Assert(cbLeft >= cb ToWrite);994 cbLeft -= cb ToWrite;995 cbWrittenTotal += cb ToWrite;1006 Assert(cbLeft >= cbChunk); 1007 cbLeft -= cbChunk; 1008 cbWrittenTotal += cbChunk; 996 1009 } 997 1010 … … 1285 1298 else 1286 1299 { 1287 rc = paWaitFor(pThis, pa_stream_cork(pStreamPA->pStream, 0, paStreamCbSuccess, pStreamPA)); 1300 /* Uncork (resume) stream. */ 1301 rc = paWaitFor(pThis, pa_stream_cork(pStreamPA->pStream, 0 /* Uncork */, paStreamCbSuccess, pStreamPA)); 1288 1302 } 1289 1303
Note:
See TracChangeset
for help on using the changeset viewer.