Lines Matching refs:caVoice
554 caVoiceOut *caVoice = (caVoiceOut *) inClientData;
562 uSize = sizeof(caVoice->audioDeviceId);
566 if (caVoice->audioDeviceId != ad)
572 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_REINIT);
617 caVoiceOut *caVoice = (caVoiceOut *) inRefCon;
619 if (ASMAtomicReadU32(&caVoice->status) != CA_STATUS_INIT)
623 csAvail = IORingBufferUsed(caVoice->pBuf) >> caVoice->hw.info.shift; /* bytes -> samples */
626 csAvail = RT_MIN(csAvail, ioData->mBuffers[0].mDataByteSize >> caVoice->hw.info.shift);
628 CA_EXT_DEBUG_LOG(("CoreAudio: [Output] Start reading buffer with %RU32 samples (%RU32 bytes)\n", csAvail, csAvail << caVoice->hw.info.shift));
635 cbToRead = csToRead << caVoice->hw.info.shift; /* samples -> bytes */
638 IORingBufferAquireReadBlock(caVoice->pBuf, cbToRead, &pcSrc, &cbToRead);
640 csToRead = cbToRead >> caVoice->hw.info.shift; /* bytes -> samples */
646 memcpy((char*)ioData->mBuffers[0].mData + (csReads << caVoice->hw.info.shift), pcSrc, cbToRead);
648 IORingBufferReleaseReadBlock(caVoice->pBuf, cbToRead);
653 ioData->mBuffers[0].mDataByteSize = csReads << caVoice->hw.info.shift; /* samples -> bytes */
655 CA_EXT_DEBUG_LOG(("CoreAudio: [Output] Finished reading buffer with %RU32 samples (%RU32 bytes)\n", csReads, csReads << caVoice->hw.info.shift));
674 caVoiceOut *caVoice = (caVoiceOut *) hw;
676 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_IN_INIT);
678 if (caVoice->audioDeviceId == kAudioDeviceUnknown)
681 uSize = sizeof(caVoice->audioDeviceId);
684 &caVoice->audioDeviceId);
695 err = AudioDeviceGetProperty(caVoice->audioDeviceId,
705 err = AudioDeviceGetProperty(caVoice->audioDeviceId,
727 err = AudioDeviceGetProperty(caVoice->audioDeviceId,
740 err = caSetFrameBufferSize(caVoice->audioDeviceId,
765 err = OpenAComponent(cp, &caVoice->audioUnit);
774 err = AudioUnitSetProperty(caVoice->audioUnit,
787 err = AudioUnitSetProperty(caVoice->audioUnit,
791 &caVoice->audioDeviceId,
792 sizeof(caVoice->audioDeviceId));
803 cb.inputProcRefCon = caVoice;
805 err = AudioUnitSetProperty(caVoice->audioUnit,
819 /* err = AudioUnitSetProperty(caVoice->audioUnit,*/
830 uSize = sizeof(caVoice->deviceFormat);
831 err = AudioUnitGetProperty(caVoice->audioUnit,
835 &caVoice->deviceFormat,
845 caPCMInfoToAudioStreamBasicDescription(&caVoice->hw.info, &caVoice->streamFormat);
848 caDebugOutputAudioStreamBasicDescription("CoreAudio: [Output] device", &caVoice->deviceFormat);
849 caDebugOutputAudioStreamBasicDescription("CoreAudio: [Output] output", &caVoice->streamFormat);
853 err = AudioUnitSetProperty(caVoice->audioUnit,
857 &caVoice->streamFormat,
858 sizeof(caVoice->streamFormat));
865 uSize = sizeof(caVoice->deviceFormat);
866 err = AudioUnitGetProperty(caVoice->audioUnit,
870 &caVoice->deviceFormat,
881 err = AudioUnitSetProperty(caVoice->audioUnit,
894 err = AudioUnitInitialize(caVoice->audioUnit);
905 err = AudioUnitGetProperty(caVoice->audioUnit,
918 cSamples = cFrames * caVoice->streamFormat.mChannelsPerFrame;
919 IORingBufferCreate(&caVoice->pBuf, cSamples << hw->info.shift);
920 if (!RT_VALID_PTR(caVoice->pBuf))
923 AudioUnitUninitialize(caVoice->audioUnit);
932 err = AudioDeviceAddPropertyListener(caVoice->audioDeviceId,
937 caVoice);
943 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_INIT);
952 caVoiceOut *caVoice = (caVoiceOut *) hw;
954 coreaudio_fini_out(&caVoice->hw);
955 caInitOutput(&caVoice->hw);
957 coreaudio_ctl_out(&caVoice->hw, VOICE_ENABLE);
969 caVoiceOut *caVoice = (caVoiceOut *) hw;
972 if (ASMAtomicReadU32(&caVoice->status) == CA_STATUS_REINIT)
973 caReinitOutput(&caVoice->hw);
977 if (ASMAtomicReadU32(&caVoice->status) != CA_STATUS_INIT)
981 coreaudio_ctl_out(&caVoice->hw, VOICE_ENABLE);
984 csAvail = IORingBufferFree(caVoice->pBuf) >> hw->info.shift; /* bytes -> samples */
999 IORingBufferAquireWriteBlock(caVoice->pBuf, cbToWrite, &pcDst, &cbToWrite);
1010 IORingBufferReleaseWriteBlock(caVoice->pBuf, cbToWrite);
1031 caVoiceOut *caVoice = (caVoiceOut *) hw;
1033 status = ASMAtomicReadU32(&caVoice->status);
1043 if (!caIsRunning(caVoice->audioDeviceId))
1045 err = AudioUnitReset(caVoice->audioUnit,
1048 IORingBufferReset(caVoice->pBuf);
1049 err = AudioOutputUnitStart(caVoice->audioUnit);
1061 if (caIsRunning(caVoice->audioDeviceId))
1063 err = AudioOutputUnitStop(caVoice->audioUnit);
1069 err = AudioUnitReset(caVoice->audioUnit,
1089 caVoiceOut *caVoice = (caVoiceOut *) hw;
1091 status = ASMAtomicReadU32(&caVoice->status);
1099 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_IN_UNINIT);
1101 err = AudioDeviceRemovePropertyListener(caVoice->audioDeviceId,
1110 err = AudioUnitUninitialize(caVoice->audioUnit);
1113 err = CloseComponent(caVoice->audioUnit);
1116 IORingBufferDestroy(caVoice->pBuf);
1117 caVoice->audioUnit = NULL;
1118 caVoice->audioDeviceId = kAudioDeviceUnknown;
1119 caVoice->pBuf = NULL;
1120 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_UNINIT);
1138 caVoiceOut *caVoice = (caVoiceOut *) hw;
1140 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_UNINIT);
1141 caVoice->audioUnit = NULL;
1142 caVoice->audioDeviceId = kAudioDeviceUnknown;
1153 caVoice->audioDeviceId = caDeviceUIDtoID(conf.pszOutputDeviceUID);
1155 if (caVoice->audioDeviceId == kAudioDeviceUnknown)
1166 hw->samples = (IORingBufferSize(caVoice->pBuf) >> hw->info.shift) / caVoice->streamFormat.mChannelsPerFrame;
1174 caVoice);
1209 caVoiceIn *caVoice = (caVoiceIn *) inClientData;
1217 uSize = sizeof(caVoice->audioDeviceId);
1221 if (caVoice->audioDeviceId != ad)
1227 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_REINIT);
1243 caVoiceIn *caVoice = (caVoiceIn *) inClientData;
1260 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_REINIT);
1280 caVoiceIn *caVoice = (caVoiceIn *) inUserData;
1282 const AudioBufferList *pBufferList = &caVoice->bufferList;
1284 if (ASMAtomicReadU32(&caVoice->status) != CA_STATUS_INIT)
1291 cSize = RT_MIN(*ioNumberDataPackets * caVoice->deviceFormat.mBytesPerPacket,
1292 pBufferList->mBuffers[0].mDataByteSize - caVoice->rpos);
1294 *ioNumberDataPackets = cSize / caVoice->deviceFormat.mBytesPerPacket;
1307 ioData->mBuffers[0].mData = (char*)pBufferList->mBuffers[0].mData + caVoice->rpos;
1308 caVoice->rpos += cSize;
1310 /* Log2(("converting .... ################ %RU32 %RU32\n", size, caVoice->rpos));*/
1333 caVoiceIn *caVoice = (caVoiceIn *) inRefCon;
1335 if (ASMAtomicReadU32(&caVoice->status) != CA_STATUS_INIT)
1343 if (RT_VALID_PTR(caVoice->converter))
1346 caVoice->bufferList.mBuffers[0].mNumberChannels = caVoice->deviceFormat.mChannelsPerFrame;
1347 caVoice->bufferList.mBuffers[0].mDataByteSize = caVoice->deviceFormat.mBytesPerFrame * inNumberFrames;
1348 caVoice->bufferList.mBuffers[0].mData = RTMemAlloc(caVoice->bufferList.mBuffers[0].mDataByteSize);
1350 err = AudioUnitRender(caVoice->audioUnit,
1355 &caVoice->bufferList);
1359 RTMemFree(caVoice->bufferList.mBuffers[0].mData);
1364 csAvail = IORingBufferFree(caVoice->pBuf) >> caVoice->hw.info.shift; /* bytes -> samples */
1367 csAvail = RT_MIN(csAvail, (uint32_t)((caVoice->bufferList.mBuffers[0].mDataByteSize / caVoice->deviceFormat.mBytesPerFrame) * caVoice->sampleRatio));
1369 CA_EXT_DEBUG_LOG(("CoreAudio: [Input] Start writing buffer with %RU32 samples (%RU32 bytes)\n", csAvail, csAvail << caVoice->hw.info.shift));
1372 tmpList.mBuffers[0].mNumberChannels = caVoice->streamFormat.mChannelsPerFrame;
1374 caVoice->rpos = 0;
1380 cbToWrite = csToWrite << caVoice->hw.info.shift;
1383 IORingBufferAquireWriteBlock(caVoice->pBuf, cbToWrite, &pcDst, &cbToWrite);
1385 csToWrite = cbToWrite >> caVoice->hw.info.shift;
1392 ioOutputDataPacketSize = cbToWrite / caVoice->streamFormat.mBytesPerPacket;
1396 AudioConverterReset(caVoice->converter);
1397 err = AudioConverterFillComplexBuffer(caVoice->converter,
1399 caVoice,
1411 cbToWrite = ioOutputDataPacketSize * caVoice->streamFormat.mBytesPerPacket;
1412 csToWrite = cbToWrite >> caVoice->hw.info.shift;
1414 IORingBufferReleaseWriteBlock(caVoice->pBuf, cbToWrite);
1422 RTMemFree(caVoice->bufferList.mBuffers[0].mData);
1423 CA_EXT_DEBUG_LOG(("CoreAudio: [Input] Finished writing buffer with %RU32 samples (%RU32 bytes)\n", csWritten, csWritten << caVoice->hw.info.shift));
1427 caVoice->bufferList.mBuffers[0].mNumberChannels = caVoice->streamFormat.mChannelsPerFrame;
1428 caVoice->bufferList.mBuffers[0].mDataByteSize = caVoice->streamFormat.mBytesPerFrame * inNumberFrames;
1429 caVoice->bufferList.mBuffers[0].mData = RTMemAlloc(caVoice->bufferList.mBuffers[0].mDataByteSize);
1431 err = AudioUnitRender(caVoice->audioUnit,
1436 &caVoice->bufferList);
1440 RTMemFree(caVoice->bufferList.mBuffers[0].mData);
1445 csAvail = IORingBufferFree(caVoice->pBuf) >> caVoice->hw.info.shift; /* bytes -> samples */
1448 csAvail = RT_MIN(csAvail, caVoice->bufferList.mBuffers[0].mDataByteSize >> caVoice->hw.info.shift);
1450 CA_EXT_DEBUG_LOG(("CoreAudio: [Input] Start writing buffer with %RU32 samples (%RU32 bytes)\n", csAvail, csAvail << caVoice->hw.info.shift));
1457 cbToWrite = csToWrite << caVoice->hw.info.shift;
1460 IORingBufferAquireWriteBlock(caVoice->pBuf, cbToWrite, &pcDst, &cbToWrite);
1462 csToWrite = cbToWrite >> caVoice->hw.info.shift;
1468 memcpy(pcDst, (char*)caVoice->bufferList.mBuffers[0].mData + (csWritten << caVoice->hw.info.shift), cbToWrite);
1470 IORingBufferReleaseWriteBlock(caVoice->pBuf, cbToWrite);
1474 RTMemFree(caVoice->bufferList.mBuffers[0].mData);
1476 CA_EXT_DEBUG_LOG(("CoreAudio: [Input] Finished writing buffer with %RU32 samples (%RU32 bytes)\n", csWritten, csWritten << caVoice->hw.info.shift));
1498 caVoiceIn *caVoice = (caVoiceIn *) hw;
1500 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_IN_INIT);
1502 if (caVoice->audioDeviceId == kAudioDeviceUnknown)
1505 uSize = sizeof(caVoice->audioDeviceId);
1508 &caVoice->audioDeviceId);
1519 err = AudioDeviceGetProperty(caVoice->audioDeviceId,
1529 err = AudioDeviceGetProperty(caVoice->audioDeviceId,
1553 err = AudioDeviceGetProperty(caVoice->audioDeviceId,
1566 err = caSetFrameBufferSize(caVoice->audioDeviceId,
1591 err = OpenAComponent(cp, &caVoice->audioUnit);
1600 err = AudioUnitSetProperty(caVoice->audioUnit,
1615 err = AudioUnitSetProperty(caVoice->audioUnit,
1628 err = AudioUnitSetProperty(caVoice->audioUnit,
1632 &caVoice->audioDeviceId,
1633 sizeof(caVoice->audioDeviceId));
1644 cb.inputProcRefCon = caVoice;
1646 err = AudioUnitSetProperty(caVoice->audioUnit,
1659 uSize = sizeof(caVoice->deviceFormat);
1660 err = AudioUnitGetProperty(caVoice->audioUnit,
1664 &caVoice->deviceFormat,
1674 caPCMInfoToAudioStreamBasicDescription(&caVoice->hw.info, &caVoice->streamFormat);
1677 caDebugOutputAudioStreamBasicDescription("CoreAudio: [Input] device", &caVoice->deviceFormat);
1678 caDebugOutputAudioStreamBasicDescription("CoreAudio: [Input] input", &caVoice->streamFormat);
1683 if ( caVoice->deviceFormat.mSampleRate != caVoice->streamFormat.mSampleRate
1684 || caVoice->deviceFormat.mChannelsPerFrame != caVoice->streamFormat.mChannelsPerFrame)
1686 err = AudioConverterNew(&caVoice->deviceFormat,
1687 &caVoice->streamFormat,
1688 &caVoice->converter);
1695 if (caVoice->deviceFormat.mChannelsPerFrame == 1 &&
1696 caVoice->streamFormat.mChannelsPerFrame == 2)
1703 err = AudioConverterSetProperty(caVoice->converter,
1715 /* err = AudioConverterSetProperty(caVoice->converter,*/
1725 err = AudioUnitSetProperty(caVoice->audioUnit,
1729 &caVoice->deviceFormat,
1730 sizeof(caVoice->deviceFormat));
1736 err = AudioUnitSetProperty(caVoice->audioUnit,
1740 &caVoice->deviceFormat,
1741 sizeof(caVoice->deviceFormat));
1751 err = AudioUnitSetProperty(caVoice->audioUnit,
1755 &caVoice->streamFormat,
1756 sizeof(caVoice->streamFormat));
1767 err = AudioUnitSetProperty(caVoice->audioUnit,
1780 err = AudioUnitInitialize(caVoice->audioUnit);
1787 uSize = sizeof(caVoice->deviceFormat);
1788 err = AudioUnitGetProperty(caVoice->audioUnit,
1792 &caVoice->deviceFormat,
1804 err = AudioUnitGetProperty(caVoice->audioUnit,
1817 caVoice->sampleRatio = caVoice->streamFormat.mSampleRate / caVoice->deviceFormat.mSampleRate;
1820 caVoice->pBuf = NULL;
1822 caVoice->bufferList.mNumberBuffers = 1;
1824 caVoice->bufferList.mBuffers[0].mNumberChannels = caVoice->streamFormat.mChannelsPerFrame;
1825 caVoice->bufferList.mBuffers[0].mDataByteSize = 0;
1826 caVoice->bufferList.mBuffers[0].mData = NULL;
1834 (cFrames * caVoice->deviceFormat.mBytesPerFrame * caVoice->sampleRatio) / caVoice->streamFormat.mBytesPerFrame)
1835 * caVoice->streamFormat.mChannelsPerFrame;
1840 IORingBufferCreate(&caVoice->pBuf, cSamples << hw->info.shift);
1841 if (RT_VALID_PTR(caVoice->pBuf))
1848 if (caVoice->pBuf)
1849 IORingBufferDestroy(caVoice->pBuf);
1850 AudioUnitUninitialize(caVoice->audioUnit);
1855 err = AudioDeviceAddPropertyListener(caVoice->audioDeviceId,
1860 caVoice);
1865 err = AudioDeviceAddPropertyListener(caVoice->audioDeviceId,
1870 caVoice);
1875 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_INIT);
1884 caVoiceIn *caVoice = (caVoiceIn *) hw;
1886 coreaudio_fini_in(&caVoice->hw);
1887 caInitInput(&caVoice->hw);
1889 coreaudio_ctl_in(&caVoice->hw, VOICE_ENABLE);
1901 caVoiceIn *caVoice = (caVoiceIn *) hw;
1904 if (ASMAtomicReadU32(&caVoice->status) == CA_STATUS_REINIT)
1905 caReinitInput(&caVoice->hw);
1907 if (ASMAtomicReadU32(&caVoice->status) != CA_STATUS_INIT)
1911 csAvail = IORingBufferUsed(caVoice->pBuf) >> hw->info.shift; /* bytes -> samples */
1916 CA_EXT_DEBUG_LOG(("CoreAudio: [Input] Start reading buffer with %RU32 samples (%RU32 bytes)\n", csAvail, csAvail << caVoice->hw.info.shift));
1926 IORingBufferAquireReadBlock(caVoice->pBuf, cbToRead, &pcSrc, &cbToRead);
1937 IORingBufferReleaseReadBlock(caVoice->pBuf, cbToRead);
1943 CA_EXT_DEBUG_LOG(("CoreAudio: [Input] Finished reading buffer with %RU32 samples (%RU32 bytes)\n", csReads, csReads << caVoice->hw.info.shift));
1957 caVoiceIn *caVoice = (caVoiceIn *) hw;
1959 status = ASMAtomicReadU32(&caVoice->status);
1969 if (!caIsRunning(caVoice->audioDeviceId))
1971 IORingBufferReset(caVoice->pBuf);
1972 err = AudioOutputUnitStart(caVoice->audioUnit);
1984 if (caIsRunning(caVoice->audioDeviceId))
1986 err = AudioOutputUnitStop(caVoice->audioUnit);
1992 err = AudioUnitReset(caVoice->audioUnit,
2012 caVoiceIn *caVoice = (caVoiceIn *) hw;
2014 status = ASMAtomicReadU32(&caVoice->status);
2022 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_IN_UNINIT);
2024 err = AudioDeviceRemovePropertyListener(caVoice->audioDeviceId,
2033 err = AudioDeviceRemovePropertyListener(caVoice->audioDeviceId,
2041 if (caVoice->converter)
2043 AudioConverterDispose(caVoice->converter);
2044 caVoice->converter = NULL;
2046 err = AudioUnitUninitialize(caVoice->audioUnit);
2049 err = CloseComponent(caVoice->audioUnit);
2052 IORingBufferDestroy(caVoice->pBuf);
2053 caVoice->audioUnit = NULL;
2054 caVoice->audioDeviceId = kAudioDeviceUnknown;
2055 caVoice->pBuf = NULL;
2056 caVoice->sampleRatio = 1;
2057 caVoice->rpos = 0;
2058 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_UNINIT);
2076 caVoiceIn *caVoice = (caVoiceIn *) hw;
2078 ASMAtomicXchgU32(&caVoice->status, CA_STATUS_UNINIT);
2079 caVoice->audioUnit = NULL;
2080 caVoice->audioDeviceId = kAudioDeviceUnknown;
2081 caVoice->converter = NULL;
2082 caVoice->sampleRatio = 1;
2083 caVoice->rpos = 0;
2092 caVoice->audioDeviceId = caDeviceUIDtoID(conf.pszInputDeviceUID);
2094 if (caVoice->audioDeviceId == kAudioDeviceUnknown)
2105 hw->samples = (IORingBufferSize(caVoice->pBuf) >> hw->info.shift) / caVoice->streamFormat.mChannelsPerFrame;
2113 caVoice);