Ejemplo n.º 1
0
        private void Initialize()
        {
            if (this.initialized)
            {
                if (this.Logger.IsWarningEnabled)
                {
                    this.Logger.LogWarning("Already initialized.");
                }
                return;
            }
            if (this.Logger.IsDebugEnabled)
            {
                this.Logger.LogDebug("Initializing.");
            }
            #if USE_ONAUDIOFILTERREAD
            this.outBuffer        = new AudioSyncBuffer <float>(this.Logger, string.Empty, this.Logger.IsInfoEnabled);
            this.outputSampleRate = AudioSettings.outputSampleRate;
            Func <IAudioOut <float> > factory = () => this.outBuffer;
            #else
            Func <IAudioOut <float> > factory = () => new UnityAudioOut(this.GetComponent <AudioSource>(), this.Logger, string.Empty, this.Logger.IsInfoEnabled);
            #endif

            #if !UNITY_EDITOR && (UNITY_PS4 || UNITY_SHARLIN)
            this.audioOutput = new Photon.Voice.PlayStation.PlayStationAudioOut(this.PlayStationUserID, factory);
            #else
            this.audioOutput = factory();
            #endif
            this.initialized = true;
            if (this.Logger.IsDebugEnabled)
            {
                this.Logger.LogDebug("Initialized.");
            }
        }
