Bug 21940 - MonoTouch.AudioToolbox.AudioConverter:AudioConverterFillComplexBuffer throws error (did not appear on 7.2.5.5)
Summary: MonoTouch.AudioToolbox.AudioConverter:AudioConverterFillComplexBuffer throws ...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 7.2.6
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 8.6.x (services rel)
Assignee: Alex Soto [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2014-08-08 05:05 UTC by francois
Modified: 2015-12-03 13:26 UTC (History)
13 users (show)

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


Attachments
Sample project updated to work with latest Xamarin and demonstrating the problem (2.73 MB, application/x-zip-compressed)
2014-11-30 22:42 UTC, joshcomley@googlemail.com
Details


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:
VERIFIED FIXED

Description francois 2014-08-08 05:05:07 UTC
Hello,

My audio manipulation class worked well on MonoTouch 7.2.5, but now I have this exception thrown at me, without changing any code:

System.ArgumentException: ref argument outDataPacketDescription has to be set
  at MonoTouch.AudioToolbox.AudioConverter.FillComplexBufferShared (IntPtr inAudioConverter, System.Int32& ioNumberDataPackets, IntPtr ioData, IntPtr outDataPacketDescription, IntPtr inUserData) [0x00000] in <filename unknown>:0
  at at (wrapper native-to-managed) MonoTouch.AudioToolbox.AudioConverter:FillComplexBufferShared (intptr,int&,intptr,intptr,intptr)
  at at (wrapper managed-to-native) MonoTouch.AudioToolbox.AudioConverter:AudioConverterFillComplexBuffer (intptr,MonoTouch.AudioToolbox.AudioConverter/AudioConverterComplexInputDataShared,intptr,int&,intptr,intptr)
  at MonoTouch.AudioToolbox.AudioConverter.FillComplexBuffer (System.Int32& outputDataPacketSize, MonoTouch.AudioToolbox.AudioBuffers outputData, MonoTouch.AudioToolbox.AudioStreamPacketDescription[] packetDescription) [0x00000] in <filename unknown>:0
  at X.App.iOS.Utils.Audio.Mixer.EncodeMixedFlow (System.String path, X.App.iOS.Utils.Audio.MixProgressDelegate progressDelegate) [0x0022c] in /Users/xxx/Code/X.Xamarin/X.App.iOS/Utils/Audio/Mixer.cs:574
  at X.App.iOS.Utils.Audio.Mixer.Start (X.App.iOS.Utils.Audio.MixFinishedDelegate done, X.App.iOS.Utils.Audio.MixProgressDelegate progressDelegate) [0x000a1] in /Users/xxx/Code/X.Xamarin/X.App.iOS/Utils/Audio/Mixer.cs:74
  at X.App.iOS.SharingViewController.<ViewDidLoad>m__0 () [0x00052] in /Users/xxx/Code/X.Xamarin/X.App.iOS/SharingViewController.cs:55
  at MonoTouch.Foundation.NSObject.<InvokeInBackground>m__0 (System.Object v) [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x0002b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Threading/Thread.cs:693


My outputPacketDescriptions param is not null:
outputPacketDescriptions	{MonoTouch.AudioToolbox.AudioStreamPacketDescription[21]}
Comment 1 Sebastien Pouliot 2014-08-08 08:15:07 UTC
@alex, can you have a look (since you just fixed something else in that region of code0 ? thanks
Comment 2 Alex Soto [MSFT] 2014-08-08 15:26:04 UTC
Hello

I've been trying to replicate the error described above but I have not been able to do it.

@francois: Could you provide me a small test case so I can replicate the error?
Comment 3 joshcomley@googlemail.com 2014-11-30 20:05:29 UTC
This has just happened to me, too. No code change and exactly this error out of nowhere! I am converting WAVE to AAC.
Comment 4 joshcomley@googlemail.com 2014-11-30 22:42:42 UTC
Created attachment 8913 [details]
Sample project updated to work with latest Xamarin and demonstrating the problem

This is the original Xamarin sample project (http://developer.xamarin.com/samples/AudioConverterFileConverter/) but the project file just updated to work with the latest Xamarin. All other code is identical.

I am running this on an iPhone 4 (*not* 4S) and all conversions work except AAC which fails with the OOP's described error:

System.ArgumentException: ref argument outDataPacketDescription has to be set

The error occurs when converter.FillComplexBuffer(...) is called. More specifically it occurs when the converter.InputData event's delegate returns (which in this case is EncoderDataProc).
Comment 5 joshcomley@googlemail.com 2014-11-30 22:46:54 UTC
One more thing: it didn't just "stop working" as I earlier prescribed; I had forgotten one code change I had added the following necessary call:
AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.AudioProcessing);

(which in the case of the sample is the deprecated "AudioSession.Category = AudioSessionCategory.AudioProcessing")

The only reason the error was not appearing before was because I had a different error, precisely this one (just for your information):
http://stackoverflow.com/questions/24143378/audioconverterfillcomplexbuffer-returns-50-and-does-not-convert-anything
Comment 6 Prashant Cholachagudda 2014-12-23 00:40:06 UTC
We can repeat the issue using the Xamarin sample project (http://developer.xamarin.com/samples/AudioConverterFileConverter/) simply by choosing AAC and hitting convert. The AAC option is only available on iPhone4/5 hardware as it is greyed out in the simulator, and iPhone 6 (which appears to use a different type of hardware encoder that the project cannot detect).
Comment 7 Ryan 2015-01-13 07:13:37 UTC
In addition to comment 6, if you disable the check for AAC on an iPhone 6/6+ the the AAC conversion works fine. Looking at the Apple docs it seems that Xamarin have wrapped / simplified this encoder check  process and something somewhere has changed and broken their implementation 

https://developer.apple.com/library/ios/qa/qa1663/_index.html

We have a live project which relies heavily on this AAC conversion, I hope there is some progress very soon.
Comment 8 Ryan 2015-01-13 07:15:28 UTC
I should point out that the AAC conversion definitely doesn't work on any phones before iPhone 6.
Comment 9 Alex Soto [MSFT] 2015-01-13 13:22:25 UTC
Hello, I can confirm this issue is happening on 32 bit devices, any 64 bit device will work, I am working on a fix at the moment will reply back ASAP I have more details.
Comment 10 Ryan 2015-01-14 04:08:15 UTC
Brilliant, cheers Alex :) Good luck!
Comment 11 Rolf Bjarne Kvinge [MSFT] 2015-01-27 06:09:28 UTC
Fixed.

maccore/master: 588ca7edead56c0a63305b466b02bfee3477f6c0

This is a candidate for a service release, so keeping it open until a decision has been made.
Comment 12 Miguel de Icaza [MSFT] 2015-01-27 12:34:21 UTC
Rolf, 

I added this to the service release, can you update the card?

https://trello.com/c/BFLimsGM/15-xi-21940-audiobuffer-api-error
Comment 13 Atin 2015-02-02 00:36:07 UTC
I have tried to reproduce this issue with monotouch 7.2.6.28 , but not able to reproduce it. To reproduce this issue, I deployed the attached project (given in bug 21940) on device , but it is working fine. Please let me know, Should I follow different steps to reproduce this issue ?
Environment Info to reproduce the issue : https://gist.github.com/Shruti360/e6316d5c9e3953b522e3

I have checked the same on latest master builds, but here I am getting different behaviour. An error message "Debugger operation failed" get displayed after clicking on "Convert & Play File..." button
Here is the screencast regarding same : http://www.screencast.com/t/KZFig4eoXj5Z
Application Output : https://gist.github.com/Shruti360/b7d5802e4a47117d2fbe
Build Output : https://gist.github.com/Shruti360/2adf0f2022b522dd9b1f
IDE Log : https://gist.github.com/Shruti360/3a15db956bb1dcaa6517
Environment Info : https://gist.github.com/Shruti360/c40bcd31407a08e82e2d

Being now, I am not changing its status till get the confirmation from developer end.
Comment 14 Rolf Bjarne Kvinge [MSFT] 2015-02-02 03:33:49 UTC
@Atin, this can only be reproduced on older iOS devices (I haven't checked extensively, but iPhone 4s/iPad 2 and older for sure). Which device did you use?
Comment 15 Shruti 2015-02-02 06:03:08 UTC
@Rolf, Thanks for the guidance

Earlier we have checked it on iphone 5 iOS Version 8.1.2. Now as per  comment 14, we have checked it with iPhone 5 iOS Version 6.0.2 and 4S iOS Version 7.1.2 but still not able to reproduce it.
Comment 16 Rolf Bjarne Kvinge [MSFT] 2015-02-02 08:41:30 UTC
@Shruti, can you try with iPhone 4S and Xamarin.iOS 8.6 (the current stable release)? And what is the behaviour you're seeing? The exception isn't always thrown, but if the bug is fixed (or not present), you should hear audio.
Comment 17 Shruti 2015-02-02 09:52:57 UTC
@Rolf, I have checked this attached sample with iPhone 4S iOS Version  7.1.2 and iPad 2 iOS Version 7.1.2 on current stable.  I am able to hear audio with both devices.

Environment Info: https://gist.github.com/Shruti360/47060acd933c8693f147

Also can you please look into 2nd paragraph in Comment 13. We are observing different behaviour with the latest master builds specially with this sample project.  Should we report separate bug for this ?
Comment 18 Rolf Bjarne Kvinge [MSFT] 2015-02-02 10:14:36 UTC
@Shruti, no need to report the 2nd paragrah from comment #13, it's been reported in other bugs already. If it becomes an issue, you should still be able to reproduce this bug by tapping on the app (i.e. run without the debugger).

@Alex, you tried more devices than I did, any idea why Shruti is having problems reproducing the bug?
Comment 19 Alex Soto [MSFT] 2015-02-02 13:12:03 UTC
@Rolf this is because that only happens with ACC encoding so @Shruti must test ACC and on a 32 bit device like iPhone 5
Comment 20 Shruti 2015-02-03 02:31:54 UTC
#Reproduce Status : 
Thanks @Rolf and @Alex, Finally with your guidance I am able to reproduce this issue with monotouch 7.2.6. To Reproduce this issue, I have selected 'ACC' encoding and click on 'Convert & Play File...' button. After clicking button, I am not able to hear audio and it's giving exception as said in Comment #0 
"015-02-03 11:49:37.898 AudioConverterFileConverter[204:1403] Unhandled managed exception: ref argument outDataPacketDescription has to be set (System.ArgumentException)
  at MonoTouch.AudioToolbox.AudioConverter.FillComplexBufferShared (IntPtr inAudioConverter, System.Int32& ioNumberDataPackets, IntPtr ioData, IntPtr outDataPacketDescription, IntPtr inUserData) [0x0007e] in /Developer/MonoTouch/Source/maccore/src/AudioToolbox/AudioConverter.cs:523 
  at (wrapper native-to-managed) MonoTouch.AudioToolbox.AudioConverter:FillComplexBufferShared (intptr,int&,intptr,intptr,intptr)"

I also checked it with selecting other Encoding Formats (IMA, iLBC,ALAC), I am able to hear audio for all these formatter without any issue.
Build Info of reproducing issue : https://gist.github.com/Shruti360/9e2b9b82d09e661a4f28

## Verification Status: 
Now, I verified this issue with latest master builds. Here, app is getting crashed on clicking button "Convert $ Play File..." with all Encoding Format.
IDE Log : https://gist.github.com/Shruti360/3271ee0bb76e097ad85c
Symbolicated Crash Logs : https://gist.github.com/Shruti360/cac2c32ae728b1052eef
iOS Device Log : https://gist.github.com/Shruti360/a864d45b04b86f89d2b7 
Environment Info : https://gist.github.com/Shruti360/08a43e8659c3cb2784ac
Devices : 32 bit devices (iPhone 5 iOS Version 6.0.2 and 4S iOS Version 7.1.2)

Please let me know Should I file separate bug for this issue ?
Comment 21 Rolf Bjarne Kvinge [MSFT] 2015-02-04 09:26:27 UTC
@Shruti, the crash you refer to in comment #20 is a sample bug, and I've fixed it. Please retest with monotouch-samples/master 2c6f39909b9944ca59d7fd1849bc1b5cbf2237d7 (or later).
Comment 22 Rajneesh Kumar 2015-02-05 06:42:24 UTC
I have checked this issue with following sample:

Sample Info: monotouch-samples_2c6f39909b9944ca59d7fd1849bc1b5cbf2237d7 /AudioConverterFileConverter

To check this issue, I select 'ACC' encoding and click on 'Convert & Play File...' button. After clicking button, I observed that I am  am able to hear audio successfully without any error/exception. I am also able to hear audio successfully, after selecting 'IMA', 'iLBC', 'ALAC' Output encoding format.

This issue has been fixed, hence closing this issue.

Environment Info:

=== Xamarin Studio ===

Version 5.8 (build 764)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.9.1.44 (Business Edition)
Hash: 5482a19
Branch: master
Build date: 2015-01-31 13:50:55-0500

=== Xamarin.Android ===

Version: 4.99.0.311 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.4 (Business Edition)

=== Build Information ===

Release ID: 508000764
Git revision: 09d1d695e623b1d6957367ca9b131af5985a05ea
Build date: 2015-02-04 17:26:31-05
Xamarin addins: 4b8c08d9590e5a24f9ef5e98c18b2f30cf09819c

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 23 Sebastien Pouliot 2015-02-11 15:16:13 UTC
backported for SR2 in 3854065364393b3ef9ade6d58f46498593506ba1
Comment 24 Rajneesh Kumar 2015-02-12 11:50:57 UTC
I have checked this issue using Xamari.iOS Version: 8.6.2.8 with following sample:

Sample Info: monotouch-samples_2c6f39909b9944ca59d7fd1849bc1b5cbf2237d7
/AudioConverterFileConverter

To check this issue, I select 'ACC' encoding and click on 'Convert & Play File...' button. After clicking button, I observed that I am  am able to hear audio successfully without any error/exception. I am also able to hear audio successfully, after selecting 'IMA', 'iLBC', 'ALAC' options under 'Output encoding format' and '44.1k','22k','8k','Source' under 'Output sample rate'.

This issue has been fixed hence I am closing this issue.

=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.2.8 (Trial Edition)
Hash: 09ae75f
Branch: 
Build date: 2015-02-11 22:34:42-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Trial Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 25 renan jegouzo 2015-12-03 10:04:17 UTC
I still have this exception on a project that works well on OSX, but raise this exception on iOS.

code:
int np=bufferSize/pcm.BytesPerPacket;
var bs=new AudioBuffers(1);
bs[0]=new AudioToolbox.AudioBuffer { 
 Data=bigbuf,
 DataByteSize=bufferSize,
 NumberChannels=pcm.ChannelsPerFrame};
var err=decode.FillComplexBuffer(ref np,bs,null);

it's an MP3 to PCM converter.
Comment 26 renan jegouzo 2015-12-03 10:07:55 UTC
Xamarin Studio
Version 5.10.1 (build 3)
Installation UUID: 2a46676f-5eb8-4569-9aa7-630cd15bdfc2
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

Xamarin.iOS
Version: 9.2.1.54 (Business Edition)
Hash: eb4c1ef
Branch: master
Build date: 2015-12-01 02:12:30-0500

Xamarin.Mac
Version: 2.4.0.109 (Business Edition)

Build Information
Release ID: 510010003
Git revision: f2021a209d66d49cbc0649a6d968b29040e57807
Build date: 2015-12-01 10:43:40-05
Xamarin addins: dfd4f5103e8951edbc8ac24480b53b53c55e04ff
Build lane: monodevelop-lion-cycle6-baseline

Operating System
Mac OS X 10.11.1
Darwin macbook.home 15.0.0 Darwin Kernel Version 15.0.0
    Sat Sep 19 15:53:46 PDT 2015
    root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Comment 27 Rolf Bjarne Kvinge [MSFT] 2015-12-03 10:16:41 UTC
@renan, please file a new bug with a complete test project we can use to reproduce it and we'll have a look.
Comment 28 renan jegouzo 2015-12-03 10:44:01 UTC
made a test project, that works well ;)
sry..
Comment 29 renan jegouzo 2015-12-03 13:26:16 UTC
I'm filling a new bug, it depends of the stream.. some radio stream aren't playing.. (but play well with same code on OSX)