Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13525] iOS: Endless loop in AudioStreamerCUR

GitHub Issuen/a
TypeBug
PriorityLow
StatusReopened
ResolutionUnresolved
Affected Version/sRelease 3.0.2, Release 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMichael Descher
AssigneeUnknown
Created2013-02-27T19:32:05.000+0000
Updated2018-02-28T20:04:16.000+0000

Description

The following method is from AudioStreamerCUR.m in SDK 3.0.2.GA. When you call the stop method while in AS_STOPPING state the app gets into an endless loop at the end of the method. Depending on the audio file the AS_STOPPING state can be several seconds at the end of the song. Also it seems that other methods have problems with that state, e.g. pause seems to do nothing. This means that the player cannot be controlled and might hang the app in this state.
- (void)stop
{
	@synchronized(self)
	{
		if (audioQueue &&
			(state == AS_PLAYING || state == AS_PAUSED ||
				state == AS_BUFFERING || state == AS_WAITING_FOR_QUEUE_TO_START))
		{
			self.state = AS_STOPPING;
			stopReason = AS_STOPPING_USER_ACTION;
			err = AudioQueueStop(audioQueue, true);
			if (err)
			{
				[self failWithErrorCode:AS_AUDIO_QUEUE_STOP_FAILED];
				return;
			}
		}
		else if (state != AS_INITIALIZED)
		{
			self.state = AS_STOPPED;
			stopReason = AS_STOPPING_USER_ACTION;
		}
		seekWasRequested = NO;
	}
	
	while (state != AS_INITIALIZED)
	{
		[NSThread sleepForTimeInterval:0.1];
	}
}

Attachments

FileDateSize
app.js2013-04-04T17:24:39.000+0000851

Comments

  1. Michael Descher 2013-02-27

    Maybe it help that it seems that the call to
    err = AudioQueueDispose(audioQueue, true)
    in "startInternal" after "cleanup:" does not return. At least not in the debugger. And so the state is never set to AS_INITIALIZED.
  2. Michael Descher 2013-02-27

    Works fine with iOS 6.0 in the simulator, so it seems (that's what Google also suggested) that it is an iOS 6.1 issue. Maybe there is some possible workaround?
  3. Jamie Buckley 2013-04-03

    Hi Michael, Please can you provide a small reproducible test case that demonstrates this issue, a 100 line or so app.js file is preferred. For more information on how to submit a bug report check: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report Regards, Jamie
  4. Michael Descher 2013-04-04

    Please see the attached "app.js" and run it in the iPhone simulator. There is a text field with a predefined URL (which you can change) and start/stop buttons. When clicking the start button the audio player plays the specified URL. The predefined should be okay as long as it is reachable. Otherwise just select any MP3 file. It should not be too long since the effect is visible only at the end. Clicking the stop button stops playback which works fine. An alert is displayed which can be closed. When the audio player state changes to STOPPING, the change listner displays an alert box and stops the player. With iOS 6.1 this freezes th GUI forever. With iOS 6.0 it works fine.
  5. Michael Descher 2013-04-04

    Test project
  6. Daniel Sefton 2013-04-11

    Tested and confirmed on iOS 6.1.3 with Ti SDK 3.0.2 GA and latest 3.1 CI. Simply quickly tap the start and stop button until it hangs. Also get a the red exception screen sometimes complaining that stop is called too many times.

JSON Source