Ejemplo n.º 2
0
        void ICanvas3DControl.OnLoaded()
        {
            try
            {
                this.Renderer = this.info.RenderFactory.Open(this.info.XwtRender, this, this, this.impl.FPS, this.impl.VideoSize);

                this.Audio = new AudioOut(48000, AudioFormat.Float32, ChannelsLayout.Stereo, 2);
                this.Mixer = new Mixer(this.Audio.SampleRate, this.Audio.Format, this.Audio.ChannelLayout);

                this.impl.OnLoaded(false);

                using (var lck = this.Renderer.GetDrawLock())
                {
                    this.impl.OnLoaded(true);
                }

                //this.Display.WaitBuffered();
                //    this.Audio?.Buffered.WaitOne(-1, false);



                //this.movie.p
            }
            catch (Exception e)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        void ICanvas3DControl.Unloading()
        {
            if (this.Renderer != null)
            {
                this.Renderer.Stop();
                this.Audio?.Stop();

                this.impl.Stop();


                this.impl.Unloading(false);

                this.Mixer?.Dispose();
                this.Mixer = null;
                this.Audio?.Dispose();
                this.Audio = null;

                using (var lck = this.Renderer.GetDrawLock())
                {
                    this.impl.Unloading(true);
                }
                this.Renderer.Dispose();
                this.Renderer = null;
            }
        }
Ejemplo n.º 4
0
        protected override void Awake()
        {
            base.Awake();
            Func <IAudioOut> factory = () => new AudioStreamPlayer(new VoiceLogger(this, "AudioStreamPlayer", this.LogLevel),
                                                                   new UnityAudioOut(this.GetComponent <AudioSource>()), "PhotonVoiceSpeaker:", this.Logger.IsInfoEnabled);

            #if !UNITY_EDITOR && UNITY_PS4
            this.audioOutput = new Photon.Voice.PS4.PS4AudioOut(PS4UserID, factory);
            #else
            this.audioOutput = factory();
            #endif
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the settings for the playback behaviour in case of delays.
 /// </summary>
 /// <param name="low">In milliseconds, audio player tries to keep the playback delay above this value.</param>
 /// <param name="high">In milliseconds, audio player tries to keep the playback below above this value.</param>
 /// <param name="max">In milliseconds, audio player guarantees that the playback delay never exceeds this value.</param>
 /// <returns>If a change has been made.</returns>
 public bool SetPlaybackDelaySettings(int low, int high, int max)
 {
     if (low >= 0 && low < high)
     {
         if (this.playbackDelaySettings.MaxDelaySoft != high ||
             this.playbackDelaySettings.MinDelaySoft != low ||
             this.playbackDelaySettings.MaxDelayHard != max)
         {
             if (max < high)
             {
                 max = high;
             }
             this.playbackDelaySettings.MaxDelaySoft = high;
             this.playbackDelaySettings.MinDelaySoft = low;
             this.playbackDelaySettings.MaxDelayHard = max;
             bool wasPlaying = this.IsPlaying;
             if (this.IsPlaying)
             {
                 this.StopPlaying();
             }
             bool wasInitialized = this.initialized;
             if (this.initialized)
             {
                 this.initialized = false;
                 this.audioOutput = null;
             }
             if (wasInitialized)
             {
                 this.Initialize();
                 if (wasPlaying)
                 {
                     this.StartPlaying();
                 }
             }
             return(true);
         }
     }
     else if (this.Logger.IsErrorEnabled)
     {
         this.Logger.LogError("Wrong playback delay config values, make sure 0 <= Low < High, low={0}, high={1}, max={2}", low, high, max);
     }
     return(false);
 }
Ejemplo n.º 6
0
        protected override void Awake()
        {
            base.Awake();
            #if USE_ONAUDIOFILTERREAD
            this.outBuffer        = new AudioSyncBuffer <float>(this.Logger, string.Empty, this.Logger.IsInfoEnabled);
            this.outputSampleRate = AudioSettings.outputSampleRate;
            Func <IAudioOut <float> > factory = () => this.outBuffer;
            #else
            Func <IAudioOut <float> > factory = () => new UnityAudioOut(this.GetComponent <AudioSource>(), this.Logger, string.Empty, this.Logger.IsInfoEnabled);
            #endif

            #if !UNITY_EDITOR && UNITY_PS4
            this.audioOutput = new Photon.Voice.PS4.PS4AudioOut(PS4UserID, factory);
            #else
            this.audioOutput = factory();
            #endif
            this.initialized = true;
            if (!this.PlaybackOnlyWhenEnabled && this.IsLinked)
            {
                this.StartPlaying();
            }
        }
Ejemplo n.º 7
0
        public Player(MainWindow mainwindow, string filename, long timebase)
        {
            try
            {
                this.timebase = timebase;
                this.renderer = mainwindow.Renderer;
                this.audioout = mainwindow.Audio;
                this.mixer    = mainwindow.Mixer;
                this.player   = BaseLib.Media.MoviePlayer.Open(() => { }, filename);

                try
                {
                    if (player.VideoStreams.Length > 0)
                    {
                        this.video = player.open_video(0, frameready);
                    }
                    if (player.AudioStreams.Length > 0)
                    {
                        this.audio       = player.open_audio(0, mainwindow.Mixer, audioready);
                        this.audiobuffer = new FifoStream(mainwindow.Audio.SampleSize * mainwindow.Audio.SampleRate * 3);
                        this.mixer.Register(this.audiobuffer, this.audioout.Channels, false);
                    }
                    this.player.start(0, timebase);
                }
                catch
                {
                    Dispose(true);
                    GC.SuppressFinalize(this);
                    throw;
                }
            }
            catch
            {
                GC.SuppressFinalize(this);
                throw;
            }
        }
Ejemplo n.º 8
0
    private IAudioOut speakersOut; // used when headphones not connected

    public PS4AudioOut(Func <IAudioOut> speakersOutFactory)
    {
        this.speakersOut = speakersOutFactory();
    }
Ejemplo n.º 9
0
        public ResultCode OpenAudioOut(ServiceCtx context, out string outputDeviceName, out AudioOutputConfiguration outputConfiguration, out IAudioOut obj, string inputDeviceName, ref AudioInputConfiguration parameter, ulong appletResourceUserId, uint processHandle, float volume)
        {
            var memoryManager = context.Process.HandleTable.GetKProcess((int)processHandle).CpuMemory;

            ResultCode result = (ResultCode)_impl.OpenAudioOut(out outputDeviceName, out outputConfiguration, out AudioOutputSystem outSystem, memoryManager, inputDeviceName, SampleFormat.PcmInt16, ref parameter, appletResourceUserId, processHandle, volume);

            if (result == ResultCode.Success)
            {
                obj = new AudioOut.AudioOut(outSystem, context.Device.System.KernelContext, processHandle);
            }
            else
            {
                obj = null;
            }

            return(result);
        }
Ejemplo n.º 10
0
 public AudioOutServer(IAudioOut impl)
 {
     _impl = impl;
 }