[TIMOB-1180] Recording audio crashes on 3GS device (but not in emulator!) under iOS 4.0 Ti 1.3.2
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:55:26.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.4.0 |
Components | iOS |
Labels | audio, crash, emulator, ios, iphone, recording |
Reporter | karlo |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:45:58.000+0000 |
Updated | 2011-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.
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)
I'm getting this issue as well - works fine in simulator - but crashes on the phone
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
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!
Have you made sure that your audio session mode is one of
Titanium.Media.AUDIO_SESSION_MODE_RECORD
orTitanium.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD
?Assigning to Blain because he is currently testing this under 4.0.
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:
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!
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.Ah, that's what I assumed. Thanks again for making this a priority! You guys rock!!
(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...
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.
Awesome! Again, I cannot say enough how cool you guys are! Many many thanks!