| @@ -427,7 +427,6 @@ opensoundsys_close (AUDIO_OUT *audio_out) · 426 unmodified lines |
| 427 | 427 | |
| 428 | 428 | #if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */ |
| 429 | 429 | |
| 430 | | −#include <Carbon.h> |
| 431 | 430 | #include <CoreAudio/AudioHardware.h> |
| 432 | 431 | |
| 433 | 432 | #define MACOSX_MAGIC MAKE_MAGIC ('M', 'a', 'c', ' ', 'O', 'S', ' ', 'X') |
| @@ -447,6 +446,9 @@ typedef struct · 13 unmodified lines |
| 447 | 446 | get_audio_callback_t callback ; |
| 448 | 447 | |
| 449 | 448 | void *callback_data ; |
| 449 | + |
| 450 | + AudioDeviceIOProcID ioprocid; |
| 451 | + |
| 450 | 452 | } MACOSX_AUDIO_OUT ; |
| 451 | 453 | |
| 452 | 454 | static AUDIO_OUT *macosx_open (int channels, int samplerate) ; |
| @@ -463,7 +465,8 @@ static AUDIO_OUT * · 10 unmodified lines |
| 463 | 465 | macosx_open (int channels, int samplerate) |
| 464 | 466 | { MACOSX_AUDIO_OUT *macosx_out ; |
| 465 | 467 | OSStatus err ; |
| 466 | | − size_t count ; |
| 468 | + UInt32 count ; |
| 469 | + AudioObjectPropertyAddress propertyAddress ; |
| 467 | 470 | |
| 468 | 471 | if ((macosx_out = calloc (1, sizeof (MACOSX_AUDIO_OUT))) == NULL) |
| 469 | 472 | { perror ("macosx_open : malloc ") ; |
| @@ -477,38 +480,45 @@ macosx_open (int channels, int samplerate) · 7 unmodified lines |
| 477 | 480 | macosx_out->device = kAudioDeviceUnknown ; |
| 478 | 481 | |
| 479 | 482 | /* get the default output device for the HAL */ |
| 483 | + propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice; |
| 484 | + propertyAddress.mScope = kAudioDevicePropertyScopeOutput; |
| 485 | + propertyAddress.mElement = kAudioObjectPropertyElementMaster; |
| 486 | + |
| 480 | 487 | count = sizeof (AudioDeviceID) ; |
| 481 | | − if ((err = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice, |
| 482 | | − &count, (void *) &(macosx_out->device))) != noErr) |
| 483 | | − { printf ("AudioHardwareGetProperty failed.\n") ; |
| 488 | + if ((err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, |
| 489 | + &count, &(macosx_out->device))) != noErr) |
| 490 | + { printf ("AudioObjectGetPropertyData (kAudioHardwarePropertyDefaultOutputDevice) failed.\n") ; |
| 484 | 491 | free (macosx_out) ; |
| 485 | 492 | return NULL ; |
| 486 | 493 | } ; |
| 487 | 494 | |
| 488 | 495 | /* get the buffersize that the default device uses for IO */ |
| 489 | 496 | count = sizeof (UInt32) ; |
| 490 | | − if ((err = AudioDeviceGetProperty (macosx_out->device, 0, false, kAudioDevicePropertyBufferSize, |
| 497 | + propertyAddress.mSelector = kAudioDevicePropertyBufferSize ; |
| 498 | + if ((err = AudioObjectGetPropertyData (macosx_out->device, &propertyAddress, 0, NULL, |
| 491 | 499 | &count, &(macosx_out->buffer_size))) != noErr) |
| 492 | | − { printf ("AudioDeviceGetProperty (AudioDeviceGetProperty) failed.\n") ; |
| 500 | + { printf ("AudioObjectGetPropertyData (kAudioDevicePropertyBufferSize) (AudioDeviceGetProperty) failed.\n") ; |
| 493 | 501 | free (macosx_out) ; |
| 494 | 502 | return NULL ; |
| 495 | 503 | } ; |
| 496 | 504 | |
| 497 | 505 | /* get a description of the data format used by the default device */ |
| 498 | 506 | count = sizeof (AudioStreamBasicDescription) ; |
| 499 | | − if ((err = AudioDeviceGetProperty (macosx_out->device, 0, false, kAudioDevicePropertyStreamFormat, |
| 507 | + propertyAddress.mSelector = kAudioDevicePropertyStreamFormat ; |
| 508 | + if ((err = AudioObjectGetPropertyData (macosx_out->device, &propertyAddress, 0, NULL, |
| 500 | 509 | &count, &(macosx_out->format))) != noErr) |
| 501 | | − { printf ("AudioDeviceGetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ; |
| 510 | + { printf ("AudioObjectGetPropertyData (kAudioDevicePropertyStreamFormat) failed.\n") ; |
| 502 | 511 | free (macosx_out) ; |
| 503 | 512 | return NULL ; |
| 504 | 513 | } ; |
| 505 | 514 | |
| 506 | 515 | macosx_out->format.mSampleRate = samplerate ; |
| 507 | 516 | macosx_out->format.mChannelsPerFrame = channels ; |
| 508 | | − |
| 509 | | − if ((err = AudioDeviceSetProperty (macosx_out->device, NULL, 0, false, kAudioDevicePropertyStreamFormat, |
| 510 | | − sizeof (AudioStreamBasicDescription), &(macosx_out->format))) != noErr) |
| 511 | | − { printf ("AudioDeviceSetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ; |
| 517 | + propertyAddress.mSelector = kAudioDevicePropertyStreamFormat ; |
| 518 | + count = sizeof (AudioStreamBasicDescription) ; |
| 519 | + if ((err = AudioObjectGetPropertyData (macosx_out->device, &propertyAddress, 0, NULL, |
| 520 | + &count, &(macosx_out->format))) != noErr) |
| 521 | + { printf ("AudioObjectGetPropertyData (kAudioDevicePropertyStreamFormat) failed.\n") ; |
| 512 | 522 | free (macosx_out) ; |
| 513 | 523 | return NULL ; |
| 514 | 524 | } ; |
| @@ -522,8 +532,8 @@ macosx_open (int channels, int samplerate) · 7 unmodified lines |
| 522 | 532 | macosx_out->done_playing = 0 ; |
| 523 | 533 | |
| 524 | 534 | /* Fire off the device. */ |
| 525 | | − if ((err = AudioDeviceAddIOProc (macosx_out->device, macosx_audio_out_callback, |
| 526 | | − (void *) macosx_out)) != noErr) |
| 535 | + if ((err = AudioDeviceCreateIOProcID (macosx_out->device, macosx_audio_out_callback, |
| 536 | + (void *) macosx_out, &macosx_out->ioprocid)) != noErr) |
| 527 | 537 | { printf ("AudioDeviceAddIOProc failed.\n") ; |
| 528 | 538 | free (macosx_out) ; |
| 529 | 539 | return NULL ; |
| @@ -582,7 +592,8 @@ macosx_close (AUDIO_OUT *audio_out) · 52 unmodified lines |
| 582 | 592 | return ; |
| 583 | 593 | } ; |
| 584 | 594 | |
| 585 | | − err = AudioDeviceRemoveIOProc (macosx_out->device, macosx_audio_out_callback) ; |
| 595 | + err = AudioDeviceDestroyIOProcID(macosx_out->device, |
| 596 | + macosx_out->ioprocid); |
| 586 | 597 | if (err != noErr) |
| 587 | 598 | { printf ("AudioDeviceRemoveIOProc failed.\n") ; |
| 588 | 599 | return ; |