Пример #1
0
        public void StopRecording()
        {
            bool wait_streams            = false;
            bool wait_controller_streams = false;
            bool wait_eye_streams        = false;
            bool wait_mouth_streams      = false;
            bool wait_voices             = false;
            bool wait_hearing            = false;
            bool wait_vision             = false;
            bool wait_anim = false;

            //STREAMS
            if (streamRecorder.isRecording)
            {
                streamRecorder.StopRecording();
                wait_streams = true;
            }

            //CONTROLLER STREAMS
            if (controllerRecorder.isRecording)
            {
                controllerRecorder.StopRecording();
                wait_controller_streams = true;
            }

            //EYE STREAMS
            if (eyeRecorder.isRecording)
            {
                eyeRecorder.StopRecording();
                wait_eye_streams = true;
            }

            //MOUTH STREAMS
            if (mouthRecorder.isRecording)
            {
                mouthRecorder.StopRecording();
                wait_mouth_streams = true;
            }

            //VOICES
            if (voiceRecorder.isRecording)
            {
                voiceRecorder.StopRecording();
                wait_voices = true;
            }

            //HEARING
            if (metagen_comp.hearingRecorder != null && metagen_comp.hearingRecorder.isRecording)
            {
                metagen_comp.hearingRecorder.StopRecording();
                wait_hearing = true;
            }

            //VISION
            if (visionRecorder.isRecording)
            {
                visionRecorder.StopRecording();
                wait_vision = true;
            }

            //BVH
            if (bvhRecorder.isRecording)
            {
                bvhRecorder.StopRecording();
            }

            try
            {
                if (animationRecorder.isRecording)
                {
                    animationRecorder.PreStopRecording();
                    wait_anim = true;
                }
            } catch (Exception e)
            {
                UniLog.Log(">w< animation stopping failed");
            }


            Task task = Task.Run(() =>
            {
                try
                {
                    //STREAMS
                    if (wait_streams)
                    {
                        streamRecorder.WaitForFinish();
                        wait_streams = false;
                    }

                    //CONTROLLER STREAMS
                    if (wait_controller_streams)
                    {
                        controllerRecorder.WaitForFinish();
                        wait_controller_streams = false;
                    }

                    //EYE STREAMS
                    if (wait_eye_streams)
                    {
                        eyeRecorder.WaitForFinish();
                        wait_eye_streams = false;
                    }

                    //MOUTH STREAMS
                    if (wait_mouth_streams)
                    {
                        mouthRecorder.WaitForFinish();
                        wait_mouth_streams = false;
                    }

                    //VOICES
                    if (wait_voices)
                    {
                        UniLog.Log("Waiting voices");
                        voiceRecorder.WaitForFinish();
                        wait_voices = false;
                        UniLog.Log("Waited voices");
                    }

                    //HEARING
                    if (wait_hearing)
                    {
                        metagen_comp.hearingRecorder.WaitForFinish();
                        wait_hearing = false;
                    }

                    //VISION
                    if (wait_vision)
                    {
                        visionRecorder.WaitForFinish();
                        wait_vision = false;
                    }

                    metagen.Util.MediaConverter.WaitForFinish();

                    //ANIMATION
                    if (wait_anim)
                    {
                        animationRecorder.StopRecording();
                        animationRecorder.WaitForFinish();
                        metagen_comp.World.RunSynchronously(() =>
                        {
                            metagen_comp.Slot.RemoveComponent(animationRecorder);
                        });
                        wait_anim = false;
                    }
                } catch (Exception e)
                {
                    UniLog.Log("OwO error in waiting task when stopped recording: " + e.Message);
                    UniLog.Log(e.StackTrace);
                } finally
                {
                    UniLog.Log("FINISHED STOPPING RECORDING");
                    metagen_comp.recording_state = OutputState.Stopped;
                    metagen_comp.dataManager.StopSection();
                }
            });

            //task.ContinueWith((Task t) =>
            //{
            //    UniLog.Log("FINISHED STOPPING RECORDING");
            //    this.recording_state = OutputState.Stopped;
            //    dataManager.StopSection();
            //});
            isRecording = false;
        }
Пример #2
0
 public void StopPlaying()
 {
     Task.Run(async() => await channel.ShutdownAsync());
     output_readers         = new Dictionary <RefID, IAsyncStreamReader <Bones> >();
     fake_proxies           = new Dictionary <RefID, List <Tuple <BodyNode, AvatarObjectSlot> > >();
     avatar_stream_channels = new Dictionary <RefID, Dictionary <BodyNode, Tuple <bool, bool, bool> > >();
     hands_are_tracked      = new Dictionary <RefID, bool>();
     proxy_slots            = new Dictionary <RefID, Dictionary <BodyNode, Slot> >();
     user_ids = new List <RefID>();
     avatarManager.avatar_template     = null;
     avatarManager.has_prepared_avatar = false;
     if (generateAnimation || generateBvh)
     {
         if (generateBvh)
         {
             bvhRecorder.StopRecording();
         }
         if (generateAnimation)
         {
             animationRecorder.PreStopRecording();
             metagen_comp.World.RunSynchronously(() =>
             {
                 animationRecorder.StopRecording();
             });
         }
         Task.Run(() =>
         {
             if (generateAnimation)
             {
                 animationRecorder.WaitForFinish();
             }
             metagen_comp.World.RunSynchronously(() =>
             {
                 UniLog.Log("AVATARS COUNT KEK");
                 UniLog.Log(avatars.Count);
                 if (generateAnimation)
                 {
                     metagen_comp.Slot.RemoveComponent(animationRecorder);
                 }
                 foreach (var item in avatars)
                 {
                     Slot slot = item.Value;
                     slot.Destroy();
                 }
                 avatars              = new Dictionary <RefID, Slot>();
                 finger_slots         = new Dictionary <RefID, Dictionary <BodyNode, Slot> >();
                 hand_posers          = new Dictionary <RefID, Dictionary <Chirality, HandPoser> >();
                 finger_compensations = new Dictionary <RefID, Dictionary <BodyNode, floatQ> >();
             });
         });
     }
     else
     {
         UniLog.Log("AVATARS COUNT KEK");
         UniLog.Log(avatars.Count);
         foreach (var item in avatars)
         {
             Slot slot = item.Value;
             slot.Destroy();
         }
         avatars              = new Dictionary <RefID, Slot>();
         finger_slots         = new Dictionary <RefID, Dictionary <BodyNode, Slot> >();
         hand_posers          = new Dictionary <RefID, Dictionary <Chirality, HandPoser> >();
         finger_compensations = new Dictionary <RefID, Dictionary <BodyNode, floatQ> >();
     }
     isPlaying = false;
 }