Esempio n. 1
0
        /// <summary>
        /// Releases the resources used by the <see cref="AudioPlayback"/> object.
        /// </summary>
        /// <param name="disposing">
        /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
        /// </param>
        /// <since_tizen> 3 </since_tizen>
        protected virtual void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (_handle != IntPtr.Zero)
            {
                if (_state != AudioIOState.Idle)
                {
                    try
                    {
                        Unprepare();
                    }
                    catch (Exception)
                    {
                    }
                }

                AudioOutput.Destroy(_handle);
                _handle     = IntPtr.Zero;
                _isDisposed = true;
            }
        }
Esempio n. 2
0
 public void StartInteracting()
 {
     foreach (var item in metagen_comp.userMetaData)
     {
         User         user     = item.Key;
         UserMetadata metadata = item.Value;
         if (!(metadata.isRecording || metagen_comp.record_everyone))
         {
             continue;
         }
         UniLog.Log("Starting voice interaction for user " + user.UserName);
         RefID user_id = user.ReferenceID;
         current_users_ids.Add(user_id.ToString());
         AvatarAudioOutputManager comp = user.Root.Slot.GetComponentInChildren <AvatarAudioOutputManager>();
         AudioOutput audio_output      = comp.AudioOutput.Target;
         audio_outputs[user_id] = audio_output;
         isRecording[user_id]   = false;
         if (audio_outputs[user_id] == null)
         {
             UniLog.Log("OwO: Audio output for user " + user_id.ToString() + " is null!");
         }
         else
         {
             UniLog.Log("Sample rate");
             UniLog.Log(metagen_comp.Engine.AudioSystem.Connector.SampleRate.ToString());
         }
     }
     isInteracting = true;
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the size allocated for the audio output buffer.
        /// </summary>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <since_tizen> 3 </since_tizen>
        public int GetBufferSize()
        {
            AudioOutput.GetBufferSize(_handle, out var size)
            .ThrowIfFailed("Failed to get buffer size.");

            return(size);
        }
Esempio n. 4
0
        /// <summary>
        /// Prepares the AudioPlayback.
        /// </summary>
        /// <remarks>
        /// This must be called before <see cref="Write(byte[])"/>.
        /// </remarks>
        /// <exception cref="InvalidOperationException">
        ///     Operation failed due to an internal error.<br/>
        ///     -or-<br/>
        ///     The current state is not <see cref="AudioIOState.Idle"/>.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <seealso cref="Unprepare"/>
        /// <since_tizen> 3 </since_tizen>
        public void Prepare()
        {
            ValidateState(AudioIOState.Idle);

            AudioIOUtil.ThrowIfError(AudioOutput.Prepare(_handle),
                                     $"Failed to prepare the {nameof(AudioPlayback)}");
        }
Esempio n. 5
0
        /// <summary>
        /// Unprepares the AudioPlayback.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        ///     Operation failed due to an internal error.<br/>
        ///     -or-<br/>
        ///     The current state is <see cref="AudioIOState.Idle"/>.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <seealso cref="Prepare"/>
        /// <since_tizen> 3 </since_tizen>
        public void Unprepare()
        {
            ValidateState(AudioIOState.Running, AudioIOState.Paused);

            AudioIOUtil.ThrowIfError(AudioOutput.Unprepare(_handle),
                                     $"Failed to unprepare the {nameof(AudioPlayback)}");
        }
Esempio n. 6
0
 public void StartRecording()
 {
     current_users_ids = new List <string>();
     saving_folder     = metagen_comp.dataManager.saving_folder;
     foreach (var item in metagen_comp.userMetaData)
     {
         User         user     = item.Key;
         UserMetadata metadata = item.Value;
         if (!metadata.isRecording || (metagen_comp.LocalUser == user && !metagen_comp.record_local_user))
         {
             continue;
         }
         RefID user_id = user.ReferenceID;
         current_users_ids.Add(user_id.ToString());
         AvatarAudioOutputManager comp = user.Root.Slot.GetComponentInChildren <AvatarAudioOutputManager>();
         AudioOutput audio_output      = comp.AudioOutput.Target;
         audio_outputs[user_id] = audio_output;
         if (audio_outputs[user_id] == null)
         {
             UniLog.Log("OwO: Audio output for user " + user_id.ToString() + " is null!");
         }
         else
         {
             UniLog.Log("Sample rate");
             UniLog.Log(metagen_comp.Engine.AudioSystem.Connector.SampleRate.ToString());
             audio_recorders[user_id] = new AudioRecorder(saving_folder + "/" + user_id.ToString() + "_voice_tmp", metagen_comp.Engine.AudioSystem.BufferSize, 1, metagen_comp.Engine.AudioSystem.SampleRate, 1);
             audio_recorders[user_id].StartWriting();
         }
     }
     isRecording = true;
 }
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            if (VlcContext.InteropManager != null &&
                VlcContext.InteropManager.MediaPlayerInterops != null &&
                VlcContext.InteropManager.MediaPlayerInterops.AudioInterops != null &&
                VlcContext.InteropManager.MediaPlayerInterops.AudioInterops.NewOutputListInstance.IsAvailable &&
                VlcContext.InteropManager.MediaPlayerInterops.AudioInterops.ReleaseOutputList.IsAvailable &&
                VlcContext.HandleManager.LibVlcHandle != IntPtr.Zero)
            {
                var outputDeviceListInstance = VlcContext.InteropManager.MediaPlayerInterops.AudioInterops.NewOutputListInstance.Invoke(VlcContext.HandleManager.LibVlcHandle);

                if (outputDeviceListInstance != IntPtr.Zero)
                {
#if SILVERLIGHT
                    var audioOutput = new AudioOutput();
                    Marshal.PtrToStructure(outputDeviceListInstance, audioOutput);
#else
                    var audioOutput = (AudioOutput)Marshal.PtrToStructure(outputDeviceListInstance, typeof(AudioOutput));
#endif
                    var lst = new VlcAudioOutputDevice(audioOutput);

                    yield return(lst);

                    while (lst.Next != null)
                    {
                        lst = lst.Next;
                        yield return(lst);
                    }
                    VlcContext.InteropManager.MediaPlayerInterops.AudioInterops.ReleaseOutputList.Invoke(outputDeviceListInstance);
                }
            }
        }
