Code Monkey home page Code Monkey logo

Comments (19)

alexbw avatar alexbw commented on July 26, 2024

Thanks for bringing this to my attention. I've never tested this use case before, but I'll look into it. If you have any solution in the meanwhile, please fork and make changes.

On Tuesday, June 5, 2012 at 4:19 PM, hoddez wrote:

Hi there,
First of all let me thank you for open sourcing this. It looks like a very valuable tool coming from somebody who has suffered from CoreAudio coding.

I've been checking out your library to see how robust it is in regards to backgrounding and interuptions etc.

I've found a crashing bug that initially makes me think it isn't that robust but maybe you can comment on it.

Testing on iPad 3 with iOS 5.1.
Simple app that launches a recording queue with:
audioManager = [Novocaine audioManager];
//This starts an input Block for recording. Set to audioManager.inputBlock=nil to stop
audioManager.inputBlock = ^(float *data, UInt32 numFrames, UInt32 numChannels) {
NSLog(@"stillgoing:%d",(int)numFrames);
};

I tried going in and out of background and that appears to work fine (for short term at least).

But if I send the app to background, then start playing audio from the stock Music app, then go back to the app running Novocaine I get this error in the console:
Error: Checking number of input channels ('!cat')


Reply to this email directly or view it on GitHub:
#15

from novocaine.

hoddez avatar hoddez commented on July 26, 2024

The problem is (obviously) with checking the number of input channels. Removing the section of code that does this is a workaround, but I'm guessing that code is there for a reason.

I know that you can't record audio while the stock music player is playing. So I guess that must block it from checking the number of input channels at that time. The weird thing is that if you take that out you can still record. Maybe if you check the number of channels later on in the cycle (once you've stopped the audio session from the music player).

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

The error is thrown on the check for the number of channels, but the problem most likely stems from an expired audio session. Novocaine only initializes an audio session once, and never checks if it expires. It works this way because I'd never had to build (or thought to build) long-running audio apps.

Does removing the audio channel check actually fix the problem? I'd be surprised if it does. I think the true fix is, in - (void)checkSessionProperties to see if the audio session is still valid, and if not, to re-initialize it.

from novocaine.

hoddez avatar hoddez commented on July 26, 2024

Yes, removing the check for input channels only will fix the problem. I haven't checked that the audio I get makes sense but everything appears to run fine and I still get a buffer every 1024 samples.

I tried moving the checkSessionProperties later on and that doesn't seem to help.

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Yeah, don't worry about moving checkSessionProperties, the fix has to
happen inside of checkSessionProperties. I'll peek inside the code in a day
or two, but for now, good to hear that removing the channel check fixes
your problem. Just hold onto that for now, but I should have a more
permanent fix for you in the near future.

On Wed, Jun 6, 2012 at 8:42 AM, hoddez <
[email protected]

wrote:

Yes, removing the check for input channels only will fix the problem. I
haven't checked that the audio I get makes sense but everything appears to
run fine and I still get a buffer every 1024 samples.

I tried moving the checkSessionProperties later on and that doesn't seem
to help.


Reply to this email directly or view it on GitHub:
#15 (comment)

from novocaine.

hoddez avatar hoddez commented on July 26, 2024

Thanks. Please let me know what the proper fix is. I'd be interested to hear about it

from novocaine.

hoddez avatar hoddez commented on July 26, 2024

Quick follow-up: You have to be sure to manually set self.numInputChannels = 1;

otherwise you just get 0s for recorded audio

from novocaine.

Baskaran avatar Baskaran commented on July 26, 2024

I too bumped on this problem. My app crashes once there is an incoming call with the !cat message... It is simply an invalid configuration issue between the foreground app and the incoming phone call..

from novocaine.

hoddez avatar hoddez commented on July 26, 2024

Baskaran, did my workaround work for you in this case or does an incoming call cause a crash even with the input channel code commented out?

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Just an FYI, having trouble setting aside time to work on Novocaine, but I haven't forgotten about the issue.

from novocaine.

soulfly avatar soulfly commented on July 26, 2024

Hi guys, i also have this problem, but in my case there is simple issue repro:

  1. I just present view controller,
  2. than do in it
    audioManager = [Novocaine audioManager];
  3. then dismiss view controller.
  4. then show present this controller again
  5. Crash

from novocaine.

ezrover avatar ezrover commented on July 26, 2024

Hi All, I have made some changes to separate the Init from the rest of the library since you can only call Init once when the application loads. I have not had time to update the sample application from the original version yet but you may want to give it a try to see if it solves your issue. On my forked version, it cleans up nicely on dealloc or when the window is closed.

from novocaine.

ezrover avatar ezrover commented on July 26, 2024

Also, I have not had the chance to test my mods against Mac version either! just iOS and it is ARC'ed...

from novocaine.

soulfly avatar soulfly commented on July 26, 2024

I found a solution:

Just add [sm pause]; to 'Begin interuption' - https://github.com/soulfly/novocaine/commit/15a0bffedcb8ea5441e7b8150d3f168a2e3ff247

from novocaine.

raja-baz avatar raja-baz commented on July 26, 2024

@soulfly That doesn't fix it for me. In fact, it would seem like that entire function is not being called(I don't get anything in the log about interruption beginning or ending) and the app still crashes sometimes when resuming from background.

from novocaine.

soulfly avatar soulfly commented on July 26, 2024

@raja-baz Please check my fork https://github.com/soulfly/novocaine with this fix.
It works for my project

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Issue a pull request if you've fixed it?

On Monday, March 4, 2013 at 10:33 AM, Igor Khomenko wrote:

@raja-baz (https://github.com/raja-baz) Please check my fork https://github.com/soulfly/novocaine with this fix.
It works for my project


Reply to this email directly or view it on GitHub (#15 (comment)).

from novocaine.

oceandull avatar oceandull commented on July 26, 2024

Audiobus provides a workaround in http://developer.audiob.us/doc/_thirty-_minute-_integration.html. The code piece is like:

UInt32 channels;
OSStatus result = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels);
if ( result == kAudioSessionIncompatibleCategory ) {
// Audio session error (rdar://13022588). Power-cycle audio session.
AudioSessionSetActive(false);
AudioSessionSetActive(true);
result = AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareInputNumberChannels, &size, &channels);
if ( result != noErr ) {
NSLog(@"Got error %d while querying input channels", result);
}
}

from novocaine.

alexbw avatar alexbw commented on July 26, 2024

Open pull request in a separate issue. Closing.

from novocaine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.