Bug 41077 - IAudioFileStream.ParseBytes / AudioFileStreamParseBytes
Summary: IAudioFileStream.ParseBytes / AudioFileStreamParseBytes
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 9.6 (iOS 9.3)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-05-13 15:57 UTC by softlion
Modified: 2016-05-14 09:36 UTC (History)
2 users (show)

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

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:
Status:
RESOLVED INVALID

Description softlion 2016-05-13 15:57:04 UTC
Hi there,
i'm using the AudioFileStream class to decode audio samples loaded from an audio stream.
At the start of the stream, ParseBytes always crashes:

afs.ParseBytes failed: Object reference not set to an instance of an object 

ParseBytes is called with bytes count=14229 vbr=False

In your implementation:

    [DllImport("/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox")]
    private static extern AudioFileStreamStatus AudioFileStreamParseBytes(IntPtr inAudioFileStream, int inDataByteSize, IntPtr inData, uint inFlags);

io doc:

    func AudioFileStreamParseBytes(_ inAudioFileStream: AudioFileStreamID, _ inDataByteSize: UInt32, _ inData: UnsafePointer<Void>, _ inFlags: AudioFileStreamParseFlags) -> OSStatus

Should your DllImport use nuint and nint instead if int and uint ?
Comment 1 Sebastien Pouliot 2016-05-13 17:25:37 UTC
No, the native `UInt32` is always 32bits like the managed `int` being used. A `nint` would be 64bits on 64bits platforms and that would cause issues. A `nint` is used to represent NSInteger (which size vary per platform).

Also the fact that you get a managed exception also make it sound unrelated to a p/invoke issue.

Can you give us a test case that demonstrate the issue ? thanks!
Comment 2 softlion 2016-05-14 08:50:43 UTC
Ok thks for the info.

I've duplicated the AudioFileStream class and now it works as expected. Not sure what the problem is.
Comment 3 softlion 2016-05-14 08:51:29 UTC
I've duplicated the AudioFileStream class and now it works as expected. Not sure what the problem is.
Comment 4 softlion 2016-05-14 09:36:10 UTC
Ok found the problem. Thks for your answers.