Bug 1552 - new AVAssetReaderAudioMixOutput(songAsset.Tracks, null) throws exception
Summary: new AVAssetReaderAudioMixOutput(songAsset.Tracks, null) throws exception
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Other Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-10-18 18:27 UTC by Loïc Dansart
Modified: 2011-10-18 18:42 UTC (History)
3 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 FIXED

Description Loïc Dansart 2011-10-18 18:27:18 UTC
This bug has already been reported here: https://bugzilla.novell.com/show_bug.cgi?id=663861 and marked as "Resolved", despite still being present in Monotouch 5.0

There is a check in AVAssetReaderAudioMixOutput's constructor that refuses null values for the outputSettings dictionary, even though it is a valid value (that case is handled correctly in AVAssetReaderTrackOutput's).


Copy paste of the original report:


Exception says "Argument cannot be null".

The following fails too:

AVAssetReaderOutput assetReaderOutput = new
AVAssetReaderAudioMixOutput(songAsset.Tracks, new NSDictionary());

MonoTouchException: "Objective-C exception thrown.  Name:
NSInvalidArgumentException Reason: *** +[AVAudioOutputSettings
_outputSettingsWithOutputSettingsDictionary:exceptionReason:] invalid parameter
not satisfying: [outputSettingsDictionary count] > 0"



Reproducible: Always

Steps to Reproduce:
1. Compile and run:

            MPMediaItem curItem =
MPMusicPlayerController.iPodMusicPlayer.NowPlayingItem;        

            NSUrl url =
(NSUrl)curItem.ValueForProperty(MPMediaItemProperty.AssetUrl);

            NSDictionary dict = new NSDictionary();
            AVUrlAsset songAsset = AVUrlAsset.FromUrl(assetUrl, dict);
            NSError error = new NSError(NSObjectFlag.Empty);
            AVAssetReader assetReader = AVAssetReader._FromAsset(songAsset,
error.Handle);

            if (assetReader == null) 
            {
                Console.WriteLine(error.LocalizedDescription);
                return;
            }

            AVAssetReaderOutput assetReaderOutput = new
AVAssetReaderAudioMixOutput(songAsset.Tracks, null);

2. Exception thrown
Actual Results:  
Exception thrown

Expected Results:  
Should be supported as per iOS documentation:

audioSettings
The audio settings to be used for audio output; the dictionary must contain
values for keys in AVAudioSettings.h (linear PCM only).
Pass nil if you want to receive decoded samples in a convenient uncompressed
format, with properties determined according to the properties of the specified
audio tracks.
Comment 1 Jeffrey Stedfast 2011-10-18 18:42:45 UTC
Thanks for the bug report Loic! I've just fixed this in all branches of MonoTouch (so it should be resolved in 4.2.3, 5.0.1, and 5.1.0)

Whoever fixed the original bug report fixed AVAssetReaderAudioMixOutput.FromTracks() but not the normal ctor.