Bug 2689 - All AudioFile::Read methods handle EOF incorrectly
Summary: All AudioFile::Read methods handle EOF incorrectly
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
Depends on:
Reported: 2011-12-29 11:04 UTC by Jackson Harper
Modified: 2012-01-12 19:12 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

test case (127.60 KB, application/zip)
2011-12-29 11:04 UTC, Jackson Harper

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jackson Harper 2011-12-29 11:04:09 UTC
Created attachment 1110 [details]
test case

Most of the Audio File Services Read functions (AudioFileReadBytes, AudioFileReadPackets) will return -1 when they encounter the EOF "error" (-39). However, from what I can tell this isn't really an error on iOS, it just means you have reached the end of the file. And the amount of data read will be specified in an out pointer. 

This means on MT a kind of standard read/eval loop doesn't work properly, returning -1 on the last chunk of data (small test case attached)

(NOTE: You'll have to move 1.caf into your apps Documents directory)

The workaround for this issue is to just trim the file read to the length of the file, but that isn't very elegant.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-01-03 13:15:19 UTC
For your test file I can't make AudioFileRead read more than 134640 bytes no matter what I do - maybe some data is discarded (headers, non-audio data, etc) when reading?
Comment 2 Jackson Harper 2012-01-03 13:27:24 UTC
Oh, i forgot to add the header info in the CWL, but for a car it should be 4096 bytes.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-01-03 13:39:19 UTC
And 134640 (the amount read with your test code) + 4096 = 138736 which is the size of the file.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-01-12 19:12:35 UTC
Fixed, will be included in 5.1.3.