Changeset 63927 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Sep 21, 2016 3:26:08 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 110811
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r63922 r63927 1880 1880 return VERR_GENERAL_FAILURE; /** @todo Fudge! */ 1881 1881 1882 /* Signal the main thread. */ 1883 RTThreadUserSignal(RTThreadSelf()); 1884 1882 1885 /* 1883 * Start the queue.1886 * Enter the main loop. 1884 1887 */ 1885 err = AudioQueueStart(pCAStream->audioQueue, NULL);1886 1887 RTThreadUserSignal(RTThreadSelf());1888 1889 1888 const bool fIn = pCAStream->enmDir == PDMAUDIODIR_IN; 1890 1889 … … 1894 1893 } 1895 1894 1895 /* 1896 * Cleanup. 1897 */ 1896 1898 if (fIn) 1897 1899 { … … 1919 1921 UInt32 cPacketDesc, const AudioStreamPacketDescription *paPacketDesc) 1920 1922 { 1921 RT_NOREF( pAudioTS, cPacketDesc, paPacketDesc);1923 RT_NOREF(audioQueue, pAudioTS, cPacketDesc, paPacketDesc); 1922 1924 1923 1925 PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser; … … 1947 1949 RTCircBufAcquireWriteBlock(pCircBuf, cbLeft, (void **)&pvDst, &cbToWrite); 1948 1950 1951 if (!cbToWrite) 1952 break; 1953 1949 1954 /* Copy the data from our ring buffer to the core audio buffer. */ 1950 1955 memcpy((UInt8 *)pvDst + cbWritten, pvSrc + cbWritten, cbToWrite); 1951 1956 1952 1957 /* Release the read buffer, so it could be used for new data. */ 1953 RTCircBufRelease ReadBlock(pCircBuf, cbToWrite);1958 RTCircBufReleaseWriteBlock(pCircBuf, cbToWrite); 1954 1959 1955 1960 cbWritten += cbToWrite; … … 1960 1965 } 1961 1966 1962 if (cbWritten)1963 {1964 OSStatus err = AudioQueueEnqueueBuffer(audioQueue, audioBuffer, 0, NULL);1965 if (err != noErr)1966 LogFunc(("Failed writing %zu bytes\n", cbWritten));1967 }1968 1969 LogFunc(("pCAStream=%p, fRunning=%RTbool, cbWritten=%zu\n", pCAStream, fRunning, cbWritten));1970 1971 1967 rc = RTCritSectLeave(&pCAStream->CritSect); 1972 1968 AssertRC(rc); 1969 1970 audioBuffer->mAudioDataByteSize = cbWritten; 1971 1972 AudioQueueEnqueueBuffer(pCAStream->audioQueue, audioBuffer, 0, NULL); 1973 1974 Log3Func(("pCAStream=%p, fRunning=%RTbool, cbWritten=%zu\n", pCAStream, fRunning, cbWritten)); 1973 1975 } 1974 1976 1975 1977 static void coreAudioOutputQueueCb(void *pvUser, AudioQueueRef audioQueue, AudioQueueBufferRef audioBuffer) 1976 1978 { 1979 RT_NOREF(audioQueue); 1980 1977 1981 PCOREAUDIOSTREAM pCAStream = (PCOREAUDIOSTREAM)pvUser; 1978 1982 AssertPtr(pCAStream); … … 2030 2034 } 2031 2035 2032 AudioQueueEnqueueBuffer( audioQueue, audioBuffer, 0, NULL);2033 2034 Log Func(("pCAStream=%p, fRunning=%RTbool, cbCapacity=%RU32, cbRead=%zu\n",2035 pCAStream, fRunning, audioBuffer->mAudioDataBytesCapacity, cbRead));2036 AudioQueueEnqueueBuffer(pCAStream->audioQueue, audioBuffer, 0, NULL); 2037 2038 Log3Func(("pCAStream=%p, fRunning=%RTbool, cbCapacity=%RU32, cbRead=%zu\n", 2039 pCAStream, fRunning, audioBuffer->mAudioDataBytesCapacity, cbRead)); 2036 2040 2037 2041 rc = RTCritSectLeave(&pCAStream->CritSect); … … 2064 2068 : "Playback queue format", &pCAStream->asbdAcq); 2065 2069 2066 rc = RTCircBufCreate(&pCAStream->pCircBuf, 4096 << 1 /*pHstStrmIn->Props.cShift*/); /** @todo FIX THIS !!! */2070 rc = RTCircBufCreate(&pCAStream->pCircBuf, 8096 << 1 /*pHstStrmIn->Props.cShift*/); /** @todo FIX THIS !!! */ 2067 2071 if (RT_FAILURE(rc)) 2068 2072 return rc; … … 3128 3132 uint32_t cbWrittenTotal = 0; 3129 3133 3134 #ifdef VBOX_WITH_AUDIO_CA_QUEUES 3135 rc = RTCritSectEnter(&pCAStream->CritSect); 3136 AssertRC(rc); 3137 #endif 3138 3130 3139 do 3131 3140 { … … 3135 3144 uint32_t cWritten, cbWritten; 3136 3145 uint8_t *puBuf; 3137 size_t cbToRead ;3146 size_t cbToRead = 0; 3138 3147 3139 3148 Log3Func(("cbMixBuf=%zu, cbToWrite=%zu/%zu\n", cbMixBuf, cbToWrite, RTCircBufSize(pCAStream->pCircBuf))); … … 3144 3153 RTCircBufAcquireReadBlock(pCAStream->pCircBuf, cbToWrite, (void **)&puBuf, &cbToRead); 3145 3154 if (!cbToRead) 3146 {3147 RTCircBufReleaseReadBlock(pCAStream->pCircBuf, cbToRead);3148 3155 break; 3149 }3150 3156 3151 3157 #ifdef DEBUG_DUMP_PCM_DATA … … 3169 3175 || !cWritten) 3170 3176 { 3171 RTCircBufReleaseReadBlock(pCAStream->pCircBuf, cbToRead);3172 3177 break; 3173 3178 } … … 3183 3188 } 3184 3189 while (0); 3190 3191 #ifdef VBOX_WITH_AUDIO_CA_QUEUES 3192 int rc2 = RTCritSectLeave(&pCAStream->CritSect); 3193 AssertRC(rc2); 3194 #endif 3185 3195 3186 3196 if (RT_SUCCESS(rc)) … … 3340 3350 LogFunc(("Queue enable/resume\n")); 3341 3351 ASMAtomicXchgBool(&pCAStream->fRunning, true); 3352 3353 AudioQueueStart(pCAStream->audioQueue, NULL); 3342 3354 #else 3343 3355 /* Only start the device if it is actually stopped */ … … 3370 3382 LogFunc(("Queue disable/pause\n")); 3371 3383 ASMAtomicXchgBool(&pCAStream->fRunning, false); 3384 3385 AudioQueuePause(pCAStream->audioQueue); 3372 3386 #else 3373 3387 /* Only stop the device if it is actually running */ … … 3559 3573 3560 3574 rc = coreAudioStreamInitQueue(pCAStream, pCfgReq, pCfgAcq); 3575 3576 pCfgAcq->cSampleBufferSize = _4K; /** @todo FIX THIS !!! */ 3561 3577 #else 3562 3578 if (fIn)
Note:
See TracChangeset
for help on using the changeset viewer.