this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

AudioToolbox compiling again

+202 -86
+12 -7
src/CoreAudio/AudioToolbox/AUComponent.cpp
··· 2 2 #include "AUComponent.h" 3 3 #include "AudioUnitALSA.h" 4 4 #include "AudioUnitPA.h" 5 - #include <util/debug.h> 6 5 #include <alsa/asoundlib.h> 7 6 #include <CoreServices/MacErrors.h> 7 + #include "stub.h" 8 8 9 9 AudioComponent AudioComponentFindNext(AudioComponent inAComponent, AudioComponentDescription *inDesc) 10 10 { 11 - TRACE2(inAComponent, inDesc); 12 - 13 11 int index = -1; 14 12 15 13 if (inDesc->componentType != kAudioUnitType_Output && inDesc->componentType != kAudioUnitType_Mixer) ··· 18 16 if (inAComponent != nullptr) 19 17 index = GetComponentIndex(inAComponent); 20 18 19 + #if defined(ENABLE_ALSA) 21 20 if (snd_card_next(&index) || index == -1) 22 21 return nullptr; 22 + #endif 23 23 24 24 return CreateComponent(kComponentTypeAudioUnit, index); 25 25 } ··· 48 48 49 49 OSStatus AudioComponentInstanceDispose(AudioComponentInstance inInstance) 50 50 { 51 - TRACE1(inInstance); 52 - 53 51 delete inInstance; 54 52 return noErr; 55 53 } ··· 61 59 62 60 OSStatus AudioComponentInstanceNew(AudioComponent inComponent, AudioComponentInstance *outInstance) 63 61 { 64 - TRACE1(inComponent); 65 - 66 62 #if defined(ENABLE_PULSEAUDIO) 67 63 *outInstance = new AudioUnitPA; 68 64 #elif defined(ENABLE_ALSA) ··· 82 78 if (!outName) 83 79 return paramErr; 84 80 81 + #if defined(ENABLE_ALSA) 85 82 if (snd_card_get_longname(index, &name)) 86 83 return paramErr; 84 + #elif defined(ENABLE_PULSEAUDIO) 85 + name = strdup("PulseAudio"); 86 + #endif 87 87 88 88 *outName = CFStringCreateWithCString(nullptr, name, kCFStringEncodingUTF8); 89 89 free(name); ··· 94 94 UInt32 AudioComponentCount(AudioComponentDescription *inDesc) 95 95 { 96 96 UInt32 count = 0; 97 + 98 + #if defined(ENABLE_ALSA) 97 99 int index = -1; 98 100 99 101 // Is there a better way? ··· 104 106 count++; 105 107 } 106 108 while (index != -1); 109 + #elif defined(ENABLE_PULSEAUDIO) 110 + count = 1; 111 + #endif 107 112 108 113 return count; 109 114 }
-1
src/CoreAudio/AudioToolbox/AudioConverter.cpp
··· 1 1 #include "AudioConverter.h" 2 2 #include "AudioConverterImpl.h" 3 3 #include <CoreServices/MacErrors.h> 4 - #include <util/debug.h> 5 4 #include <stdexcept> 6 5 #include <cstring> 7 6
+16 -14
src/CoreAudio/AudioToolbox/AudioConverterImpl.cpp
··· 1 1 #include "AudioConverterImpl.h" 2 2 #include <CoreServices/MacErrors.h> 3 - #include <util/debug.h> 4 3 #include <stdexcept> 5 4 #include <cstring> 5 + #include <cassert> 6 + #include <iostream> 7 + #include "stub.h" 6 8 7 9 extern "C" { 8 10 #include <libavcodec/avcodec.h> ··· 49 51 50 52 if (idIn == AV_CODEC_ID_NONE || idOut == AV_CODEC_ID_NONE) 51 53 { 52 - LOG << "AudioConverter::create(): Unsupported codec, format in = " << std::hex << inSourceFormat->mFormatID << ", out = " << inDestinationFormat->mFormatID << std::dec << std::endl; 54 + // LOG << "AudioConverter::create(): Unsupported codec, format in = " << std::hex << inSourceFormat->mFormatID << ", out = " << inDestinationFormat->mFormatID << std::dec << std::endl; 53 55 return paramErr; 54 56 } 55 57 ··· 58 60 59 61 if (!codecIn || !codecOut) 60 62 { 61 - LOG << "AudioConverter::create(): avcodec_find_*() failed, format in = " << std::hex << inSourceFormat->mFormatID << ", out = " << inDestinationFormat->mFormatID << std::dec << std::endl; 63 + // LOG << "AudioConverter::create(): avcodec_find_*() failed, format in = " << std::hex << inSourceFormat->mFormatID << ", out = " << inDestinationFormat->mFormatID << std::dec << std::endl; 62 64 return paramErr; 63 65 } 64 66 ··· 71 73 cIn->channels = inSourceFormat->mChannelsPerFrame; 72 74 cIn->sample_rate = inSourceFormat->mSampleRate; 73 75 74 - LOG << "Converting from PCM with " << cIn->channels << " channels at " << cIn->sample_rate << " Hz\n"; 76 + // LOG << "Converting from PCM with " << cIn->channels << " channels at " << cIn->sample_rate << " Hz\n"; 75 77 } 76 78 77 79 if (avcodec_open2((*out)->m_decoder, codecIn, nullptr) < 0) 78 80 { 79 81 delete *out; 80 - LOG << "AudioConverter::create(): avcodec_open() failed, format in = " << std::hex << inSourceFormat->mFormatID << ", out = " << inDestinationFormat->mFormatID << std::dec << std::endl; 82 + // LOG << "AudioConverter::create(): avcodec_open() failed, format in = " << std::hex << inSourceFormat->mFormatID << ", out = " << inDestinationFormat->mFormatID << std::dec << std::endl; 81 83 82 84 return paramErr; 83 85 } ··· 130 132 131 133 if (!audioSampleBuffer) 132 134 { 133 - ERROR() << "Failed to allocate sample buffer"; 135 + std::cerr << "AudioConverter::allocateBuffers(): Failed to allocate sample buffer\n"; 134 136 //return paramErr; // TODO 135 137 } 136 138 137 139 // Setup the data pointers in the AVFrame 138 140 if (avcodec_fill_audio_frame(m_audioFrame, m_encoder->channels, m_encoder->sample_fmt, (const uint8_t*) audioSampleBuffer, audioSampleBuffer_size, 0 ) < 0) 139 141 { 140 - ERROR() << "Could not set up audio frame"; 142 + std::cerr << "AudioConverter::allocateBuffers(): Could not set up audio frame\n"; 141 143 //return paramErr; // TODO 142 144 } 143 145 } ··· 261 263 m_avpkt.size = bufferList.mBuffers[0].mDataByteSize; 262 264 m_avpkt.data = (uint8_t*) bufferList.mBuffers[0].mData; 263 265 264 - LOG << "dataProc() returned " << m_avpkt.size << " bytes of data\n"; 266 + // LOG << "dataProc() returned " << m_avpkt.size << " bytes of data\n"; 265 267 266 268 return noErr; 267 269 } ··· 314 316 { 315 317 if (m_avpktOutUsed < m_avpktOut.size) 316 318 { 317 - LOG << "case 1 (used " << m_avpktOutUsed << " from " << m_avpktOut.size << ")\n"; 319 + // LOG << "case 1 (used " << m_avpktOutUsed << " from " << m_avpktOut.size << ")\n"; 318 320 // Feed output from previous conversion 319 321 while (m_avpktOutUsed < m_avpktOut.size && newSize < origSize) 320 322 { ··· 333 335 } 334 336 else if (!m_resampler || avresample_available(m_resampler) == 0) 335 337 { 336 - LOG << "case 2\n"; 338 + // LOG << "case 2\n"; 337 339 feedDecoder(dataProc, opaque, srcaudio); 338 340 if (avresample_available(m_resampler) == 0) 339 341 goto end; 340 342 } 341 343 else 342 344 { 343 - LOG << "case 3\n"; 345 + // LOG << "case 3\n"; 344 346 feedEncoder(); 345 347 } 346 348 } ··· 355 357 } 356 358 catch (const std::exception& e) 357 359 { 358 - ERROR() << "Exception: " << e.what(); 360 + // ERROR() << "Exception: " << e.what(); 359 361 #ifdef HAVE_AV_FRAME_ALLOC 360 362 av_frame_free(&srcaudio); 361 363 #else ··· 364 366 } 365 367 catch (OSStatus err) 366 368 { 367 - ERROR() << "OSStatus error: " << err; 369 + // ERROR() << "OSStatus error: " << err; 368 370 #ifdef HAVE_AV_FRAME_ALLOC 369 371 av_frame_free(&srcaudio); 370 372 #else ··· 441 443 m_avpktOut.size = 0; 442 444 m_avpktOutUsed = 0; 443 445 444 - LOG << "Got " << avail << " samples\n"; 446 + // LOG << "Got " << avail << " samples\n"; 445 447 err = avcodec_fill_audio_frame(m_audioFrame, m_encoder->channels, 446 448 m_encoder->sample_fmt, output, avail * m_destinationFormat.mChannelsPerFrame * (m_destinationFormat.mBitsPerChannel / 8), 447 449 m_destinationFormat.mChannelsPerFrame * (m_destinationFormat.mBitsPerChannel / 8));
+1 -1
src/CoreAudio/AudioToolbox/AudioQueueBase.cpp
··· 1 1 #include "AudioQueueBase.h" 2 - #include <util/debug.h> 2 + #include "stub.h" 3 3 #include <CoreServices/MacErrors.h> 4 4 5 5 AudioQueue::AudioQueue(const AudioStreamBasicDescription* format, void* userData,
+1 -1
src/CoreAudio/AudioToolbox/AudioQueueOutput.cpp
··· 1 1 #include "AudioQueueOutput.h" 2 - #include <util/debug.h> 2 + #include "stub.h" 3 3 #include <CoreServices/MacErrors.h> 4 4 5 5 AudioQueueOutput::AudioQueueOutput(const AudioStreamBasicDescription *inFormat,
+12 -14
src/CoreAudio/AudioToolbox/AudioUnit.cpp
··· 2 2 #include "AudioUnit.h" 3 3 #include "AudioOutputUnitComponent.h" 4 4 #include "AudioUnitALSA.h" 5 - #include <log.h> 6 - #include <trace.h> 7 - #include <alsa/asoundlib.h> 5 + #include "stub.h" 8 6 #include <CoreServices/MacErrors.h> 9 7 10 8 OSStatus AudioUnitInitialize(AudioUnit inUnit) 11 9 { 12 - return inUnit->init(); 10 + return ((AudioUnitComponent*)inUnit)->init(); 13 11 } 14 12 15 13 OSStatus AudioUnitUninitialize(AudioUnit inUnit) 16 14 { 17 - return inUnit->deinit(); 15 + return ((AudioUnitComponent*)inUnit)->deinit(); 18 16 } 19 17 20 18 OSStatus AudioUnitAddRenderNotify(AudioUnit inUnit, AURenderCallback inProc, void* opaque) 21 19 { 22 - return inUnit->addRenderNotify(inProc, opaque); 20 + return ((AudioUnitComponent*)inUnit)->addRenderNotify(inProc, opaque); 23 21 } 24 22 25 23 OSStatus AudioUnitRemoveRenderNotify(AudioUnit inUnit, AURenderCallback inProc, void* opaque) 26 24 { 27 - return inUnit->removeRenderNotify(inProc, opaque); 25 + return ((AudioUnitComponent*)inUnit)->removeRenderNotify(inProc, opaque); 28 26 } 29 27 30 28 OSStatus AudioUnitRender(AudioUnit inUnit, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) ··· 35 33 return paramErr; 36 34 37 35 *ioActionFlags |= kAudioUnitRenderAction_PreRender; 38 - status = inUnit->notifyListeners(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData); 36 + status = ((AudioUnitComponent*)inUnit)->notifyListeners(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData); 39 37 40 38 if (status != noErr) 41 39 return status; 42 40 43 41 *ioActionFlags &= ~kAudioUnitRenderAction_PreRender; 44 - status = inUnit->render(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData); 42 + status = ((AudioUnitComponent*)inUnit)->render(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData); 45 43 46 44 if (status != noErr) 47 45 *ioActionFlags |= kAudioUnitRenderAction_PostRenderError; 48 46 49 47 *ioActionFlags |= kAudioUnitRenderAction_PostRender; 50 - return inUnit->notifyListeners(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData); 48 + return ((AudioUnitComponent*)inUnit)->notifyListeners(ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData); 51 49 } 52 50 53 51 OSStatus AudioUnitReset(AudioUnit inUnit, AudioUnitScope inScope, AudioUnitElement inElement) 54 52 { 55 - return inUnit->reset(inScope, inElement); 53 + return ((AudioUnitComponent*)inUnit)->reset(inScope, inElement); 56 54 } 57 55 58 56 OSStatus AudioUnitGetProperty(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData, UInt32 *ioDataSize) 59 57 { 60 - return inUnit->getProperty(inID, inScope, inElement, outData, ioDataSize); 58 + return ((AudioUnitComponent*)inUnit)->getProperty(inID, inScope, inElement, outData, ioDataSize); 61 59 } 62 60 63 61 OSStatus AudioUnitGetPropertyInfo(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32 *outDataSize, Boolean *outWritable) 64 62 { 65 - return inUnit->getPropertyInfo(inID, inScope, inElement, outDataSize, outWritable); 63 + return ((AudioUnitComponent*)inUnit)->getPropertyInfo(inID, inScope, inElement, outDataSize, outWritable); 66 64 } 67 65 68 66 OSStatus AudioUnitSetProperty(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void *inData, UInt32 inDataSize) 69 67 { 70 - return inUnit->setProperty(inID, inScope, inElement, inData, inDataSize); 68 + return ((AudioUnitComponent*)inUnit)->setProperty(inID, inScope, inElement, inData, inDataSize); 71 69 } 72 70 73 71 OSStatus AudioOutputUnitStart(AudioUnit inUnit)
+26 -26
src/CoreAudio/AudioToolbox/AudioUnitALSA.cpp
··· 1 - #include "darling-config.h" 1 + #include <iostream> 2 2 #include "AudioUnitALSA.h" 3 3 #include "AudioUnitProperties.h" 4 4 #include <CoreServices/MacErrors.h> 5 - #include <util/debug.h> 5 + #include "stub.h" 6 6 #include <sstream> 7 7 #include <stdexcept> 8 8 #include <memory> ··· 18 18 { 19 19 static dispatch_once_t pred; 20 20 dispatch_once(&pred, ^{ 21 - g_audioQueue = dispatch_queue_create("org.darlinghw.audiounit", nullptr); 21 + g_audioQueue = dispatch_queue_create("org.darlinghq.audiounit", nullptr); 22 22 }); 23 23 } 24 24 ··· 145 145 if (err < 0) 146 146 throwAlsaError("Failed to set sample rate", err); 147 147 148 - LOG << "Channel count: " << int(alsaConfig.mChannelsPerFrame) << std::endl; 148 + // LOG << "Channel count: " << int(alsaConfig.mChannelsPerFrame) << std::endl; 149 149 err = snd_pcm_hw_params_set_channels(m_pcmOutput, hw_params, alsaConfig.mChannelsPerFrame); 150 150 if (err < 0) 151 151 throwAlsaError("Failed to set channel count", err); ··· 237 237 } 238 238 catch (const std::exception& e) 239 239 { 240 - ERROR() << e.what(); 240 + // ERROR() << e.what(); 241 241 242 242 deinit(); 243 243 return kAudioUnitErr_FailedInitialization; ··· 272 272 pfd.revents = event; 273 273 274 274 err = snd_pcm_poll_descriptors_revents(m_pcmOutput, &pfd, 1, &revents); 275 - if (err < 0) 276 - ERROR() << "snd_pcm_poll_descriptors_revents() failed: " << snd_strerror(err); 275 + // if (err < 0) 276 + // ERROR() << "snd_pcm_poll_descriptors_revents() failed: " << snd_strerror(err); 277 277 278 278 if (revents & POLLIN) 279 279 pushDataFromInput(); ··· 294 294 const AudioStreamBasicDescription& config = m_config[kOutputBus].first; 295 295 UInt32 cc = config.mChannelsPerFrame; 296 296 297 - TRACE(); 297 + // TRACE(); 298 298 299 299 memset(&ts, 0, sizeof(ts)); 300 300 ··· 358 358 359 359 if (err != noErr) 360 360 { 361 - ERROR() << "Render callback failed with error " << err; 361 + // ERROR() << "Render callback failed with error " << err; 362 362 363 363 // Fill with silence, the error may be temporary 364 364 UInt32 bytes = config.mBytesPerFrame * SAMPLE_PERIOD; ··· 488 488 489 489 for (UInt32 i = 0; i < ioData->mNumberBuffers; i++) 490 490 { 491 - LOG << "Writing " << ioData->mBuffers[i].mDataByteSize << " bytes into sound card\n"; 491 + // LOG << "Writing " << ioData->mBuffers[i].mDataByteSize << " bytes into sound card\n"; 492 492 493 493 sampleCount = std::min<UInt32>(ioData->mBuffers[i].mDataByteSize / config.mBytesPerFrame, inNumberFrames - framesSoFar); 494 494 framesSoFar += sampleCount; ··· 502 502 { 503 503 if (wr == -EINTR || wr == -EPIPE) 504 504 { 505 - LOG << "Recovering PCM\n"; 505 + // LOG << "Recovering PCM\n"; 506 506 snd_pcm_recover(m_pcmOutput, wr, false); 507 507 goto do_write; 508 508 } 509 509 else 510 510 { 511 - ERROR() << "snd_pcm_writei() failed: " << snd_strerror(wr); 511 + // ERROR() << "snd_pcm_writei() failed: " << snd_strerror(wr); 512 512 return kAudioUnitErr_NoConnection; 513 513 } 514 514 } 515 515 else if (wr < sampleCount) 516 - ERROR() << "snd_pcm_writei(): not all data written?"; 516 + ;// ERROR() << "snd_pcm_writei(): not all data written?"; 517 517 } 518 518 519 519 return noErr; ··· 527 527 528 528 if (ioData->mNumberBuffers != config.mChannelsPerFrame) 529 529 { 530 - ERROR() << "Incorrect buffer count for planar audio, only " << ioData->mNumberBuffers; 530 + // ERROR() << "Incorrect buffer count for planar audio, only " << ioData->mNumberBuffers; 531 531 return paramErr; 532 532 } 533 533 ··· 536 536 { 537 537 if (size != ioData->mBuffers[i].mDataByteSize) 538 538 { 539 - ERROR() << "Bad buffer size in buffer " << i; 539 + // ERROR() << "Bad buffer size in buffer " << i; 540 540 return paramErr; 541 541 } 542 542 } ··· 552 552 { 553 553 if (wr == -EINTR || wr == -EPIPE) 554 554 { 555 - LOG << "Recovering PCM\n"; 555 + // LOG << "Recovering PCM\n"; 556 556 snd_pcm_recover(m_pcmOutput, wr, false); 557 557 goto do_write; 558 558 } 559 559 else 560 560 { 561 - ERROR() << "snd_pcm_writen() failed: " << snd_strerror(wr); 561 + // ERROR() << "snd_pcm_writen() failed: " << snd_strerror(wr); 562 562 return kAudioUnitErr_NoConnection; 563 563 } 564 564 } 565 565 else if (wr < sampleCount) 566 - ERROR() << "snd_pcm_writen(): not all data written?"; 566 + ;// ERROR() << "snd_pcm_writen(): not all data written?"; 567 567 568 568 return noErr; 569 569 } ··· 586 586 587 587 for (UInt32 i = 0; i < ioData->mNumberBuffers; i++) 588 588 { 589 - LOG << "Reading up to " << ioData->mBuffers[i].mDataByteSize << " bytes from sound card\n"; 589 + // LOG << "Reading up to " << ioData->mBuffers[i].mDataByteSize << " bytes from sound card\n"; 590 590 591 591 sampleCount = ioData->mBuffers[i].mDataByteSize / config.mBytesPerFrame; 592 592 ··· 601 601 } 602 602 else 603 603 { 604 - ERROR() << "snd_pcm_writei() failed: " << snd_strerror(wr); 604 + // ERROR() << "snd_pcm_writei() failed: " << snd_strerror(wr); 605 605 return kAudioUnitErr_NoConnection; 606 606 } 607 607 } ··· 620 620 621 621 if (ioData->mNumberBuffers != config.mChannelsPerFrame) 622 622 { 623 - ERROR() << "Incorrect buffer count for planar audio, only " << ioData->mNumberBuffers; 623 + // ERROR() << "Incorrect buffer count for planar audio, only " << ioData->mNumberBuffers; 624 624 return paramErr; 625 625 } 626 626 ··· 629 629 { 630 630 if (size != ioData->mBuffers[i].mDataByteSize) 631 631 { 632 - ERROR() << "Bad buffer size in buffer " << i; 632 + // ERROR() << "Bad buffer size in buffer " << i; 633 633 return paramErr; 634 634 } 635 635 } ··· 650 650 } 651 651 else 652 652 { 653 - ERROR() << "snd_pcm_writen() failed: " << snd_strerror(wr); 653 + // ERROR() << "snd_pcm_writen() failed: " << snd_strerror(wr); 654 654 return kAudioUnitErr_NoConnection; 655 655 } 656 656 } ··· 679 679 if (snd_pcm_poll_descriptors(m_pcmOutput, pollfds.get(), count) != count) 680 680 throw std::runtime_error("snd_pcm_poll_descriptors() failed"); 681 681 682 - LOG << "ALSA descriptor count: " << count << std::endl; 682 + // LOG << "ALSA descriptor count: " << count << std::endl; 683 683 startDescriptors(pollfds.get(), count); 684 684 } 685 685 ··· 728 728 { 729 729 int err; 730 730 731 - TRACE(); 731 + // TRACE(); 732 732 733 733 try 734 734 { ··· 746 746 if (m_pcmOutput) 747 747 snd_pcm_drop(m_pcmOutput); 748 748 749 - ERROR() << e.what(); 749 + // ERROR() << e.what(); 750 750 return kAudioUnitErr_FailedInitialization; 751 751 } 752 752
+3 -3
src/CoreAudio/AudioToolbox/AudioUnitBase.cpp
··· 2 2 #include "AudioUnitProperties.h" 3 3 #include "AudioUnitRenderer.h" 4 4 #include <CoreServices/MacErrors.h> 5 - #include <util/debug.h> 5 + #include "stub.h" 6 6 #include <cstring> 7 7 8 8 AudioUnitComponent::AudioUnitComponent(std::initializer_list<CFStringRef> elements) ··· 80 80 81 81 OSStatus AudioUnitComponent::setProperty(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, const void* data, UInt32 dataSize) 82 82 { 83 - TRACE5(prop, scope, elem, data, dataSize); 83 + // TRACE5(prop, scope, elem, data, dataSize); 84 84 85 85 switch (prop) 86 86 { ··· 177 177 178 178 OSStatus AudioUnitComponent::getProperty(AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, void* data, UInt32* dataSize) 179 179 { 180 - TRACE5(prop, scope, elem, data, dataSize); 180 + // TRACE5(prop, scope, elem, data, dataSize); 181 181 182 182 switch (prop) 183 183 {
+12 -12
src/CoreAudio/AudioToolbox/AudioUnitPA.cpp
··· 7 7 #include <sstream> 8 8 #include <memory> 9 9 #include <cstring> 10 - #include <util/debug.h> 10 + #include "stub.h" 11 11 #include <objc/runtime.h> 12 12 13 13 extern "C" char*** _NSGetArgv(void); ··· 71 71 72 72 if (m_stream == nullptr) 73 73 { 74 - ERROR() << "pa_stream_new() failed"; 74 + // ERROR() << "pa_stream_new() failed"; 75 75 return kAudioUnitErr_FailedInitialization; 76 76 } 77 77 ··· 93 93 void AudioUnitPA::paStreamStateCB(pa_stream* s, void*) 94 94 { 95 95 int state = pa_stream_get_state(s); 96 - TRACE() << "state=" << state; 96 + //TRACE() << "state=" << state; 97 97 98 98 switch (state) 99 99 { 100 100 case PA_STREAM_FAILED: 101 - ERROR() << "PA stream error: " << pa_strerror(pa_context_errno(pa_stream_get_context(s))); 101 + //ERROR() << "PA stream error: " << pa_strerror(pa_context_errno(pa_stream_get_context(s))); 102 102 break; 103 103 case PA_STREAM_READY: 104 - LOG << "PA stream is ready\n"; 104 + //LOG << "PA stream is ready\n"; 105 105 break; 106 106 } 107 107 } ··· 124 124 125 125 if (!m_stream) 126 126 { 127 - std::cerr << "No stream?!\n"; 127 + // std::cerr << "No stream?!\n"; 128 128 return; 129 129 } 130 130 131 - TRACE() << "m_started=" << m_started; 131 + //TRACE() << "m_started=" << m_started; 132 132 133 133 if (!m_started) 134 134 { ··· 210 210 211 211 if (err != noErr || bufs->mBuffers[0].mDataByteSize == 0) 212 212 { 213 - ERROR() << "Render callback failed with error " << err; 213 + // ERROR() << "Render callback failed with error " << err; 214 214 215 215 // Fill with silence, the error may be temporary 216 216 UInt32 bytes = length; ··· 244 244 } 245 245 } 246 246 247 - LOG << "Rendering...\n"; 247 + //LOG << "Rendering...\n"; 248 248 m_lastRenderError = AudioUnitRender(this, &flags, &ts, kOutputBus, length / config.mBytesPerFrame, bufs); 249 249 250 250 operator delete(bufs); ··· 280 280 if (!bytes) 281 281 break; 282 282 283 - LOG << "AudioUnitPA::renderInterleavedOutput(): data=" << ioData->mBuffers[i].mData << ", bytes=" << bytes << std::endl; 283 + //LOG << "AudioUnitPA::renderInterleavedOutput(): data=" << ioData->mBuffers[i].mData << ", bytes=" << bytes << std::endl; 284 284 pa_stream_write(m_stream, ((char*) ioData->mBuffers[i].mData) + framesSoFar * config.mBytesPerFrame, bytes, 285 285 nullptr, 0, PA_SEEK_RELATIVE); 286 286 ··· 468 468 pa_mainloop_free(m_mainloop); 469 469 m_mainloop = nullptr; 470 470 471 - ERROR() << e.what(); 471 + // ERROR() << e.what(); 472 472 } 473 473 } 474 474 ··· 519 519 { 520 520 Completion* comp = static_cast<Completion*>(priv); 521 521 522 - TRACE() << pa_context_get_state(c); 522 + // TRACE() << pa_context_get_state(c); 523 523 switch (pa_context_get_state(c)) 524 524 { 525 525 case PA_CONTEXT_READY:
+50
src/CoreAudio/AudioToolbox/CMakeLists.txt
··· 1 + project(AudioToolbox) 2 + 3 + include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/libcxx/include ${CMAKE_CURRENT_BINARY_DIR}) 4 + include_directories( 5 + ${CMAKE_CURRENT_SOURCE_DIR}/../include 6 + ${CMAKE_CURRENT_SOURCE_DIR}/../include/AudioToolbox 7 + ) 8 + 9 + add_definitions(-DENABLE_PULSEAUDIO=1) 10 + 11 + set(audiotoolbox_sources 12 + AUComponent.cpp 13 + AudioConverter.cpp 14 + AudioConverterImpl.cpp 15 + AudioFile.cpp 16 + AudioOutputUnitComponent.cpp 17 + AudioQueueBase.cpp 18 + AudioQueue.cpp 19 + AudioQueueOutput.cpp 20 + # AudioUnitALSA.cpp 21 + AudioUnitBase.cpp 22 + AudioUnit.cpp 23 + AudioUnitPA.cpp 24 + AudioUnitRenderer.cpp 25 + AUGraph.cpp 26 + ) 27 + 28 + add_framework(AudioToolbox 29 + FAT 30 + CURRENT_VERSION 31 + VERSION "A" 32 + 33 + SOURCES 34 + ${audiotoolbox_sources} 35 + 36 + DEPENDENCIES 37 + system 38 + cxx 39 + CoreFoundation 40 + CoreAudio 41 + CoreServices 42 + objc 43 + avformat 44 + avresample 45 + avcodec 46 + avutil 47 + pulse # This should go away in favor of abstraction inside CoreAudio 48 + ) 49 + 50 + # TODO: Add AudioUnit.framework
+14
src/CoreAudio/AudioToolbox/stub.h
··· 1 + #ifndef AT_STUB_H 2 + #define AT_STUB_H 3 + #include <stdio.h> 4 + 5 + #ifndef STUB 6 + # define STUB() fprintf(stderr, "AudioToolbox STUB: %s called\n", __FUNCTION__) 7 + #endif 8 + 9 + #define TRACE() 10 + #define TRACE1(...) 11 + #define TRACE2(...) 12 + 13 + #endif 14 +
+20 -1
src/CoreAudio/CMakeLists.txt
··· 1 1 project(CoreAudio_root) 2 + include(wrap_elf) 3 + 4 + add_definitions(-DENABLE_PULSEAUDIO) 5 + 6 + find_package(FFmpeg REQUIRED) 7 + find_package(PulseAudio REQUIRED) 8 + 9 + include_directories( 10 + ${FFMPEG_INCLUDE_DIR} 11 + ${PULSEAUDIO_INCLUDE_DIRS} 12 + ) 13 + add_definitions(-DHAVE_AV_FRAME_ALLOC=1) 14 + 15 + wrap_elf(avresample libavresample.so) 16 + wrap_elf(avcodec libavcodec.so) 17 + wrap_elf(avformat libavformat.so) 18 + wrap_elf(avutil libavutil.so) 19 + #wrap_elf(asound libasound.so) 20 + wrap_elf(pulse libpulse.so) 2 21 3 22 add_subdirectory(CoreAudio) 4 - #add_subdirectory(AudioToolbox) 23 + add_subdirectory(AudioToolbox)
+11 -1
src/CoreAudio/CoreAudio/AudioHardware.cpp
··· 21 21 #include "AudioHardwareImpl.h" 22 22 #include <CoreServices/MacErrors.h> 23 23 #include <memory> 24 + #include "stub.h" 24 25 25 26 static std::unique_ptr<AudioHardwareImpl> g_systemObject; 26 27 ··· 60 61 { 61 62 AudioHardwareImpl* obj = GetObject(inObjectID); 62 63 if (!obj) 63 - return kAudioHardwareBadObjectError; 64 + return 0; 64 65 65 66 return obj->hasProperty(inAddress); 66 67 } ··· 141 142 142 143 OSStatus AudioHardwareCreateAggregateDevice(CFDictionaryRef, AudioObjectID* outDeviceID) 143 144 { 145 + STUB(); 144 146 if (outDeviceID) 145 147 *outDeviceID = 0; 146 148 ··· 149 151 150 152 OSStatus AudioHardwareDestroyAggregateDevice(AudioObjectID inDeviceID) 151 153 { 154 + STUB(); 152 155 return unimpErr; 153 156 } 154 157 155 158 OSStatus AudioHardwareGetProperty(AudioHardwarePropertyID inPropId, UInt32* ioPropertyDataSize, void* outPropertyData) 156 159 { 160 + STUB(); 161 + return unimpErr; 162 + } 163 + 164 + OSStatus AudioHardwareGetPropertyInfo(AudioHardwarePropertyID inPropertyID, UInt32 *outSize, Boolean *outWritable) 165 + { 166 + STUB(); 157 167 return unimpErr; 158 168 } 159 169
+1 -1
src/CoreAudio/CoreAudio/CMakeLists.txt
··· 8 8 AudioHardwareStream.cpp 9 9 ) 10 10 11 - add_framework( 11 + add_framework(CoreAudio 12 12 FAT 13 13 CURRENT_VERSION 14 14 VERSION "A"
+10
src/CoreAudio/CoreAudio/stub.h
··· 1 + #ifndef CA_STUB_H 2 + #define CA_STUB_H 3 + #include <stdio.h> 4 + 5 + #ifndef STUB 6 + # define STUB() fprintf(stderr, "CoreAudio STUB: %s called\n", __FUNCTION__) 7 + #endif 8 + 9 + #endif 10 +
+11 -3
src/CoreAudio/include/AudioToolbox/AUComponent.h
··· 3 3 #include <MacTypes.h> 4 4 #include <CoreServices/Components.h> 5 5 #include <CoreFoundation/CFString.h> 6 - #include <AudioToolbox/AUGraph.h> 6 + //#include <AudioToolbox/AUGraph.h> 7 7 8 - class AudioUnitComponent; 8 + // class AudioUnitComponent; 9 9 10 10 typedef Component AudioComponent; 11 11 typedef ComponentInstance AudioComponentInstance; 12 - typedef ComponentDescription AudioComponentDescription; 12 + // typedef ComponentDescription AudioComponentDescription; 13 + 14 + typedef struct AudioComponentDescription { 15 + OSType componentType; 16 + OSType componentSubType; 17 + OSType componentManufacturer; 18 + UInt32 componentFlags; 19 + UInt32 componentFlagsMask; 20 + } AudioComponentDescription; 13 21 14 22 enum 15 23 {
+1
src/CoreAudio/include/AudioToolbox/AUGraph.h
··· 2 2 #define AUGRAPH_H 3 3 #include <AudioToolbox/AudioUnit.h> 4 4 #include <AudioToolbox/AudioUnitProperties.h> 5 + #include <AudioToolbox/AUComponent.h> 5 6 6 7 #ifdef __cplusplus 7 8 extern "C" {
src/CoreAudio/include/AudioToolbox/AudioConverterImpl.h src/CoreAudio/AudioToolbox/AudioConverterImpl.h
src/CoreAudio/include/AudioToolbox/AudioOutputUnitComponent.h src/CoreAudio/AudioToolbox/AudioOutputUnitComponent.h
src/CoreAudio/include/AudioToolbox/AudioQueueBase.h src/CoreAudio/AudioToolbox/AudioQueueBase.h
src/CoreAudio/include/AudioToolbox/AudioQueueOutput.h src/CoreAudio/AudioToolbox/AudioQueueOutput.h
+1 -1
src/CoreAudio/include/AudioToolbox/AudioUnitALSA.h src/CoreAudio/AudioToolbox/AudioUnitALSA.h
··· 2 2 #define AUCOMPONENTINTERNAL_H 3 3 #include "AudioUnit.h" 4 4 #include <CoreServices/ComponentsInternal.h> 5 - #include <asoundlib.h> 5 + #include <alsa/asoundlib.h> 6 6 #include <dispatch/dispatch.h> 7 7 #include <vector> 8 8 #include "AudioOutputUnitComponent.h"
src/CoreAudio/include/AudioToolbox/AudioUnitBase.h src/CoreAudio/AudioToolbox/AudioUnitBase.h
src/CoreAudio/include/AudioToolbox/AudioUnitPA.h src/CoreAudio/AudioToolbox/AudioUnitPA.h
src/CoreAudio/include/AudioToolbox/AudioUnitRenderer.h src/CoreAudio/AudioToolbox/AudioUnitRenderer.h