Kunne ikke starte Audio Queue Feil starter opptak

stemmer
1
    CFStringRef state; 
    UInt32 propertySize = sizeof(CFStringRef); 
//  AudioSessionInitialize(NULL, NULL, NULL, NULL); 
    AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
    if(CFStringGetLength(state) == 0)
//  if(state == 0)
    { //SILENT
        NSLog(@Silent switch is on);
    //  create vibrate 
    //  AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    UInt32 audioCategory = kAudioSessionCategory_MediaPlayback;
    AudioSessionSetProperty( kAudioSessionProperty_AudioCategory, sizeof(UInt32), &audioCategory);

    }
    else { //NOT SILENT
        NSLog(@Silent switch is off);

    }

hvor enn jeg bruker koden ovenfor jeg er i stand til å spille av lyd fil i stille modus

men etter å ha spilt innspilt lydfil i stille modus når jeg prøver å ta opp stemmen igjen

Jeg får en feilmelding

Som

2010-12-08 13: 29: 56,710 VoiceRecorder [382: 307] -66681 Kan ikke starte Audio Queue Feil starter opptak

her er koden

    // file url
[self setupAudioFormat:&recordState.dataFormat];
CFURLRef fileURL =  CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8 *) [filePath UTF8String], [filePath length], NO);
// recordState.currentPacket = 0;
    // new input queue
OSStatus status;
status = AudioQueueNewInput(&recordState.dataFormat, HandleInputBuffer, &recordState, CFRunLoopGetCurrent(),kCFRunLoopCommonModes, 0, &recordState.queue);
if (status) {CFRelease(fileURL); printf(Could not establish new queue\n); return NO;}
    // create new audio file
status = AudioFileCreateWithURL(fileURL, kAudioFileAIFFType, &recordState.dataFormat, kAudioFileFlags_EraseFile, &recordState.audioFile);   CFRelease(fileURL); // thanks august joki
if (status) {printf(Could not create file to record audio\n); return NO;}
    // figure out the buffer size
DeriveBufferSize(recordState.queue, recordState.dataFormat, 0.5, &recordState.bufferByteSize);      // allocate those buffers and enqueue them
for(int i = 0; i < NUM_BUFFERS; i++)
{
    status = AudioQueueAllocateBuffer(recordState.queue, recordState.bufferByteSize, &recordState.buffers[i]);
    if (status) {printf(Error allocating buffer %d\n, i); return NO;}

    status = AudioQueueEnqueueBuffer(recordState.queue, recordState.buffers[i], 0, NULL);
    if (status) {printf(Error enqueuing buffer %d\n, i); return NO;}
}       // enable metering
UInt32 enableMetering = YES;
status = AudioQueueSetProperty(recordState.queue, kAudioQueueProperty_EnableLevelMetering, &enableMetering,sizeof(enableMetering));
if (status) {printf(Could not enable metering\n); return NO;}
    // start recording
status = AudioQueueStart(recordState.queue, NULL); //   status = 0;     NSLog(@%d,status);
if (status) {printf(Could not start Audio Queue\n); return NO;}
recordState.currentPacket = 0;
recordState.recording = YES;
return YES;

Jeg får en feilmelding her

Publisert på 08/12/2010 klokken 06:40
kilden bruker
På andre språk...                            


1 svar

stemmer
0

Jeg sto overfor lignende problem i iOS 7.1. Legg følgende i AppDelegate's didFinishLaunchingWithOptions:

AVAudioSession * audioSession = [AVAudioSession sharedInstance]; 
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: nil]; 
[audioSession setActive:YES error: nil]; 

EDIT : Over koden fungerer for meg

Svarte 26/03/2014 kl. 03:52
kilden bruker

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more