/// <summary> /// Starts the audio stream. /// </summary> public Task Start() { try { if (!Active) { InitAudioQueue(); var result = audioQueue.Start(); if (result == AudioQueueStatus.Ok) { OnActiveChanged?.Invoke(this, true); } else { throw new Exception($"audioQueue.Start() returned non-OK status: {result}"); } } return(Task.FromResult(true)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Error in AudioStream.Start(): {0}", ex); throw; } }
/// <summary> /// Starts the audio stream. /// </summary> public Task Start() { try { if (!Active) { // not sure this does anything or if should be here... inherited via copied code ¯\_(ツ)_/¯ Android.OS.Process.SetThreadPriority(Android.OS.ThreadPriority.UrgentAudio); Init(); audioSource.StartRecording(); OnActiveChanged?.Invoke(this, true); Task.Run(() => Record()); } return(Task.FromResult(true)); } catch (Exception ex) { Debug.WriteLine("Error in AudioStream.Start(): {0}", ex.Message); Stop(); throw; } }
/// <summary> /// Starts the audio stream. /// </summary> public async Task Start() { try { if (!Active) { await Init(); var profile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Low); profile.Audio = AudioEncodingProperties.CreatePcm((uint)SampleRate, (uint)ChannelCount, (uint)BitsPerSample); await capture.StartRecordToStreamAsync(profile, stream); Active = true; OnActiveChanged?.Invoke(this, true); _ = Task.Run(() => Record()); } } catch (Exception ex) { Active = false; System.Diagnostics.Debug.WriteLine("Error in AudioStream.Start(): {0}", ex); throw; } }
/// <summary> /// Stops the audio stream. /// </summary> public Task Stop() { audioQueue.Stop(true); OnActiveChanged?.Invoke(this, false); return(Task.FromResult(true)); }
/// <summary> /// Stops the audio stream. /// </summary> public Task Stop() { if (Active) { Active = false; outputNode?.Stop(); audioGraph?.Stop(); OnActiveChanged?.Invoke(this, false); } outputNode?.Dispose(); outputNode = null; if (audioGraph != null) { audioGraph.QuantumStarted -= Graph_QuantumStarted; audioGraph.UnrecoverableErrorOccurred -= Graph_UnrecoverableErrorOccurred; audioGraph.Dispose(); audioGraph = null; } return(Task.CompletedTask); }
protected virtual void Update() { if (_isActive != IsActive) { _isActive = IsActive; OnActiveChanged?.Invoke(_isActive); } }
/// <summary> /// Stops the audio stream. /// </summary> public Task Stop() { if (Active) { audioSource.Stop(); audioSource.Release(); OnActiveChanged?.Invoke(this, false); } else // just in case { audioSource?.Release(); } return(Task.FromResult(true)); }
/// <summary> /// Stops the audio stream. /// </summary> public Task Stop() { if (audioQueue != null) { audioQueue.InputCompleted -= QueueInputCompleted; if (audioQueue.IsRunning) { BufferOperation(() => audioQueue.Stop(true), () => OnActiveChanged?.Invoke(this, false), status => Debug.WriteLine("AudioStream.Stop() :: audioQueue.Stop returned non OK result: {0}", status)); } audioQueue.Dispose(); audioQueue = null; } return(Task.FromResult(true)); }
/// <summary> /// Stops the audio stream. /// </summary> public Task Stop() { audioQueue.InputCompleted -= QueueInputCompleted; var result = audioQueue.Stop(true); audioQueue.Dispose(); audioQueue = null; if (result == AudioQueueStatus.Ok) { OnActiveChanged?.Invoke(this, false); } else { System.Diagnostics.Debug.WriteLine("AudioStream.Stop() :: audioQueue.Stop returned non OK result: {0}", result); } return(Task.FromResult(true)); }
/// <summary> /// Stops the audio stream. /// </summary> public async Task Stop() { if (capture != null) { capture.RecordLimitationExceeded -= OnRecordLimitationExceeded; capture.Failed -= OnCaptureFailed; } if (Active) { Active = false; await capture.StopRecordAsync(); stream?.Dispose(); capture?.Dispose(); OnActiveChanged?.Invoke(this, false); } }
/// <summary> /// Starts the audio stream. /// </summary> public Task Start() { try { if (!Active) { InitAudioQueue(); BufferOperation(() => audioQueue.Start(), () => OnActiveChanged?.Invoke(this, true), status => throw new Exception($"audioQueue.Start() returned non-OK status: {status}")); } return(Task.FromResult(true)); } catch (Exception ex) { Debug.WriteLine("Error in AudioStream.Start(): {0}", ex.Message); Stop(); throw; } }
/// <summary> /// Starts the audio stream. /// </summary> public async Task Start() { try { if (!Active) { await Init(); // start our constructed audio graph audioGraph.Start(); Active = true; OnActiveChanged?.Invoke(this, true); } } catch (Exception ex) { Debug.WriteLine("Error in AudioStream.Start(): {0}", ex.Message); await Stop(); throw; } }
public void SetInactive() { _isUnitActive = false; OnActiveChanged?.Invoke(this, EventArgs.Empty); }