Bug 37657 - crash cause of OutputAudioQueue.AllocateBuffer(size,out ptrbuf); returning invalid buffers..
Summary: crash cause of OutputAudioQueue.AllocateBuffer(size,out ptrbuf); returning in...
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: 2.4.0 (C6)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
Depends on:
Reported: 2016-01-13 18:05 UTC by renan jegouzo
Modified: 2016-01-14 09:10 UTC (History)
1 user (show)

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:

Description renan jegouzo 2016-01-13 18:05:46 UTC
crash with simple silent OutputAudioQueue

sample project:

Xamarin Studio
Version 5.10.1 (build 6)
Installation UUID: 2a46676f-5eb8-4569-9aa7-630cd15bdfc2
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

Not Installed

Apple Developer Tools
Xcode 7.2 (9548)
Build 7C68

Version: (Business Edition)
Hash: 7322991
Branch: master
Build date: 2015-12-08 16:20:29-0500

Version: (Business Edition)

Build Information
Release ID: 510010006
Git revision: 0b60eecdb531933734519c13257d16a780274aab
Build date: 2015-12-04 20:28:20-05
Xamarin addins: 9876fd7c9837977178411ec7375b4352c0a0d6af
Build lane: monodevelop-lion-cycle6-baseline

Operating System
Mac OS X 10.11.2
Darwin macbook.home 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 1 renan jegouzo 2016-01-13 19:06:33 UTC
if you comment the AppDelegate.cs:line 37
like this

no crash
Comment 2 Chris Hamons 2016-01-13 20:10:12 UTC
So this is not a bug with Xamarin.Mac. You are misusing the Api in question. As you can see here:



and in these random internet examples:

The AudioQueueBufferRef value is not simply a buffer you can copy into. Your code is spraying memory with the marshal call and thus crashing.

This API is rather non-trivial to learn, to say it nicely. You can look at examples here:


(which is iOS, but should apply mostly to XM)

And here's a hacky sample I released when people on the forums ran into issues:


Good Luck.
Comment 3 renan jegouzo 2016-01-14 07:05:17 UTC
I know this sample, I use it too.
there is no reason for the crash, in the official documentation you gave me.

the project is like this one (in objective C)

Comment 4 renan jegouzo 2016-01-14 07:27:40 UTC
OK, I fixed the crash with

for(int i=0; i<oggBufferCount; i++) {
  unsafe {
    AudioQueueBuffer* aqb; 
      var st=output.AllocateBuffer(oggBufferSize,out aqb);
        throw new Exception(st.ToString());

I think it' important to have a working simple OutputAudioQueue example, to get the trick.

now I have a problem with the CFRunLoop.Current.Run();
that exits immediatly
Comment 5 renan jegouzo 2016-01-14 07:29:55 UTC
oops the complete code
Comment 6 renan jegouzo 2016-01-14 08:17:43 UTC
I started programming in assembly language on z80, after 68000, X86 and ARM. I can tell it's
Comment 7 renan jegouzo 2016-01-14 08:18:10 UTC
a simple API, the only problem here is Xamarin
Comment 8 renan jegouzo 2016-01-14 08:39:04 UTC
API that is really fuzzy
Comment 9 renan jegouzo 2016-01-14 08:40:28 UTC
Xamarin wrapper**
Comment 10 renan jegouzo 2016-01-14 09:10:18 UTC
ok I got it, it works