Ported error handling from the previous Audjustable player.

STKDataSource is designed to return values < 0 in case of error, but new STKAudioPlayer doesn't handle that, which causes crash few lines later when calling AudioFileStreamParseBytes with read<0.
This commit is contained in:
Andrew Kosovich 2014-02-14 13:37:43 +02:00
parent 6eb149f83a
commit 9aed1b082a
1 changed files with 11 additions and 0 deletions

View File

@ -1470,6 +1470,17 @@ static void AudioFileStreamPacketsProc(void* clientData, UInt32 numberBytes, UIn
}
}
if (read < 0)
{
// iOS will shutdown network connections if the app is backgrounded (i.e. device is locked when player is paused)
// We try to reopen -- should probably add a back-off protocol in the future
long long position = currentlyReadingEntry.dataSource.position;
[currentlyReadingEntry.dataSource seekToOffset:position];
return;
}
int flags = 0;
if (discontinuous)