o->hw_output_channels, o->output_frames->height);
}
if ( o->blocksize != o->output_frames->length ) {
o->hw_output_channels, o->output_frames->height);
}
if ( o->blocksize != o->output_frames->length ) {
o->blocksize, o->output_frames->length);
}
if ( o->hw_input_channels != o->input_frames->height ) {
o->blocksize, o->output_frames->length);
}
if ( o->hw_input_channels != o->input_frames->height ) {
o->hw_input_channels, o->input_frames->height);
}
if ( o->blocksize != o->input_frames->length ) {
o->hw_input_channels, o->input_frames->height);
}
if ( o->blocksize != o->input_frames->length ) {
/* setting up audio session with interruption listener */
err = AudioSessionInitialize(NULL, NULL, audio_unit_interruption_listener, o);
/* setting up audio session with interruption listener */
err = AudioSessionInitialize(NULL, NULL, audio_unit_interruption_listener, o);
audio_unit_set_audio_session_category(o->input_enabled, o->verbose);
audio_unit_check_audio_route(o);
audio_unit_set_audio_session_category(o->input_enabled, o->verbose);
audio_unit_check_audio_route(o);
/* add route change listener */
err = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange,
audio_unit_route_change_listener, o);
/* add route change listener */
err = AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange,
audio_unit_route_change_listener, o);
/* set latency */
err = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration,
sizeof(latency), &latency);
/* set latency */
err = AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration,
sizeof(latency), &latency);
#if 0 // only for iphone OS >= 3.1
UInt32 val = 1; // set to 0 (default) to use ear speaker in voice application
err = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
sizeof(UInt32), &val);
#if 0 // only for iphone OS >= 3.1
UInt32 val = 1; // set to 0 (default) to use ear speaker in voice application
err = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
sizeof(UInt32), &val);
AudioUnit *audio_unit = &(o->audio_unit);
err = AudioComponentInstanceNew(comp, &(o->audio_unit));
AudioUnit *audio_unit = &(o->audio_unit);
err = AudioComponentInstanceNew(comp, &(o->audio_unit));
/* enable IO */
UInt32 enabled = 1;
err = AudioUnitSetProperty (*audio_unit, kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input, 1, &enabled, sizeof(enabled));
if (err) {
/* enable IO */
UInt32 enabled = 1;
err = AudioUnitSetProperty (*audio_unit, kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input, 1, &enabled, sizeof(enabled));
if (err) {
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_MaximumFramesPerSlice,
kAudioUnitScope_Global, 0, &max_fps, sizeof(max_fps));
if (err) {
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_MaximumFramesPerSlice,
kAudioUnitScope_Global, 0, &max_fps, sizeof(max_fps));
if (err) {
goto fail;
}
AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &(o->au_ios_cb_struct), sizeof(o->au_ios_cb_struct));
goto fail;
}
AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &(o->au_ios_cb_struct), sizeof(o->au_ios_cb_struct));
#if 0
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SampleRate,
kAudioUnitScope_Input, 0, &samplerate, sizeof(Float64));
#if 0
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SampleRate,
kAudioUnitScope_Input, 0, &samplerate, sizeof(Float64));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SampleRate,
kAudioUnitScope_Output, 1, &samplerate, sizeof(Float64));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_SampleRate,
kAudioUnitScope_Output, 1, &samplerate, sizeof(Float64));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &audioFormat, sizeof(audioFormat));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &audioFormat, sizeof(audioFormat));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &audioFormat, sizeof(audioFormat));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &audioFormat, sizeof(audioFormat));
#if 0
AudioStreamBasicDescription thruFormat;
thissize = sizeof(thruFormat);
err = AudioUnitGetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &thruFormat, &thissize);
#if 0
AudioStreamBasicDescription thruFormat;
thissize = sizeof(thruFormat);
err = AudioUnitGetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &thruFormat, &thissize);
- if (err) { AUBIO_ERR("audio_unit: could not get speaker output format, err: %d", (int)err); goto fail; }
+ if (err) { AUBIO_ERR("audio_unit: could not get speaker output format, err: %d\n", (int)err); goto fail; }
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &thruFormat, sizeof(thruFormat));
err = AudioUnitSetProperty (*audio_unit, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output, 1, &thruFormat, sizeof(thruFormat));
- if (err) { AUBIO_ERR("audio_unit: could not set input audio format, err: %d", (int)err); goto fail; }
+ if (err) { AUBIO_ERR("audio_unit: could not set input audio format, err: %d\n", (int)err); goto fail; }
err = AudioUnitRender(thisUnit, action_flags, time_stamp, 1,
inNumber_frames, input_output);
if (err) {
err = AudioUnitRender(thisUnit, action_flags, time_stamp, 1,
inNumber_frames, input_output);
if (err) {
thissize = sizeof(samplerate);
err = AudioUnitGetProperty (o->audio_unit, kAudioUnitProperty_SampleRate,
kAudioUnitScope_Output, 1, &samplerate, &thissize);
thissize = sizeof(samplerate);
err = AudioUnitGetProperty (o->audio_unit, kAudioUnitProperty_SampleRate,
kAudioUnitScope_Output, 1, &samplerate, &thissize);
/* get hardware input channels */
thissize = sizeof(input_hw_channels);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels,
&thissize, &input_hw_channels);
/* get hardware input channels */
thissize = sizeof(input_hw_channels);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels,
&thissize, &input_hw_channels);
/* get hardware output channels */
thissize = sizeof(output_hw_channels);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputNumberChannels,
&thissize, &output_hw_channels);
/* get hardware output channels */
thissize = sizeof(output_hw_channels);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputNumberChannels,
&thissize, &output_hw_channels);
/* get hardware input volume */
thissize = sizeof(input_hw_volume);
err = AudioSessionGetProperty(kAudioSessionProperty_InputGainScalar,
&thissize, &input_hw_volume);
/* get hardware input volume */
thissize = sizeof(input_hw_volume);
err = AudioSessionGetProperty(kAudioSessionProperty_InputGainScalar,
&thissize, &input_hw_volume);
/* get hardware output volume */
thissize = sizeof(output_hw_volume);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume,
&thissize, &output_hw_volume);
/* get hardware output volume */
thissize = sizeof(output_hw_volume);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputVolume,
&thissize, &output_hw_volume);
- AUBIO_MSG("audio_unit: opened at %.0fHz, sw channels %din/%dout, hw channels %ldin/%ldout, hw vol %.2fin/%.2fout",
+ AUBIO_MSG("audio_unit: opened at %.0fHz, sw channels %din/%dout, hw channels %din/%dout, hw vol %.2fin/%.2fout\n",
input_hw_volume, output_hw_volume);
/* get max frames per slice */
thissize = sizeof(max_fps);
err = AudioUnitGetProperty (o->audio_unit, kAudioUnitProperty_MaximumFramesPerSlice,
kAudioUnitScope_Global, 0, &max_fps, &thissize);
input_hw_volume, output_hw_volume);
/* get max frames per slice */
thissize = sizeof(max_fps);
err = AudioUnitGetProperty (o->audio_unit, kAudioUnitProperty_MaximumFramesPerSlice,
kAudioUnitScope_Global, 0, &max_fps, &thissize);
- if (err) { AUBIO_ERR("audio_unit: could not get maximum frames per slice property %ld",
- err); goto fail; }
+ if (err) { AUBIO_ERR("audio_unit: could not get maximum frames per slice property %d\n",
+ (int)err); goto fail; }
/* get hardware latency */
thissize = sizeof(latency);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration,
&thissize, &latency);
/* get hardware latency */
thissize = sizeof(latency);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration,
&thissize, &latency);
/* get input latency */
thissize = sizeof(input_latency);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency,
&thissize, &input_latency);
/* get input latency */
thissize = sizeof(input_latency);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputLatency,
&thissize, &input_latency);
/* get output harlatency */
thissize = sizeof(output_latency);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputLatency,
&thissize, &output_latency);
/* get output harlatency */
thissize = sizeof(output_latency);
err = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareOutputLatency,
&thissize, &output_latency);
- AUBIO_MSG("audio_unit: I/O latency: %.2fms, %d frames, (%.2fms, %d frames in, %.2fms %d frames out)",
+ AUBIO_MSG("audio_unit: I/O latency: %.2fms, %d frames, (%.2fms, %d frames in, %.2fms %d frames out)\n",
latency*1000., (sint_t)round(latency*samplerate),
input_latency*1000., (sint_t)ROUND(input_latency*samplerate),
output_latency*1000., (sint_t)ROUND(output_latency*samplerate));
latency*1000., (sint_t)round(latency*samplerate),
input_latency*1000., (sint_t)ROUND(input_latency*samplerate),
output_latency*1000., (sint_t)ROUND(output_latency*samplerate));
}
err = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
sizeof(category), &category);
if (err) {
}
err = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
sizeof(category), &category);
if (err) {
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,
sizeof (allowMixing), &allowMixing);
if (err) {
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,
sizeof (allowMixing), &allowMixing);
if (err) {
CFStringRef currentRoute;
UInt32 val, thissize = sizeof(currentRoute);
OSStatus err = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &thissize, ¤tRoute);
CFStringRef currentRoute;
UInt32 val, thissize = sizeof(currentRoute);
OSStatus err = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &thissize, ¤tRoute);
CFNumberGetValue ( routeChangeReasonRef, kCFNumberSInt32Type, &change_reason_number);
switch (change_reason_number) {
case kAudioSessionRouteChangeReason_NewDeviceAvailable:
CFNumberGetValue ( routeChangeReasonRef, kCFNumberSInt32Type, &change_reason_number);
switch (change_reason_number) {
case kAudioSessionRouteChangeReason_NewDeviceAvailable: