Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-02-2010, 04:58 AM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 19
newIphoneprogrammer is on a distinguished road
Send a message via Skype™ to newIphoneprogrammer
Default Problem Problem problem With Voice Recording and pLaying

Code:
	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");
		
	}

where ever i use Above code i am able to play sound file in Silent mode

but after playing file


when i try to record another voice

i get an error here


Code:
	// 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;
error :
Could not start Audio Queue


Please solve my problem i will be very thanks for to you
__________________
In Order to Change The World Change yourself
newIphoneprogrammer is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, iphone, recording, xcode 4.0

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 364
6 members and 358 guests
daudrizek, HemiMG, Kirkout, MarkC, Sami Gh
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:50 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0