I am new in ios developement.I have downloaded sample audio recorder project from https://github.com/vecter/Audio-Queue-Services-Example using Audio Queue Service with the help of AudioToolBox framework .In that sample project recorded audio format is .aif. while run the downloaded sample project working fine.In the sample example project using how to record audio like .mp3 format .how can i do this?
simply i have changed kAudioFileAIFFType into kAudioFileMP3Type i am getting message from nslog
//---------nslog message--------------
Not recording, returning
Writing buffer 0
//------------------
- (void)startRecording
{
[self setupAudioFormat:&recordState.dataFormat];
recordState.currentPacket = 0;
OSStatus status;
status = AudioQueueNewInput(&recordState.dataFormat,
AudioInputCallback,
&recordState,
CFRunLoopGetCurrent(),
kCFRunLoopCommonModes,
0,
&recordState.queue);
if (status == 0)
{
// Prime recording buffers with empty data
for (int i = 0; i < NUM_BUFFERS; i++)
{
AudioQueueAllocateBuffer(recordState.queue, 16000, &recordState.buffers[i]);
AudioQueueEnqueueBuffer (recordState.queue, recordState.buffers[i], 0, NULL);
}
status = AudioFileCreateWithURL(fileURL,
kAudioFileMP3Type,
&recordState.dataFormat,
kAudioFileFlags_EraseFile,
&recordState.audioFile);
if (status == 0)
{
recordState.recording = true;
status = AudioQueueStart(recordState.queue, NULL);
if (status == 0)
{
labelStatus.text = @"Recording";
}
}
}
if (status != 0)
{
[self stopRecording];
labelStatus.text = @"Record Failed";
}
}
//---------------------------------------------------------------------------
- (void)startPlayback
{
playState.currentPacket = 0;
[self setupAudioFormat:&playState.dataFormat];
OSStatus status;
status = AudioFileOpenURL(fileURL, kAudioFileReadPermission, kAudioFileMP3Type, &playState.audioFile);
if (status == 0)
{
status = AudioQueueNewOutput(&playState.dataFormat,
AudioOutputCallback,
&playState,
CFRunLoopGetCurrent(),
kCFRunLoopCommonModes,
0,
&playState.queue);
if (status == 0)
{
// Allocate and prime playback buffers
playState.playing = true;
for (int i = 0; i < NUM_BUFFERS && playState.playing; i++)
{
AudioQueueAllocateBuffer(playState.queue, 16000, &playState.buffers[i]);
AudioOutputCallback(&playState, playState.queue, playState.buffers[i]);
}
status = AudioQueueStart(playState.queue, NULL);
if (status == 0)
{
labelStatus.text = @"Playing";
}
}
}
if (status != 0)
{
[self stopPlayback];
labelStatus.text = @"Play failed";
}
}