Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 776843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:30:56+00:00 2026-05-14T19:30:56+00:00

I am facing a strange problem with AVAudioRecorder. In my application i need to

  • 0

I am facing a strange problem with AVAudioRecorder. In my application i need to record audio and play it. I am creating my player as :

if(recorder)
{
if(recorder.recording)
[recorder stop];
[recorder release];
recorder = nil;
}

NSString * filePath = [NSHomeDirectory() stringByAppendingPathComponent: [NSString stringWithFormat:@"Documents/%@.caf",songTitle]];
        NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys:
                                        [NSNumber numberWithFloat: 44100.0],AVSampleRateKey,
                                        [NSNumber numberWithInt: kAudioFormatAppleIMA4],AVFormatIDKey,
                                        [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                                        [NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil];
        recorder = [[AVAudioRecorder alloc] initWithURL: [NSURL fileURLWithPath:filePath] settings: recordSettings error: nil];
        recorder.delegate = self;
if ([recorder prepareToRecord] == YES){
                [recorder record];

I am releasing and creating player every time I press record button. But the problem is that, AVAudiorecorder is taking some time before starting to record, and so if I press record button multiple times continuously, my application freezes for some time.

The same code works fine without any problem when headphones are connected to device…there is no delay in recording, and the app doesn’t freeze even if I press record button multiple times.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:30:56+00:00Added an answer on May 14, 2026 at 7:30 pm

    Got the solution. I just added the code

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
            NSError *err = nil;
            [audioSession setCategory :AVAudioSessionCategoryPlayAndRecord error:&err];
            if(err){
                NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
                return;
            }
            err = nil;
            [audioSession setActive:YES error:&err];
            if(err){
                NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
                return;
            }
    

    and it is now working fine. However i want to know what difference does this piece of code made? And why it was like that my application was working fine with headphones connected but freezed without them.?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a strange problem in cakePHP. The issue is when ever i
I'm facing very strange problem - my app is working nice on a device
I am facing a very strange problem. I have a grid and when i
I am facing a strange error in MOSS 2007 running under Windows 2008. I
I seem to be facing a strange issue in SQL 2008. I have a
In an site I'm currently writing, I'm facing a strange, mind-boggling behaviour: after seconds
I am facing problem when comparing 2 strings values using C:When tag I am
Folks, in my application I'm using clock_gettime(CLOCK_MONOTONIC) in order to measure the delta time
So I've made custom function for a game I'm working on, one being fade
I have a webpage with a tiled background body image. It needs to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.