Lines Matching refs:core

245 static int coreaudio_buf_lock (coreaudioVoiceOut *core, const char *fn_name)
249 err = pthread_mutex_lock (&core->buf_mutex);
258 static int coreaudio_buf_unlock (coreaudioVoiceOut *core, const char *fn_name)
262 err = pthread_mutex_unlock (&core->buf_mutex);
274 coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw; \
277 if (coreaudio_buf_lock(core, "coreaudio_" #name)) { \
283 coreaudio_buf_unlock(core, "coreaudio_" #name); \
312 coreaudioVoiceOut *core = (coreaudioVoiceOut *) hwptr;
315 if (coreaudio_buf_lock (core, "audioDeviceIOProc")) {
320 if (inDevice != core->outputDeviceID) {
321 coreaudio_buf_unlock (core, "audioDeviceIOProc(old device)");
325 frameCount = core->audioDevicePropertyBufferFrameSize;
331 coreaudio_buf_unlock (core, "audioDeviceIOProc(empty)");
351 coreaudio_buf_unlock (core, "audioDeviceIOProc");
355 static OSStatus init_out_device(coreaudioVoiceOut *core)
361 .mBitsPerChannel = core->hw.info.bits,
362 .mBytesPerFrame = core->hw.info.bytes_per_frame,
363 .mBytesPerPacket = core->hw.info.bytes_per_frame,
364 .mChannelsPerFrame = core->hw.info.nchannels,
368 .mSampleRate = core->hw.info.freq
371 status = coreaudio_get_voice(&core->outputDeviceID);
377 if (core->outputDeviceID == kAudioDeviceUnknown) {
383 status = coreaudio_get_framesizerange(core->outputDeviceID,
394 if (frameRange.mMinimum > core->frameSizeSetting) {
395 core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
397 } else if (frameRange.mMaximum < core->frameSizeSetting) {
398 core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
401 core->audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
405 status = coreaudio_set_framesize(core->outputDeviceID,
406 &core->audioDevicePropertyBufferFrameSize);
413 (uint32_t)core->audioDevicePropertyBufferFrameSize);
418 status = coreaudio_get_framesize(core->outputDeviceID,
419 &core->audioDevicePropertyBufferFrameSize);
428 core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
431 status = coreaudio_set_streamformat(core->outputDeviceID,
440 core->outputDeviceID = kAudioDeviceUnknown;
454 core->ioprocid = NULL;
455 status = AudioDeviceCreateIOProcID(core->outputDeviceID,
457 &core->hw,
458 &core->ioprocid);
462 if (status != kAudioHardwareNoError || core->ioprocid == NULL) {
464 core->outputDeviceID = kAudioDeviceUnknown;
471 static void fini_out_device(coreaudioVoiceOut *core)
477 status = coreaudio_get_isrunning(core->outputDeviceID, &isrunning);
485 status = AudioDeviceStop(core->outputDeviceID, core->ioprocid);
493 status = AudioDeviceDestroyIOProcID(core->outputDeviceID,
494 core->ioprocid);
498 core->outputDeviceID = kAudioDeviceUnknown;
501 static void update_device_playback_state(coreaudioVoiceOut *core)
506 status = coreaudio_get_isrunning(core->outputDeviceID, &isrunning);
516 if (core->enabled) {
519 status = AudioDeviceStart(core->outputDeviceID, core->ioprocid);
527 status = AudioDeviceStop(core->outputDeviceID,
528 core->ioprocid);
543 coreaudioVoiceOut *core = in_client_data;
547 if (core->outputDeviceID) {
548 fini_out_device(core);
551 if (!init_out_device(core)) {
552 update_device_playback_state(core);
563 coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
570 err = pthread_mutex_init(&core->buf_mutex, NULL);
581 core->frameSizeSetting = audio_buffer_frames(
584 core->bufferCount = cpdo->has_buffer_count ? cpdo->buffer_count : 4;
588 core);
595 if (init_out_device(core)) {
599 core);
615 coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
620 core);
625 fini_out_device(core);
628 err = pthread_mutex_destroy(&core->buf_mutex);
636 coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
638 core->enabled = enable;
639 update_device_playback_state(core);