Re: Changing Default Device and Sample Rate via Objective C
Re: Changing Default Device and Sample Rate via Objective C
- Subject: Re: Changing Default Device and Sample Rate via Objective C
- From: "René J.V. Bertin" <email@hidden>
- Date: Tue, 02 Oct 2012 15:21:38 +0200
You're welcome.
The crashing call is supposed to return the number of supported sample rates, so that in a subsequent call with kAudioDevicePropertyAvailableNominalSampleRates you can provide a buffer of the appropriate size instead of the NULL pointer. This is how all examples I've seen do it, but even on 10.6.8 I've always gotten size==0 as a result (without error).
So it's possible/likely that this aspect has changed, and now gives a crash. I'm not sure if I included it in AudioDevice.cpp, but the way I obtain the supported sample rates now is by passing in a reasonably large value for size (100) with of course a buffer of that many AudioValueRanges. Upon return, sizes will have been changed to the actual number of ranges returned.
Note that you can encounter basically 2 cases. Either you'll get a >1 number of ranges, where each 'range' is in fact a single, discrete rate. The other case I've encountered is a single range, where the 2 values in the AudioValueRange correspond to the minimum and maximum rates supported. In that case the device will accept any rate between those extremes (and the corresponding numerical field in Audio Midi Setup will be editable).
R.
On Oct 02, 2012, at 15:11, email@hidden wrote:
> Thanks! Very nice of you to share this sample with me. As you know, samples on this stuff are very hard to come by.
>
> After changing some small type conversion warnings, it does build for me. However, I get a runtime exception in CreateDefaultAU() on line 99: err = AudioDeviceGetProperty( defaultADeviceID, 0, false, kAudioDevicePropertyAvailableNominalSampleRates, &size, NULL );
>
> The exception is "Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)"
>
> Not sure what is going on yet but I think I'll spend some time debugging the problem as this is the best example I have seen yet.
>
> Mike
>
> On Oct 2, 2012, at 5:53 AM, René J.V. Bertin wrote:
>
>> Hi Mike,
>>
>> Here's my twiddled version of the DefaultOutputUnit example, containing a simple C++ API to meddle with the hardware audio device. Hope it compiles for you, I'm on 10.6.8 ...
>>
>> René
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden