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