bluetooth headset and recording
bluetooth headset and recording
- Subject: bluetooth headset and recording
- From: Olivier Destrebecq <email@hidden>
- Date: Wed, 8 Feb 2006 14:53:31 -0500
I'm trying to record audio coming through the input. In this
particular instance the input is a bluetooth headset (this code works
with imic, isight, line in and some other USB input). I'm am
recording straight to AAC, maybe that would be the problem, but i
would assume that it should not cause any problem. Also note that i'm
setting an encoding bit rate for the converter to 32000. This fails
when called on the bluetooth input. How can i know what value are
legal to pass in there? Would that be the cause of the problem?
Thanks in advance
{
//create a fileWriter
//
const unsigned kBufferSize = 0x8000;
[self setAudioFileRecorder: new CAAudioFileRecorderInputSelection
(3, kBufferSize)]; //8Kb buffer
//set the input device for the file recorder
//
[self audioFileRecorder]->setDefaultInput([recordingDevice
deviceID]);
//create the directory reference and the filereference
//
FSRef parentDir;
CFURLGetFSRef((CFURLRef)[NSURL fileURLWithPath: [[self
tempFileRecordingPath] stringByDeletingLastPathComponent]], &parentDir);
//set the format for the destination file (AAC for our purpose)
//
MTCoreAudioStreamDescription *inputStreamDescription =
[recordingDevice streamDescriptionForChannel: 1
forDirection: kMTCoreAudioDeviceRecordDirection];
MTCoreAudioStreamDescription *audioStreamDescription =
[MTCoreAudioStreamDescription streamDescription];
[audioStreamDescription setFormatID: kAudioFormatMPEG4AAC];
[audioStreamDescription setChannelsPerFrame: 1];
[audioStreamDescription setFormatFlags: 2];
[audioStreamDescription setFramesPerPacket: 512]; //64kbps
[audioStreamDescription setSampleRate: [inputStreamDescription
sampleRate]];
//make sure the temp folder exists
//
NSAssert ([NSApplication temporaryDirectory], @"could not get
temp directory");
try
{
//create the audio file for the recorder
//
[self audioFileRecorder]->SetFile(parentDir,
(CFStringRef) [[self
tempFileRecordingPath] lastPathComponent],
kAudioFileM4AType,
CAStreamBasicDescription
([audioStreamDescription audioStreamBasicDescription]),
NULL);
}
catch (CAXException exception)
{
NSString *string = [NSString stringWithCString:
exception.mOperation];
NSLog (@"caught exception: %@", string);
[self setAudioFileRecorder: nil];
NSException *exception = [NSException exceptionWithName:
NSCocoaErrorDomain reason: string userInfo: nil];
NSAlert *alert = [NSAlert alertWithError: [NSError
errorWithException:exception]];
[alert setAlertStyle: NSCriticalAlertStyle];
[alert beginSheetModalForWindow: [self windowForSheet]
modalDelegate: nil
didEndSelector: nil
contextInfo: nil];
[exception raise];
}
try
{
CAAudioFile &recfile = [self audioFileRecorder]->GetFile();
int bitrate = 32000;
recfile.SetConverterProperty(kAudioConverterEncodeBitRate,
sizeof(UInt32), &bitrate);
}
catch (CAXException exception)
{
NSString *string = [NSString stringWithCString:
exception.mOperation];
NSLog (@"caught exception: %@", string);
//no big deal, the user just can't set the value he wants
there...
}
}
but when i run it with a bluetooth headset, i get a crash when i stop
the recording:
#0 0x05666974 in SMACMP4scomDispatch
#1 0x0566cbf0 in SMACMP4scomDispatch
#2 0x056f86fc in dyld_stub_memcmp
#3 0x90b5a684 in CallComponent
#4 0x9420ba04 in AudioCodecAppendInputData
#5 0x9410fa00 in CodecConverter::AppendNewInput
#6 0x9410f884 in CodecConverter::CallInputProc
#7 0x94154260 in CodecConverter::EncoderFillBuffer
#8 0x940f6fd8 in AudioConverterChain::RenderOutput
#9 0x940f6e5c in BufferedAudioConverter::FillBuffer
#10 0x940f6ce8 in AudioConverterFillComplexBuffer
#11 0x94176c88 in ExtAudioFile::WritePacketsFromCallback
#12 0x94176044 in ExtAudioFile::Write
#13 0x9416c1f0 in ExtAudioFileWrite
#14 0x0009da30 in CAAudioFile::Write at CAAudioFile.h:219
#15 0x0002f444 in CAAudioFileWriter::WriteBuffer at
CAAudioFileStreamer.cpp:219
#16 0x000978fc in CAAudioFileWriter::ProcessBuffer at
CAAudioFileStreamer.h:123
#17 0x000305ac in CAPushBufferQueue::Flush at CABufferQueue.cpp:261
#18 0x0002fee0 in CAAudioFileWriter::Stop at CAAudioFileStreamer.cpp:209
#19 0x0002f248 in CAAudioFileRecorder::Stop at
CAAudioFileRecorder.cpp:175
#20 0x00013b8c in -[presentationCastDocument stopRecording] at
presentationCastDocument.mm:757
#21 0x0001a898 in -[recorderWindowController startStopRecording:] at
recorderWindowController.mm:302
or if i leave it run for a couple seconds:
#0 0x05850410 in SMACMP4scomDispatch
#1 0x05856ac4 in SMACMP4scomDispatch
#2 0x058e2744 in dyld_stub_memcmp
#3 0x90b5a684 in CallComponent
#4 0x9420ba58 in AudioCodecProduceOutputPackets
#5 0x941542b8 in CodecConverter::EncoderFillBuffer
#6 0x940f6fd8 in AudioConverterChain::RenderOutput
#7 0x940f6e5c in BufferedAudioConverter::FillBuffer
#8 0x940f6ce8 in AudioConverterFillComplexBuffer
#9 0x94176c88 in ExtAudioFile::WritePacketsFromCallback
#10 0x94176044 in ExtAudioFile::Write
#11 0x9416c1f0 in ExtAudioFileWrite
#12 0x0009da30 in CAAudioFile::Write at CAAudioFile.h:219
#13 0x0002f444 in CAAudioFileWriter::WriteBuffer at
CAAudioFileStreamer.cpp:219
#14 0x000978fc in CAAudioFileWriter::ProcessBuffer at
CAAudioFileStreamer.h:123
Olivier Destrebecq
http://otusweb.spymac.com/portfolio/
_______________________________________________
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