Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1180] Recording audio crashes on 3GS device (but not in emulator!) under iOS 4.0 Ti 1.3.2

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:55:26.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsaudio, crash, emulator, ios, iphone, recording
Reporterkarlo
AssigneeReggie Seagraves
Created2011-04-15T02:45:58.000+0000
Updated2011-04-17T01:55:26.000+0000

Description

I have the below code to allow the user to press a button and record (other buttons etc to playback of course). The code is pretty much taken straight from KS and works perfectly in the emulator and on a pre- iOS 4.0 device. In the app, I tap the record button, app sits for a second and then crashes back to Springboard. I'm not 100% the crash is happening in the record, but I get no response from the app between the tapping of the record button and the crash.
And again, it works fine in the emulator. Any ideas? Thanks in advance!

// create record button
var buttonRecord = Ti.UI.createButton
({
    backgroundImage:'../images/record.png',
    width:50,
    height:60,
    left:107,
    top:4
});
buttonRecord.addEventListener( 'click', function()
{
    if ( recording.recording )
    {
        file = recording.stop();
        buttonRecord.backgroundImage = '../images/record.png';
        buttonPlay.enabled = true;
    }
    else
    {
        buttonRecord.backgroundImage = '../images/stop.png';
        recording.start();
        buttonPlay.enabled = false;
    }
});
buttonView.add( buttonRecord );

If I comment out "recording.start();" there are (of course) no crashes.

Comments

  1. karlo 2011-04-15

    Sorry, meant to mention I also tested this with KS e37f5dd and it exhibits the same behavior (which is pretty much expected, since I basically copied the KS code for my app)

  2. ranguard 2011-04-15

    I'm getting this issue as well - works fine in simulator - but crashes on the phone

  3. kosso 2011-04-15

    What compression codecs and formats are you trying?

    (I've yet to try my recorder on a 4.0 iOS device yet)

    try changing over to:

    recording.compression = Ti.Media.AUDIO_FORMAT_AAC;
    recording.format = Ti.Media.AUDIO_FILEFORMAT_MP4A;

    which I find gives great quality/filesize for the 3GS (on iOS < 4.0) - but crashes the 3G, where I had to use Ti.Media.AUDIO_FILEFORMAT_CAF and Ti.Media.AUDIO_FORMAT_LINEAR_PCM

  4. karlo 2011-04-15

    I'm using these:

    recording.compression = Ti.Media.AUDIO_FORMAT_ULAW;
    recording.format = Ti.Media.AUDIO_FILEFORMAT_WAVE;

    I tried with alternate compression/formats (including the combo you recommend above), but the behavior is the same: works fine on emulator, crashes on device.

    Thanks for the suggestion, though!

  5. Stephen Tramer 2011-04-15

    Have you made sure that your audio session mode is one of Titanium.Media.AUDIO_SESSION_MODE_RECORD or Titanium.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD?

    Assigning to Blain because he is currently testing this under 4.0.

  6. karlo 2011-04-15

    Thanks for updating the ticket, Stephen! I am setting the session mode (I neglected to include that bit in the code above). I have it set to:

       recording.audioSessionMode = Titanium.Media.AUDIO_SESSION_MODE_RECORD;
       

    I haven't tried PLAY_AND_RECORD but would be happy to if you think it will make a difference. I also haven't tried all permutations/combinations of compression and format, except for the two indicated above.

    Thanks again!

  7. Stephen Tramer 2011-04-15

    PLAY_AND_RECORD is actually going to be the same type of audio session (it allows recording and playback at the same time), so this will not fix your problem. We're working on it right now and I will be sure to close this bug once we have it resolved. This is a priority for 1.4 so expect it to be fixed by official release at the latest.

  8. karlo 2011-04-15

    Ah, that's what I assumed. Thanks again for making this a priority! You guys rock!!

  9. Jeff Haynie 2011-04-15

    (from [eadace1da081b2cbd8a5aee4c877cb006d221861]) Closes #1180: In pre-iOS 4, the device had its number of input channels set before setting RECORD modes. In iOS 4 this changed, presumably because the number of input chanels can change between recording sessions - presumably this was to deal with bugs involving swapping out the recording-enabled earbuds on Touch devices. http://github.com/appcelerator/titanium_mobile/commit/eadace1da081b2cbd8a5aee4c877cb006d221861"> http://github.com/appcelerator/titanium_mobile/commit/eadace1da081b...

  10. Blain Hamon 2011-04-15

    Haw. I just realized why this would be the case in iOS4. Up until now, all recordings are single channel because there's only one microphone. But what new feature was brought out with the iPhone 4? Yup, a second microphone, technically making two input channels. D'oh.

  11. karlo 2011-04-15

    Awesome! Again, I cannot say enough how cool you guys are! Many many thanks!

JSON Source