示例#1
0
        public static AudioSessionErrors AddListener(AudioSessionProperty property, PropertyListener listener)
        {
            if (listener == null)
            {
                throw new ArgumentNullException("listener");
            }

            if (listeners == null)
            {
                listeners = new Dictionary <AudioSessionProperty, List <PropertyListener> > ();
            }

            List <PropertyListener> a;

            if (!listeners.TryGetValue(property, out a))
            {
                listeners [property] = a = new List <PropertyListener> ();
            }

            a.Add(listener);

            if (a.Count == 1)
            {
                return(AudioSessionAddPropertyListener(property, Listener, IntPtr.Zero));
            }

            return(AudioSessionErrors.None);
        }
示例#2
0
        public static void AddListener(AudioSessionProperty property, PropertyListener listener)
        {
            if (listener == null)
            {
                throw new ArgumentNullException("listener");
            }

            if (listeners == null)
            {
                listeners = new Hashtable();
            }

            ArrayList a = (ArrayList)listeners [property];

            if (a == null)
            {
                listeners [property] = a = new ArrayList();
            }

            a.Add(listener);

            if (a.Count == 1)
            {
                AudioSessionAddPropertyListener(property, Listener, IntPtr.Zero);
            }
        }
		static void SetDouble (AudioSessionProperty property, double val)
		{
			unsafe {
				int k = AudioSessionSetProperty (property, 8, (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);
			}
		}
		static void SetInt (AudioSessionProperty property, int val)
		{
			unsafe {
				int k = AudioSessionSetProperty (property, sizeof (int), (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);
			}
		}
		static void SetFloat (AudioSessionProperty property, float val)
		{
			unsafe {
				int k = AudioSessionSetProperty (property, 4, (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);
			}
		}
		static float GetFloat (AudioSessionProperty property)
		{
			unsafe {
				float val = 0;
				int size = 4;
				int k = AudioSessionGetProperty (property, ref size, (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);
				return val;
			}
		}
		static void AddListenerEvent (AudioSessionProperty property, object handler, PropertyListener listener)
		{
			if (strongListenerHash == null)
				Interlocked.CompareExchange (ref strongListenerHash, new Hashtable (), null);

			lock (strongListenerHash) {
				strongListenerHash [handler] = listener;
			}

			AddListener (property, listener);
		}
		static double GetDouble (AudioSessionProperty property)
		{
			unsafe {
				double val = 0;
				int size = 8;
				int k = AudioSessionGetProperty (property, ref size, (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);

				return val;
			}
		}
		static void Listener (IntPtr userData, AudioSessionProperty prop, int size, IntPtr data)
		{
			ArrayList a = (ArrayList) listeners [prop];
			if (a == null){
				// Should never happen
				return;
			}

			foreach (PropertyListener pl in a){
				pl (prop, size, data);
			}
		}
示例#10
0
		public static void RemoveListener (AudioSessionProperty property, PropertyListener listener)
		{
			if (listener == null)
				throw new ArgumentNullException ("listener");

			ArrayList a = (ArrayList) listeners [property];
			if (a == null)
				return;
			a.Remove (listener);
			if (a.Count == 0)
				listeners [property] = null;
		}
示例#11
0
		static IntPtr GetIntPtr (AudioSessionProperty property)
		{
			unsafe {
				IntPtr val;
				int size = IntPtr.Size;
				int k = AudioSessionGetProperty (property, ref size, (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);
				
				return val;
			}
		}
示例#12
0
        static int GetInt(AudioSessionProperty property)
        {
            unsafe {
                int val  = 0;
                int size = 4;
                int k    = AudioSessionGetProperty(property, ref size, (IntPtr)(&val));
                if (k != 0)
                {
                    throw new AudioSessionException(k);
                }

                return(val);
            }
        }
示例#13
0
        static void Listener(IntPtr userData, AudioSessionProperty prop, int size, IntPtr data)
        {
            List <PropertyListener> a;

            if (!listeners.TryGetValue(prop, out a))
            {
                // Should never happen
                return;
            }

            foreach (PropertyListener pl in a)
            {
                pl(prop, size, data);
            }
        }
示例#14
0
		static void RemoveListenerEvent (AudioSessionProperty property, object handler)
		{
			if (strongListenerHash == null)
				return;

			PropertyListener listener;
			lock (strongListenerHash) {
				listener = (PropertyListener) strongListenerHash [handler]; 
				if (listener == null)
					return;

				strongListenerHash.Remove (handler);
			}

			RemoveListener (AudioSessionProperty.CurrentHardwareOutputVolume, listener);
		}
示例#15
0
        public static void RemoveListener(AudioSessionProperty property, PropertyListener listener)
        {
            if (listener == null)
            {
                throw new ArgumentNullException("listener");
            }

            List <PropertyListener> a;

            if (!listeners.TryGetValue(property, out a))
            {
                return;
            }
            a.Remove(listener);
            if (a.Count == 0)
            {
                listeners [property] = null;
            }
        }
示例#16
0
        static void RemoveListenerEvent(AudioSessionProperty property, object handler)
        {
            if (strongListenerHash == null)
            {
                return;
            }

            PropertyListener listener;

            lock (strongListenerHash) {
                if (!strongListenerHash.TryGetValue(handler, out listener))
                {
                    return;
                }

                strongListenerHash.Remove(handler);
            }

            RemoveListener(AudioSessionProperty.CurrentHardwareOutputVolume, listener);
        }
示例#17
0
        public void audioListener(AudioSessionProperty prop, int size, IntPtr data)
        {
            if (prop == AudioSessionProperty.AudioRouteChange) {

                var audioInputAvailable = AudioSession.AudioInputAvailable;

                if (unitIsRunning && !audioInputAvailable) {

                    rioUnit.Stop ();

                } else if (!unitIsRunning && audioInputAvailable) {

                    if (!unitCreated) {

                        SetupRemoteIO ();

                    }
                }
            }
        }
示例#18
0
		public static AudioSessionErrors AddListener (AudioSessionProperty property, PropertyListener listener)
		{
			if (listener == null)
				throw new ArgumentNullException ("listener");

			if (listeners == null)
				listeners = new Hashtable ();

			ArrayList a = (ArrayList) listeners [property];
			if (a == null)
				listeners [property] = a = new ArrayList ();

			a.Add (listener);

			if (a.Count == 1) {
				return AudioSessionAddPropertyListener (property, Listener, IntPtr.Zero);
			}

			return AudioSessionErrors.None;
		}
示例#19
0
        void RouteChangeListener(/*IntPtr 			inClientData,*/
							AudioSessionProperty	inID,
							int                  	inDataSize,
							IntPtr            		inData)
        {
            if (inID == AudioSessionProperty.AudioRouteChange) {

                NSDictionary routeDict = Runtime.GetNSObject (inData) as NSDictionary;

                NSNumber reasonValue = (NSNumber)routeDict.ValueForKey (new NSString ("OutputDeviceDidChange_Reason"));

                if ((AudioSessionRouteChangeReason)reasonValue.Int32Value ==
                    AudioSessionRouteChangeReason.OldDeviceUnavailable)
                {
                    this.pausePlaybackForPlayer (this.player);
                }
            }
        }
示例#20
0
 extern static OSStatus AudioSessionAddPropertyListener(AudioSessionProperty id, _PropertyListener inProc, IntPtr userData);
示例#21
0
 extern static OSStatus AudioSessionGetPropertySize(AudioSessionProperty id, out int size);
示例#22
0
 public AudioSessionPropertyEventArgs(AudioSessionProperty prop, int size, IntPtr data)
 {
     this.Property = prop;
     this.Size     = size;
     this.Data     = data;
 }
示例#23
0
 static void SetInt(AudioSessionProperty property, int val)
 {
     unsafe {
         int k = AudioSessionSetProperty (property, 4, (IntPtr) (&val));
         if (k != 0)
             throw new AudioSessionException (k);
     }
 }
示例#24
0
        static void Listener(IntPtr userData, AudioSessionProperty prop, int size, IntPtr data)
        {
            ArrayList a = (ArrayList) listeners [prop];
            if (a == null){
                // Should never happen
                return;
            }

            foreach (PropertyListener pl in a){
                pl (prop, size, data);
            }
        }
示例#25
0
        static double GetDouble(AudioSessionProperty property)
        {
            unsafe {
                double val = 0;
                int size = 8;
                int k = AudioSessionGetProperty (property, ref size, (IntPtr) (&val));
                if (k != 0)
                    throw new AudioSessionException (k);

                return val;
            }
        }
示例#26
0
 public void Listener(AudioSessionProperty prop, int size, IntPtr data)
 {
     cback (null, new AudioSessionRouteChangeEventArgs (data));
 }
示例#27
0
 public void Listener(AudioSessionProperty prop, int size, IntPtr data)
 {
     cback(null, new AudioSessionRouteChangeEventArgs(data));
 }
示例#28
0
 static extern int AudioSessionSetProperty(
     AudioSessionProperty inID,
     UInt32 inDataSize,
     ref OverrideAudioRouteType inData);
示例#29
0
 static extern OSStatus AudioSessionGetPropertySize(AudioSessionProperty id, out int size);
示例#30
0
 static extern OSStatus AudioSessionSetProperty(AudioSessionProperty id, int size, IntPtr data);
示例#31
0
		static IntPtr GetIntPtr (AudioSessionProperty property)
		{
			unsafe {
				IntPtr val;
				int size = IntPtr.Size;
				int k = AudioSessionGetProperty (property, ref size, (IntPtr) (&val));
				if (k != 0)
					throw new AudioSessionException (k);
				
				return val;
			}
		}
示例#32
0
        static int GetInt(AudioSessionProperty property)
        {
            unsafe {
                int val = 0;
                int size = 4;
                int k = AudioSessionGetProperty (property, ref size, (IntPtr) (&val));
                if (k != 0)
                    throw new AudioSessionException (k);

                return val;
            }
        }
示例#33
0
		extern static AudioSessionErrors AudioSessionAddPropertyListener(AudioSessionProperty id, _PropertyListener inProc, IntPtr userData);
示例#34
0
 static void SetDouble(AudioSessionProperty property, double val)
 {
     unsafe {
         int k = AudioSessionSetProperty (property, 8, (IntPtr) (&val));
         if (k != 0)
             throw new AudioSessionException (k);
     }
 }
示例#35
0
		static void AddListenerEvent (AudioSessionProperty property, object handler, PropertyListener listener)
		{
			if (strongListenerHash == null)
				Interlocked.CompareExchange (ref strongListenerHash, new Hashtable (), null);

			lock (strongListenerHash) {
				strongListenerHash [handler] = listener;
			}

			AddListener (property, listener);
		}
示例#36
0
 public AudioSessionPropertyEventArgs(AudioSessionProperty prop, int size, IntPtr data)
 {
     this.Property = prop;
     this.Size = size;
     this.Data = data;
 }
示例#37
0
		static void RemoveListenerEvent (AudioSessionProperty property, object handler)
		{
			if (strongListenerHash == null)
				return;

			PropertyListener listener;
			lock (strongListenerHash) {
				listener = (PropertyListener) strongListenerHash [handler]; 
				if (listener == null)
					return;

				strongListenerHash.Remove (handler);
			}

			RemoveListener (AudioSessionProperty.CurrentHardwareOutputVolume, listener);
		}
示例#38
0
 extern static OSStatus AudioSessionSetProperty(AudioSessionProperty id, int size, IntPtr data);
示例#39
0
        public static void AddListener(AudioSessionProperty property, PropertyListener listener)
        {
            if (listener == null)
                throw new ArgumentNullException ("listener");

            if (listeners == null)
                listeners = new Hashtable ();

            ArrayList a = (ArrayList) listeners [property];
            if (a == null)
                listeners [property] = a = new ArrayList ();

            a.Add (listener);

            if (a.Count == 1)
                AudioSessionAddPropertyListener (property, Listener, IntPtr.Zero);
        }
示例#40
0
        public static void RemoveListener(AudioSessionProperty property, PropertyListener listener)
        {
            if (listener == null)
                throw new ArgumentNullException ("listener");

            ArrayList a = (ArrayList) listeners [property];
            if (a == null)
                return;
            a.Remove (listener);
            if (a.Count == 0)
                listeners [property] = null;
        }
示例#41
0
 static extern OSStatus AudioSessionAddPropertyListener(AudioSessionProperty id, _PropertyListener inProc, IntPtr userData);
示例#42
0
		extern static OSStatus AudioSessionGetProperty(AudioSessionProperty id, ref int size, IntPtr data);
示例#43
0
        static extern int AudioSessionSetProperty(
		    AudioSessionProperty inID,
		    UInt32 inDataSize,
		    ref OverrideAudioRouteType inData);