Audio() protected method

Audio action.
Will be called when the device stack receives an invocation of the Audio action for the owning device. Must be implemented iff EnableActionAudio was called.
protected Audio ( IDvInvocation aInvocation, bool &aValue ) : void
aInvocation IDvInvocation Interface allowing querying of aspects of this particular action invocation.
aValue bool
return void
Example #1
0
        private static int DoAudio(IntPtr aPtr, IntPtr aInvocation)
        {
            GCHandle gch = GCHandle.FromIntPtr(aPtr);
            DvProviderAvOpenhomeOrgSender1 self = (DvProviderAvOpenhomeOrgSender1)gch.Target;
            DvInvocation invocation             = new DvInvocation(aInvocation);
            bool         value;

            try
            {
                invocation.ReadStart();
                invocation.ReadEnd();
                self.Audio(invocation, out value);
            }
            catch (ActionError e)
            {
                invocation.ReportActionError(e, "Audio");
                return(-1);
            }
            catch (PropertyUpdateError)
            {
                invocation.ReportError(501, String.Format("Invalid value for property {0}", new object[] { "Audio" }));
                return(-1);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("WARNING: unexpected exception {0} thrown by {1}", new object[] { e, "Audio" });
                System.Diagnostics.Debug.WriteLine("         Only ActionError or PropertyUpdateError should be thrown by actions");
                return(-1);
            }
            try
            {
                invocation.WriteStart();
                invocation.WriteBool("Value", value);
                invocation.WriteEnd();
            }
            catch (ActionError)
            {
                return(-1);
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine("WARNING: unexpected exception {0} thrown by {1}", new object[] { e, "Audio" });
                System.Diagnostics.Debug.WriteLine("       Only ActionError can be thrown by action response writer");
            }
            return(0);
        }
        private static int DoAudio(IntPtr aPtr, IntPtr aInvocation)
        {
            GCHandle gch = GCHandle.FromIntPtr(aPtr);
            DvProviderAvOpenhomeOrgSender1 self = (DvProviderAvOpenhomeOrgSender1)gch.Target;
            DvInvocation invocation             = new DvInvocation(aInvocation);
            bool         value;

            try
            {
                invocation.ReadStart();
                invocation.ReadEnd();
                self.Audio(invocation, out value);
            }
            catch (ActionError e)
            {
                invocation.ReportActionError(e, "Audio");
                return(-1);
            }
            catch (PropertyUpdateError)
            {
                invocation.ReportError(501, String.Format("Invalid value for property {0}", "Audio"));
                return(-1);
            }
            catch (Exception e)
            {
                Console.WriteLine("WARNING: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "Audio", e.TargetSite.Name);
                Console.WriteLine("         Only ActionError or PropertyUpdateError should be thrown by actions");
                return(-1);
            }
            try
            {
                invocation.WriteStart();
                invocation.WriteBool("Value", value);
                invocation.WriteEnd();
            }
            catch (ActionError)
            {
                return(-1);
            }
            catch (System.Exception e)
            {
                Console.WriteLine("ERROR: unexpected exception {0}(\"{1}\") thrown by {2} in {3}", e.GetType(), e.Message, "Audio", e.TargetSite.Name);
                Console.WriteLine("       Only ActionError can be thrown by action response writer");
            }
            return(0);
        }