~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/maccore/src/AVFoundation/AVAudioRecorder.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
namespace MonoMac.AVFoundation {
31
31
 
 
32
        [Advice ("Use AudioSettings instead")]
32
33
        public class AVAudioRecorderSettings {
33
34
                public AVAudioRecorderSettings ()
34
35
                {
51
52
                {
52
53
                        var dict = new NSMutableDictionary ();
53
54
 
54
 
                        dict.SetObject (new NSNumber ((int) AudioFormat), AVAudioPlayer.AVFormatIDKey);
55
 
                        dict.SetObject (new NSNumber (SampleRate), AVAudioPlayer.AVSampleRateKey);
56
 
                        dict.SetObject (new NSNumber (NumberChannels), AVAudioPlayer.AVNumberOfChannelsKey);
 
55
                        dict.SetObject (new NSNumber ((int) AudioFormat), AVAudioSettings.AVFormatIDKey);
 
56
                        dict.SetObject (new NSNumber (SampleRate), AVAudioSettings.AVSampleRateKey);
 
57
                        dict.SetObject (new NSNumber (NumberChannels), AVAudioSettings.AVNumberOfChannelsKey);
57
58
 
58
59
                        if (AudioFormat == AudioFormatType.LinearPCM){
59
60
                                IntPtr thandle = CFBoolean.True.Handle;
61
62
                                
62
63
                                if (LinearPcmBitDepth != 0){
63
64
                                        if (LinearPcmBitDepth == 8 || LinearPcmBitDepth == 16 || LinearPcmBitDepth == 32 || LinearPcmBitDepth == 24)
64
 
                                                dict.SetObject (new NSNumber (LinearPcmBitDepth), AVAudioRecorder.AVLinearPCMBitDepthKey);
 
65
                                                dict.SetObject (new NSNumber (LinearPcmBitDepth), AVAudioSettings.AVLinearPCMBitDepthKey);
65
66
                                        else
66
67
                                                throw new Exception ("Invalid value for LinearPcmBitDepth, must be one of 8, 16, 24 or 32");
67
68
                                }
68
 
                                dict.LowlevelSetObject (LinearPcmBigEndian ? thandle : fhandle, AVAudioRecorder.AVLinearPCMIsBigEndianKey.Handle);
69
 
                                dict.LowlevelSetObject (LinearPcmFloat ? thandle : fhandle, AVAudioRecorder.AVLinearPCMIsFloatKey.Handle);
70
 
                                dict.LowlevelSetObject (LinearPcmNonInterleaved ? thandle : fhandle, AVAudioRecorder.AVLinearPCMIsNonInterleaved.Handle);
 
69
                                dict.LowlevelSetObject (LinearPcmBigEndian ? thandle : fhandle, AVAudioSettings.AVLinearPCMIsBigEndianKey.Handle);
 
70
                                dict.LowlevelSetObject (LinearPcmFloat ? thandle : fhandle, AVAudioSettings.AVLinearPCMIsFloatKey.Handle);
 
71
                                dict.LowlevelSetObject (LinearPcmNonInterleaved ? thandle : fhandle, AVAudioSettings.AVLinearPCMIsNonInterleaved.Handle);
71
72
                        }
72
 
                        dict.SetObject (new NSNumber ((int) AudioQuality), AVAudioRecorder.AVEncoderAudioQualityKey);
 
73
                        dict.SetObject (new NSNumber ((int) AudioQuality), AVAudioSettings.AVEncoderAudioQualityKey);
73
74
                        if (EncoderBitRate.HasValue)
74
 
                                dict.SetObject (new NSNumber ((int) EncoderBitRate.Value), AVAudioRecorder.AVEncoderBitRateKey);
 
75
                                dict.SetObject (new NSNumber ((int) EncoderBitRate.Value), AVAudioSettings.AVEncoderBitRateKey);
75
76
                        if (EncoderBitRatePerChannel.HasValue)
76
 
                                dict.SetObject (new NSNumber ((int) EncoderBitRatePerChannel.Value), AVAudioRecorder.AVEncoderBitRatePerChannelKey);
 
77
                                dict.SetObject (new NSNumber ((int) EncoderBitRatePerChannel.Value), AVAudioSettings.AVEncoderBitRatePerChannelKey);
77
78
                        if (EncoderBitDepthHint.HasValue){
78
79
                                var n = EncoderBitDepthHint.Value;
79
80
                                if (n < 8 || n > 32)
80
81
                                        throw new Exception ("EncoderBitDepthHint should be a value between 8 and 32");
81
 
                                dict.SetObject (new NSNumber ((int) EncoderBitDepthHint.Value), AVAudioRecorder.AVEncoderBitDepthHintKey);
 
82
                                dict.SetObject (new NSNumber ((int) EncoderBitDepthHint.Value), AVAudioSettings.AVEncoderBitDepthHintKey);
82
83
                        }
83
84
                        if (SampleRateConverterAudioQuality.HasValue)
84
 
                                dict.SetObject (new NSNumber ((int) SampleRateConverterAudioQuality.Value), AVAudioRecorder.AVSampleRateConverterAudioQualityKey);
 
85
                                dict.SetObject (new NSNumber ((int) SampleRateConverterAudioQuality.Value), AVAudioSettings.AVSampleRateConverterAudioQualityKey);
85
86
 
86
87
                        return dict;
87
88
                }
88
89
        }
89
90
 
90
91
        public partial class AVAudioRecorder {
91
 
                [Obsolete ("Use the factory AVAudioRecorder.ToUrl as this method had an invalid signature up to MonoMac 1.4.4")]
 
92
                [Obsolete ("Use static Create method as this method had an invalid signature up to MonoMac 1.4.4", true)]
92
93
                public AVAudioRecorder (NSUrl url, NSDictionary settings, NSError outError)
93
94
                {
94
95
                        throw new Exception ("This constructor is no longer supported, use the AVAudioRecorder.ToUrl factory method instead");
95
96
                }
96
97
 
 
98
                public static AVAudioRecorder Create (NSUrl url, AudioSettings settings, out NSError error)
 
99
                {
 
100
                        if (settings == null)
 
101
                                throw new ArgumentNullException ("settings");
 
102
                        
 
103
                        return ToUrl (url, settings.Dictionary, out error);
 
104
                }
 
105
 
 
106
                [Advice ("Use Create method")]
97
107
                public static AVAudioRecorder ToUrl (NSUrl url, AVAudioRecorderSettings settings, out NSError error)
98
108
                {
99
109
                        if (settings == null)
101
111
                        
102
112
                        return ToUrl (url, settings.ToDictionary (), out error);
103
113
                }
104
 
                
 
114
 
 
115
                [Advice ("Use Create method")]          
105
116
                public static AVAudioRecorder ToUrl (NSUrl url, NSDictionary settings, out NSError error)
106
117
                {
107
118
                        unsafe {