Esempio n. 8
0
        static void StartAudioOutput(string pluginPath, string waveFilePath)
        {
            try
            {
                var hostCmdStub      = new HostCommandStub();
                VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub);

                // add custom data to the context
                ctx.Set("PluginPath", pluginPath);
                ctx.Set("HostCmdStub", hostCmdStub);

                // actually open the plugin itself
                ctx.PluginCommandStub.Open();

                var audioOut = new AudioOutput(
                    new List <IVstPluginCommandStub>()
                {
                    ctx.PluginCommandStub
                },
                    waveFilePath);
                Thread.Sleep(100);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
Esempio n. 9
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Controller.
            Controller controller = new Controller();

            // GUI.
            EnterForm enterForm  = new EnterForm();
            ChatForm  chatWindow = new ChatForm();
            ErrorForm errorForm  = new ErrorForm();

            controller.EnterForm          = enterForm;
            controller.UserList           = chatWindow;
            controller.TextMessageInput   = chatWindow;
            controller.TextMessageOutput  = chatWindow;
            controller.UserJoinHandler    = chatWindow;
            controller.UserLeaveHandler   = chatWindow;
            controller.ErrorMessageOutput = errorForm;

            enterForm.ConnectionController   = controller;
            chatWindow.TextMessageController = controller;
            chatWindow.ConnectionController  = controller;
            chatWindow.SoundInputController  = controller;
            chatWindow.SoundOutputController = controller;

            // Sound.
            AudioOutput <string> audioOutput     = new AudioOutput <string>();
            MicrophoneInput      microphoneInput = new MicrophoneInput();

            controller.SoundOutput = audioOutput;
            controller.SoundInput  = microphoneInput;

            // Networking.
            ServiceConnector serviceConnector = new ServiceConnector();

            controller.TextSender        = serviceConnector;
            controller.SoundSender       = serviceConnector;
            controller.ConnectionHandler = serviceConnector;

            serviceConnector.UserController        = controller;
            serviceConnector.SoundController       = controller;
            serviceConnector.TextMessageController = controller;
            serviceConnector.DisconnectController  = controller;

            // Text processing.
            MessageTransformer  messageTransformer  = new MessageTransformer();
            NicknameTransformer nicknameTransformer = new NicknameTransformer();
            MessageVerifier     messageVerifier     = new MessageVerifier(possibleLength: PossibleLength);
            NicknameVerifier    nicknameVerifier    = new NicknameVerifier();

            controller.MessageTransformer  = messageTransformer;
            controller.NicknameTransformer = nicknameTransformer;
            controller.MessageVerifier     = messageVerifier;
            controller.NicknameVerifier    = nicknameVerifier;

            Application.Run(new MessengerAppContext(enterForm, chatWindow, errorForm));
        }
