Beispiel #1
0
        public AudioInPusher(AudioSessionParameters sessParam, Voice.ILogger logger)
        {
            var t = new Thread(() =>
            {
                try
                {
                    var handle = Photon_Audio_In_CreatePusher(instanceCnt, nativePushCallback, (int)sessParam.Category, (int)sessParam.Mode, sessParam.CategotyOptionsToInt());
                    lock (instancePerHandle)
                    {
                        this.handle     = handle;
                        this.instanceID = instanceCnt;
                        instancePerHandle.Add(instanceCnt++, this);
                    }
                }
                catch (Exception e)
                {
                    Error = e.ToString();
                    if (Error == null) // should never happen but since Error used as validity flag, make sure that it's not null
                    {
                        Error = "Exception in AudioInPusher constructor";
                    }
                    logger.LogError("[PV] AudioInPusher: " + Error);
                }
            });

            t.Name = "IOS AudioInPusher ctr";
            t.Start();
        }
        public AudioInPusher(AudioSessionParameters sessParam, ILogger logger)
        {
            // initialization in a separate thread to avoid 0.5 - 1 sec. pauses in main thread execution
            var t = new Thread(() =>
            {
                lock (instancePerHandle) // prevent concurrent initialization
                {
                    try
                    {
                        var handle      = Photon_Audio_In_CreatePusher(instanceCnt, nativePushCallback, (int)sessParam.Category, (int)sessParam.Mode, sessParam.CategoryOptionsToInt());
                        this.handle     = handle;
                        this.instanceID = instanceCnt;
                        instancePerHandle.Add(instanceCnt++, this);
                    }
                    catch (Exception e)
                    {
                        Error = e.ToString();
                        if (Error == null) // should never happen but since Error used as validity flag, make sure that it's not null
                        {
                            Error = "Exception in AudioInPusher constructor";
                        }
                        logger.LogError("[PV] AudioInPusher: " + Error);
                    }
                    finally
                    {
                        initializationFinished = true;
                    }
                }
            });

            t.Name = "IOS AudioInPusher ctr";
            t.Start();
        }
        public AudioInReader(AudioSessionParameters sessParam, ILogger logger)
        {
            var t = new Thread(() =>
            {
                try
                {
                    var audioIn = Photon_Audio_In_CreateReader((int)sessParam.Category, (int)sessParam.Mode, sessParam.CategoryOptionsToInt());
                    lock (this)
                    {
                        this.audioIn = audioIn;
                    }
                }
                catch (Exception e)
                {
                    Error = e.ToString();
                    if (Error == null) // should never happen but since Error used as validity flag, make sure that it's not null
                    {
                        Error = "Exception in AudioInReader constructor";
                    }
                    logger.LogError("[PV] AudioInReader: " + Error);
                }
            });

            t.Name = "IOS AudioInPusher ctr";
            t.Start();
        }
        public AudioInReader(AudioSessionParameters sessParam, ILogger logger)
        {
            // initialization in a separate thread to avoid 0.5 - 1 sec. pauses in main thread execution
            var t = new Thread(() =>
            {
                lock (this)
                {
                    try
                    {
                        var audioIn = Photon_Audio_In_CreateReader((int)sessParam.Category, (int)sessParam.Mode, sessParam.CategoryOptionsToInt());
                        lock (this)
                        {
                            this.audioIn = audioIn;
                        }
                    }
                    catch (Exception e)
                    {
                        Error = e.ToString();
                        if (Error == null) // should never happen but since Error used as validity flag, make sure that it's not null
                        {
                            Error = "Exception in AudioInReader constructor";
                        }
                        logger.LogError("[PV] AudioInReader: " + Error);
                    }
                    finally
                    {
                        initializationFinished = true;
                    }
                }
            });

            t.Name = "IOS AudioInReader ctr";
            t.Start();
        }