Initializing input
Initializing input
- Subject: Initializing input
- From: Sergei Ludanov <email@hidden>
- Date: Thu, 30 Oct 2003 18:59:43 -0800
I am quite new to CoreAudio and have a problem that I can't figure out,
so any help will be greatly appreciated.
I need to setup input audio device. Here is the code I use (and I must
say I am not sure if it is really right way to so):
-(void) setupSoundDevice
{
OSStatus err = noErr;
UInt32 count, bufferSize;
AudioDeviceID device = kAudioDeviceUnknown;
AudioStreamBasicDescription format;
_deviceReady = NO;
// get the default input device for the HAL
count = sizeof(AudioDeviceID);
err =
AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice,
&count, (void *) &device);
// set the buffersize for the default device to use for IO
count = sizeof(UInt32);
bufferSize = 3520 * 8;
//set buffersize to 28160, actually it is 3520 pixels * 2
(stereo) * 4 (size of float)
err = AudioDeviceSetProperty(device, 0, 0, false,
kAudioDevicePropertyBufferSize, count, &bufferSize);
if (err != noErr) return;
// get a description of the data format used by the default device
count = sizeof(AudioStreamBasicDescription);
err = AudioDeviceGetProperty(device, 0, false,
kAudioDevicePropertyStreamFormat, &count, &format);
if (err != noErr) return;
// we want linear pcm
if(format.mFormatID != kAudioFormatLinearPCM) return;
// everything is ok so fill in these globals
_device = device;
_bufferSize = bufferSize;
_format = format;
_deviceReady = YES;
}
This code works with almost every computer I tried on, except my Cube
with iMic USB Audio. It tells me that kAudioDevicePropertyBufferSize
and kAudioDevicePropertyStreamFormat are unsupported properties. Is
there other way to init iMic as input device? I use the same routine to
init output device and iMic does not complain about the same
properties...
Thanks,
Sergei Ludanov
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.