Esempio n. 10
0
        /// <summary>
        /// Drains the buffered audio data from the output stream.
        /// It blocks the calling thread until the drain of the stream buffer is complete, for example, at the end of playback.
        /// </summary>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The current state is <see cref="AudioIOState.Idle"/>.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void Drain()
        {
            ValidateState(AudioIOState.Running, AudioIOState.Paused);

            var ret = AudioOutput.Drain(_handle);

            MultimediaDebug.AssertNoError((int)ret);
        }
 public void SetDeviceList(List <string> List)
 {
     AudioOutput.Clear();
     foreach (string device in List)
     {
         AudioOutput.Add(device);
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Flushes and discards the buffered audio data from the output stream.
        /// </summary>
        /// <exception cref="InvalidOperationException">The current state is <see cref="AudioIOState.Idle"/>.</exception>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void Flush()
        {
            ValidateState(AudioIOState.Running, AudioIOState.Paused);

            int ret = AudioOutput.Flush(_handle);

            MultimediaDebug.AssertNoError(ret);
        }
Esempio n. 13
0
 /// <summary>
 /// Play sfx
 /// </summary>
 /// <param name="clip"></param>
 /// <param name="output"></param>
 public void PlaySFX(AudioClip clip, AudioOutput output = AudioOutput.Sfx)
 {
     if (clip == null)
     {
         return;
     }
     StartCoroutine(SFXManager(clip, output));
 }
Esempio n. 14
0
        /// <summary>
        ///     Configures an explicit audio output device. If the module paramater is NULL,
        ///     audio output will be moved to the device specified by the device identifier string immediately.
        ///     This is the recommended usage. A list of adequate potential device strings can be obtained with
        ///     <see cref="EnumAudioDeviceList" />.
        ///     However passing NULL is supported in LibVLC version 2.2.0 and later only; in earlier versions, this function would
        ///     have no effects when the module parameter was NULL.
        ///     If the module parameter is not NULL, the device parameter of the corresponding audio output, if it exists, will be
        ///     set to the specified string.
        ///     Note that some audio output modules do not have such a parameter (notably MMDevice and PulseAudio).
        ///     A list of adequate potential device strings can be obtained with <see cref="GetAudioDeviceList" />.
        /// </summary>
        public void SetAudioDevice(AudioOutput audioOutput, AudioDevice audioDevice)
        {
            if (VlcMediaPlayer == null)
            {
                throw new InvalidOperationException("VlcMediaPlayer doesn't have initialize.");
            }

            VlcMediaPlayer.SetAudioDevice(audioOutput, audioDevice);
        }
Esempio n. 15
0
        /// <summary>
        ///     Selects an audio output module.
        ///     Any change will take be effect only after playback is stopped and restarted. Audio output cannot be changed while
        ///     playing.
        /// </summary>
        /// <param name="audioOutput"></param>
        /// <returns></returns>
        public bool SetAudioOutput(AudioOutput audioOutput)
        {
            if (VlcMediaPlayer == null)
            {
                throw new InvalidOperationException("VlcMediaPlayer doesn't have initialize.");
            }

            return(VlcMediaPlayer.SetAudioOutput(audioOutput));
        }
Esempio n. 16
0
 /// <summary>
 /// VlcAudioOutput constrctor
 /// </summary>
 /// <param name="audioOutput">The libvlc audio output structure</param>
 internal VlcAudioOutputDevice(AudioOutput audioOutput)
 {
     Name        = IntPtrExtensions.ToStringAnsi(audioOutput.name);
     Description = IntPtrExtensions.ToStringAnsi(audioOutput.description);
     if (audioOutput.next != IntPtr.Zero)
     {
         var next = (AudioOutput)Marshal.PtrToStructure(audioOutput.next, typeof(AudioOutput));
         Next = new VlcAudioOutputDevice(next);
     }
 }
Esempio n. 17
0
        private void RegisterStreamCallback()
        {
            _streamCallback = (IntPtr handle, uint bytes, IntPtr _) =>
            {
                BufferAvailable?.Invoke(this, new AudioPlaybackBufferAvailableEventArgs((int)bytes));
            };

            AudioOutput.SetStreamChangedCallback(_handle, _streamCallback, IntPtr.Zero)
            .ThrowIfFailed("Failed to set stream changed callback.");
        }
Esempio n. 18
0
        /// <summary>
        /// Resumes feeding of the audio data to the device.
        /// </summary>
        /// <remarks>It has no effect if the current state is <see cref="AudioIOState.Running"/>.</remarks>
        /// <exception cref="InvalidOperationException">
        ///     The current state is <see cref="AudioIOState.Idle"/>.<br/>
        ///     -or-<br/>
        ///     The method is called in an event handler.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <seealso cref="Pause"/>
        /// <since_tizen> 3 </since_tizen>
        public void Resume()
        {
            if (_state == AudioIOState.Running)
            {
                return;
            }
            ValidateState(AudioIOState.Paused);

            AudioIOUtil.ThrowIfError(AudioOutput.Resume(_handle));
        }
Esempio n. 19
0
        /// <summary>
        /// Resumes feeding of the audio data to the device.
        /// </summary>
        /// <remarks>It has no effect if the current state is <see cref="AudioIOState.Running"/>.</remarks>
        /// <exception cref="InvalidOperationException">
        ///     The current state is <see cref="AudioIOState.Idle"/>.<br/>
        ///     -or-<br/>
        ///     The method is called in an event handler.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The AudioPlayback has already been disposed of.</exception>
        /// <seealso cref="Pause"/>
        /// <since_tizen> 3 </since_tizen>
        public void Resume()
        {
            if (_state == AudioIOState.Running)
            {
                return;
            }
            ValidateState(AudioIOState.Paused);

            AudioOutput.Resume(_handle).ThrowIfFailed("Failed to resume.");
        }
Esempio n. 20
0
        /// <summary>
        /// Applies the sound stream information to the AudioPlayback.
        /// </summary>
        /// <param name="streamPolicy">The <see cref="AudioStreamPolicy"/> to apply for the AudioPlayback.</param>
        /// <exception cref="ArgumentNullException"><paramref name="streamPolicy"/> is null.</exception>
        /// <exception cref="ObjectDisposedException">
        ///     <paramref name="streamPolicy"/> has already been disposed of.<br/>
        ///     -or-<br/>
        ///     The AudioPlayback has already been disposed of.
        /// </exception>
        /// <exception cref="NotSupportedException"><paramref name="streamPolicy"/> is not supported.</exception>
        /// <exception cref="ArgumentException">Not able to retrieve information from <paramref name="streamPolicy"/>.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void ApplyStreamPolicy(AudioStreamPolicy streamPolicy)
        {
            if (streamPolicy == null)
            {
                throw new ArgumentNullException(nameof(streamPolicy));
            }

            ValidateNotDisposed();

            AudioIOUtil.ThrowIfError(AudioOutput.SetStreamInfo(_handle, streamPolicy.Handle));
        }
Esempio n. 21
0
        private void RegisterStreamCallback()
        {
            _streamCallback = (IntPtr handle, uint bytes, IntPtr _) =>
            {
                BufferAvailable?.Invoke(this, new AudioPlaybackBufferAvailableEventArgs((int)bytes));
            };

            AudioIOUtil.ThrowIfError(
                AudioOutput.SetStreamChangedCallback(_handle, _streamCallback, IntPtr.Zero),
                $"Failed to create {nameof(AudioPlayback)}");
        }
Esempio n. 22
0
        /// <summary>
        /// Applies the sound stream information to the AudioPlayback.
        /// </summary>
        /// <param name="streamPolicy">The <see cref="AudioStreamPolicy"/> to apply for the AudioPlayback.</param>
        /// <exception cref="ArgumentNullException"><paramref name="streamPolicy"/> is null.</exception>
        /// <exception cref="ObjectDisposedException">
        ///     <paramref name="streamPolicy"/> has already been disposed of.<br/>
        ///     -or-<br/>
        ///     The AudioPlayback has already been disposed of.
        /// </exception>
        /// <exception cref="NotSupportedException"><paramref name="streamPolicy"/> is not supported.</exception>
        /// <exception cref="ArgumentException">Not able to retrieve information from <paramref name="streamPolicy"/>.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void ApplyStreamPolicy(AudioStreamPolicy streamPolicy)
        {
            if (streamPolicy == null)
            {
                throw new ArgumentNullException(nameof(streamPolicy));
            }

            ValidateNotDisposed();

            AudioOutput.SetStreamInfo(_handle, streamPolicy.Handle)
            .ThrowIfFailed("Failed to apply stream policy.");
        }
Esempio n. 23
0
        public MainWindow()
            : base("MD", 640, 480)
        {
            this.WindowState = WindowState.Maximized;

            // Client area
            VariableContainer clientarea = new VariableContainer();

            // Menu items
            MenuItem[] menuitems = new MenuItem[]
            {
                MenuItem.Create("File", new MenuItem[]
                {
                    MenuItem.Create("Import", delegate
                    {
                        using(var fd = new WinForms.OpenFileDialog())
                        {
                            fd.Filter = "MP3 Files |*.mp3";
                            if (fd.ShowDialog() == WinForms.DialogResult.OK)
                            {
                                string file = fd.FileName;
                                AudioContext ac = new AudioContext();
                                MemoryAudioSource mas = new MP3AudioFeed(file).Copy(4096, 4096 * 100);

                                SpectrogramView sp = new SpectrogramView(mas);
                                clientarea.Client = sp;

                                AudioOutput ao = new AudioOutput(mas.Play);
                                ao.Play();
                            }
                            else
                            {
                                return;
                            }
                        }
                    }),
                    MenuItem.Create("Exit", delegate
                    {
                        this.Close();
                    })
                })
            };

            // Menu and splitter
            Menu menu = new Menu(menuitems);
            SplitContainer sc = new SplitContainer(Axis.Vertical, menu.WithBorder(0.0, 0.0, 0.0, 1.0), clientarea);
            sc.NearSize = 30.0;

            // Main layer container
            LayerContainer lc = new LayerContainer(sc);

            this.Control = lc;
        }
Esempio n. 24
0
 void Awake()
 {
     if (manager == null)
     {
         DontDestroyOnLoad(gameObject);
         manager = this;
     }
     else if (manager != this)
     {
         Destroy(gameObject);
     }
 }
        public static void CreateMediaPlayerWithUnityAudioEditor()
        {
            GameObject go = new GameObject("MediaPlayer");

            go.AddComponent <MediaPlayer>();
            go.AddComponent <AudioSource>();
            AudioOutput ao = go.AddComponent <AudioOutput>();

            // Move the AudioOutput component above the AudioSource so that it acts as the audio generator
            UnityEditorInternal.ComponentUtility.MoveComponentUp(ao);
            Selection.activeGameObject = go;
        }
Esempio n. 26
0
        private void RegisterStateChangedCallback()
        {
            _stateChangedCallback = (IntPtr handle, int previous, int current, bool byPolicy, IntPtr _) =>
            {
                _state = (AudioIOState)current;

                StateChanged?.Invoke(this,
                                     new AudioIOStateChangedEventArgs((AudioIOState)previous, _state, byPolicy));
            };

            AudioOutput.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero)
            .ThrowIfFailed("Failed to set state changed callback.");
        }
Esempio n. 27
0
        private void RegisterStateChangedCallback()
        {
            _stateChangedCallback = (IntPtr handle, int previous, int current, bool byPolicy, IntPtr _) =>
            {
                _state = (AudioIOState)current;

                StateChanged?.Invoke(this,
                                     new AudioIOStateChangedEventArgs((AudioIOState)previous, _state, byPolicy));
            };

            AudioIOUtil.ThrowIfError(
                AudioOutput.SetStateChangedCallback(_handle, _stateChangedCallback, IntPtr.Zero),
                $"Failed to create {nameof(AudioPlayback)}");
        }
Esempio n. 28
0
        internal void Update(double deltaTime)
        {
            if (_fade < _fadeTime && _fadeTime > 0)
            {
                _fade += deltaTime;

                var volume = (float)MathHelper.Clamp(_fade / _fadeTime, 0, 1);

                if (_playing != null)
                {
                    _playing.Volume = (1 - volume) * _volume;
                }

                if (_next != null)
                {
                    _next.Volume = volume * _volume;
                }
            }
            else
            {
                if (_playing != null)
                {
                    _playing.Volume = _volume;
                }

                if (_next != null)
                {
                    _next.Volume = _volume;
                }

                if (_fadeTime > 0)
                {
                    _fade     = 0;
                    _fadeTime = 0;

                    _playing?.Dispose();
                    _currentSong?.Dispose();

                    if (_next != null)
                    {
                        _playing     = _next;
                        _currentSong = _nextSong;

                        _nextSong = null;
                        _next     = null;
                    }
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// VlcAudioOutput constrctor
        /// </summary>
        /// <param name="audioOutput">The libvlc audio output structure</param>
        internal VlcAudioOutputDevice(AudioOutput audioOutput)
        {
            Name        = IntPtrExtensions.ToStringAnsi(audioOutput.name);
            Description = IntPtrExtensions.ToStringAnsi(audioOutput.description);
            if (audioOutput.next != IntPtr.Zero)
            {
#if SILVERLIGHT
                var next = new AudioOutput();
                Marshal.PtrToStructure(audioOutput.next, next);
#else
                var next = (AudioOutput)Marshal.PtrToStructure(audioOutput.next, typeof(AudioOutput));
#endif
                Next = new VlcAudioOutputDevice(next);
            }
        }
Esempio n. 30
0
        private void StopInternal()
        {
            _nextSong?.Dispose();
            _currentSong?.Dispose();
            _next?.Dispose();
            _playing?.Dispose();

            _fade     = 0;
            _fadeTime = 0;

            _playing     = null;
            _next        = null;
            _currentSong = null;
            _nextSong    = null;
        }
        /// <summary>
        /// VlcAudioOutput constrctor
        /// </summary>
        /// <param name="audioOutput">The libvlc audio output structure</param>
        internal VlcAudioOutputDevice(AudioOutput audioOutput)
        {
            Name = IntPtrExtensions.ToStringAnsi(audioOutput.name);
            Description = IntPtrExtensions.ToStringAnsi(audioOutput.description);
            if (audioOutput.next != IntPtr.Zero)
            {
#if SILVERLIGHT
                var next = new AudioOutput();
                Marshal.PtrToStructure(audioOutput.next, next);
#else
                var next = (AudioOutput)Marshal.PtrToStructure(audioOutput.next, typeof(AudioOutput));
#endif
                Next = new VlcAudioOutputDevice(next);
            }
        }
Esempio n. 32
0
        private void lstAudioDevices_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lstAudioDevices.SelectedIndex == -1)
            {
                chkAcourateAsioVolume.IsChecked = false;
                chkAcourateAsioVolume.IsEnabled = false;
                sldrDeviceLatency.IsEnabled     = false;
                return;
            }

            currentOutput = (AudioOutput)lstAudioDevices.SelectedItem;

            if (currentOutput.DeviceType == AudioOutputs.AudioDeviceType.Asio)
            {
                sldrDeviceLatency.IsEnabled = false;
                sldrDeviceLatency.Value     = 25;
                lblChosenLatency.Content    = "Not Applicable";
            }
            else
            {
                if (currentOutput.ChosenLatency > 0)
                {
                    sldrDeviceLatency.Value = currentOutput.ChosenLatency;
                }
                else
                {
                    sldrDeviceLatency.Value = 100;
                }

                sldrDeviceLatency.IsEnabled = true;
            }

            SaveSelectedDeviceToSettings();
            OnRaiseSelectedOutputChangedEvent(new SelectedOutputChangedEventArgs(currentOutput));

            if (IsAcourateAsioVolumeAllowed())
            {
                chkAcourateAsioVolume.IsEnabled = true;
            }
            else
            {
                chkAcourateAsioVolume.IsChecked = false;
                chkAcourateAsioVolume.IsEnabled = false;
            }
        }
        public async Task InitDatabase(string name)
        {
            //
            // Check if the database is already exist
            //
            bool dbexist = await CheckDbAsync(name);

            //
            // Open the database, creating the database if it not already exist
            //
            Dbconnection = new SQLiteAsyncConnection(name);

            //
            // If the database is new create tables
            //
            if (!dbexist)
            {
                await Dbconnection.CreateTableAsync<File>();
                await Dbconnection.CreateTableAsync<Directory>();
                await Dbconnection.CreateTableAsync<Album>();
                await Dbconnection.CreateTableAsync<Artist>();
                await Dbconnection.CreateTableAsync<Genre>();
                await Dbconnection.CreateTableAsync<CurrentPlaylist>();
                await Dbconnection.CreateTableAsync<PlaylistFile>();
                await Dbconnection.CreateTableAsync<Playlist>();
                await Dbconnection.CreateTableAsync<AudioOutput>();

                AudioOutput newAudioOutput = new AudioOutput()
                {
                    Name = "Windows Phone Audio Output",
                    Enabled = true
                };

                await Dbconnection.InsertAsync(newAudioOutput);

                await Dbconnection.CreateTableAsync<Option>();

                Option newOption = new Option()
                {
                    Name = "repeat",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                newOption = new Option()
                {
                    Name = "random",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                newOption = new Option()
                {
                    Name = "consume",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                newOption = new Option()
                {
                    Name = "single",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                /*
                newOption = new Option()
                {
                    Name = "state",
                    ValueString = "stop"
                };
                await Dbconnection.InsertAsync(newOption);
                */
            }

            //
            // Check if empty start Directory exist
            //
            Directory startDirectory = await GetDirectory(string.Empty, 0);

            //
            // If not, create a empty start directory
            //
            // This is so MPD uri's should work in a easy way
            //
            if (startDirectory == null)
            {

                //
                // Create empty start parent Directory
                //
                startDirectory = new Directory()
                {
                    Name = string.Empty,
                    Path = string.Empty,
                    RelativePath = string.Empty,
                    ParentDirectoryId = 0,
                    FolderRelativeId = string.Empty
                };

                //
                // Add start Directory to Directories
                //
                await Dbconnection.InsertAsync(startDirectory);
            }
        }