public bool StopDecoder() { try { if (_mediaCodec != null) { _mediaCodec.Stop(); _mediaCodec.Release(); } if (_audioTrack != null) { _audioTrack.Stop(); _audioTrack.Release(); } _encoderThread?.Interrupt(); _decoderThread?.Interrupt(); return(true); } catch (Exception) { return(false); } }
public void Clear() { recorder?.Stop(); recorder?.Release(); recorder?.Dispose(); recorder = null; audioTrack?.Stop(); audioTrack?.Release(); audioTrack?.Dispose(); audioTrack = null; }
/* //play short tone on cennection * private void websocketClient_Opened(object sender, EventArgs e) * { * * websocketClient.Send("2000"); * Thread.Sleep(333); * websocketClient.Send("2000"); * * } */ private void websocketClient_MessageReceived(object sender, MessageReceivedEventArgs e) { if (!isPlaying) { byte[] GeneratedSnd = CreateSound(int.Parse(e.Message)); track = new AudioTrack(Stream.Music, 8000, ChannelOut.Mono, Encoding.Pcm16bit, 80000, AudioTrackMode.Static); prevTone = int.Parse(e.Message); isPlaying = !isPlaying; track.Write(GeneratedSnd, 0, 80000); try { track.Play(); } catch (Java.Lang.IllegalStateException) { track.Flush(); track.Release(); } } else if (isPlaying && prevTone != int.Parse(e.Message)) { isPlaying = !isPlaying; track.Stop(); track.Flush(); track.Release(); byte[] GeneratedSnd = CreateSound(int.Parse(e.Message)); track = new AudioTrack(Stream.Music, 8000, ChannelOut.Mono, Encoding.Pcm16bit, 80000, AudioTrackMode.Static); prevTone = int.Parse(e.Message); isPlaying = !isPlaying; track.Write(GeneratedSnd, 0, 80000); try { track.Play(); } catch (Java.Lang.IllegalStateException) { track.Flush(); track.Release(); } } else { isPlaying = !isPlaying; track.Stop(); track.Flush(); track.Release(); } }
public void AudioPlayRelease() { record.Stop(); audioTrack.Stop(); audioTrack.Release(); record.Release(); }
public void Stop() { lock (stateLocker) { if (recorder != null) { if (recorder.RecordingState == RecordState.Recording) { recorder.Stop(); recorder.Release(); recorder = null; recordingThread = null; } } if (player != null) { if (player.PlayState == PlayState.Playing) { player.Stop(); player.Release(); player = null; } } OnMessage?.Invoke(this, "Stopped"); } }
public void stop() { if (!running) { return; } running = false; MainActivity.Instance.VolumeControlStream = Stream.NotificationDefault; if (audioPlayer != null) { try { audioPlayer.Stop(); audioPlayer.Release(); } catch (Exception) { } audioPlayer.Dispose(); audioPlayer = null; } if (audioDecoder != null) { audioDecoder.stop(); audioDecoder.Dispose(); audioDecoder = null; } bufferSize = 0; }
void IDualityBackend.Shutdown() { // Shut down the streaming thread if (streamWorker != null) { streamWorkerEnd = true; if (!streamWorker.Join(1000)) { streamWorker.Abort(); } streamWorkerQueueEvent.Dispose(); streamWorkerEnd = false; streamWorkerQueueEvent = null; streamWorkerQueue = null; streamWorker = null; } if (masterTrack != null) { masterTrack.Stop(); masterTrack.Dispose(); masterTrack = null; } if (activeInstance == this) { activeInstance = null; } }
public async Task PlayOnce(System.IO.Stream stream) { await Task.Run(() => { try { int sampleRate = 16000; var channel = ChannelOut.Mono; var encoding = Android.Media.Encoding.Pcm16bit; var buffSize = AudioTrack.GetMinBufferSize(sampleRate, channel, encoding); if (_playOnceAudioTrack == null) { _playOnceAudioTrack = new AudioTrack(Stream.Music, sampleRate, channel, encoding, buffSize, AudioTrackMode.Stream); } _playOnceAudioTrack.Stop(); _playOnceAudioTrack.Flush(); var buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); _playOnceAudioTrack.Play(); _playOnceAudioTrack.Write(buffer, 0, buffer.Length); } catch (Exception ex) { } }); }
public void StopPlaying() { if (audioTrack != null) { audioTrack.Stop(); audioTrack.Release(); } }
private void AudioTrackStop() { if (audioTrack != null) { audioTrack.Stop(); audioTrack.Release(); audioTrack = null; } }
public void Close() { if (audioTrack != null) { audioTrack.Stop(); audioTrack.Release(); audioTrack.Dispose(); } }
public void StopProgressTone() { if (mProgressTone != null) { mProgressTone.Stop(); mProgressTone.Release(); mProgressTone = null; } }
public void Stop() { if (Track != null) { Track.Stop(); Track.Dispose(); Track = null; } }
public void Stop() { if (audioTrack != null) { audioTrack.Stop(); audioTrack.Release(); audioTrack = null; } }
public static void ReturnAudioTrack(AudioTrack audioTrack) { AudioTrackData audioTrackData = null; for (int i = 0; i < m_audioTracks.Count; i++) { if (m_audioTracks[i].AudioTrack == audioTrack) { audioTrackData = m_audioTracks[i]; break; } } if (!Mixer.EnableAudioTrackCaching) { if (audioTrackData != null) { m_audioTracks.Remove(audioTrackData); } audioTrack.Pause(); audioTrack.Release(); return; } if (audioTrackData == null) { audioTrack.Pause(); audioTrack.Release(); return; } bool flag = false; if (m_audioTracks.Count > 16) { flag = true; for (int j = 0; j < m_audioTracks.Count; j++) { if (m_audioTracks[j].BytesCount < audioTrackData.BytesCount) { flag = false; break; } } } if (flag) { audioTrack.Pause(); audioTrack.Release(); m_audioTracks.Remove(audioTrackData); } else { audioTrack.Stop(); audioTrack.SetPlaybackHeadPosition(audioTrackData.BytesCount / audioTrackData.SoundBuffer.ChannelsCount / 2); audioTrackData.ReloadStaticDataTime = Time.FrameStartTime + 0.75; } LogCacheStats(); }
public void Stop() { if (_audioTrack == null) { return; } _audioTrack.Stop(); _audioTrack.Release(); _audioTrack = null; }
private void StopImmediate() { if (audioTrackImmediate != null) { audioTrackImmediate.Stop(); audioTrackImmediate.Release(); audioTrackImmediate.Dispose(); audioTrackImmediate = null; } }
public void Stop() { if (playingTask != null) { quit = true; playingTask.Wait(); playingTask = null; } audioTrack.Stop(); }
public void StopPlaying() { WvlLogger.Log(LogType.TraceAll, "StopPlaying()"); if (audioTrack != null) { audioTrack.Stop(); audioTrack.Release(); audioTrack = null; } }
public void Stop() { if (!_isPlaying) { return; } _audioTrack.Stop(); _audioTrack = null; _isPlaying = false; }
public void stop() { if (audioPlayer == null) { return; } audioPlayer.Stop(); audioPlayer.Release(); audioPlayer.Dispose(); audioPlayer = null; running = false; }
public void PlaySound(int sampling_rate, byte[] pcm_data) { if (audio != null) { audio.Stop(); audio.Release(); } audio = new AudioTrack(Stream.Music, sampling_rate, ChannelOut.Mono, Encoding.Pcm16bit , pcm_data.Length * sizeof(short), AudioTrackMode.Static); audio.Write(pcm_data, 0, pcm_data.Length); audio.Play(); }
public void PlaySound(int samplingRate, byte[] pcmData) { if (previousAudioTrack != null) { previousAudioTrack.Stop(); previousAudioTrack.Release(); } AudioTrack audioTrack = new AudioTrack(Stream.Music, samplingRate, ChannelOut.Mono, Android.Media.Encoding.Pcm16bit, pcmData.Length * sizeof(short), AudioTrackMode.Static); audioTrack.Write(pcmData, 0, pcmData.Length); audioTrack.Play(); previousAudioTrack = audioTrack; }
private void TogglePause() { if (audioTrack.IsRunning) { audioTrack.Stop(); } else { if (audioTrack.CurrentTime >= audioTrack.Length) { audioTrack.Seek(0); // Reset } audioTrack.Start(); } }
void playSound(int freq, int duration) { var sampleRate = 8000; var generatedSnd = genTone(sampleRate, freq, (duration * sampleRate) / 1000); AudioTrack audioTrack = new AudioTrack(Stream.Music, sampleRate, ChannelConfiguration.Mono, Encoding.Pcm16bit, generatedSnd.Length, AudioTrackMode.Stream); audioTrack.Play(); audioTrack.Write(generatedSnd, 0, generatedSnd.Length); while (audioTrack.PlayState == PlayState.Playing) { Thread.Sleep(10); } audioTrack.Stop(); }
/// <summary> /// Stop the audio /// </summary> public static void Stop() { if (active) { Pause(); if (song.IsPlaying) { song.Stop(); } song.Dispose(); song = null; Reset(); } }
public void Stop() { if (State == SoundStates.Stopped) { return; } if (instance == null) { return; } instance.Stop(); instance.Release(); instance.Dispose(); instance = null; audio.removeinstance(); State = SoundStates.Stopped; }
public void stop() { running = false; lock (pendingFrames) { pendingFrames.Clear(); availableBuffers.Clear(); } if (audioPlayer != null) { try { audioPlayer.Stop(); audioPlayer.Release(); } catch (Exception) { } audioPlayer.Dispose(); audioPlayer = null; } if (audioDecoder != null) { try { audioDecoder.Stop(); audioDecoder.Release(); } catch (Exception) { } audioDecoder.Dispose(); audioDecoder = null; } bufferSize = 0; }
private void OnPlayButton(string koe, int speed) { var wav = new AquesTalk().synthe(koe, speed); if (wav.Length == 1) { return; } if (_audioTrack != null) { _audioTrack.Stop(); _audioTrack.Release(); _audioTrack.Dispose(); } _audioTrack = new AudioTrack(Stream.Music, 8000, ChannelOut.Mono, Encoding.Pcm16bit, wav.Length - 44, AudioTrackMode.Static); _audioTrack.Write(wav, 44, wav.Length - 44); _audioTrack.Play(); }
private void OnPeriodFinished() { int audioDataBufferSize; SoundEffectInstance instance; lock (this) { ++BuffersToWrite; if (BuffersToWrite == NumberOfSubBuffersInAudioTrack) { Track.Stop(); } instance = CurrentInstance; if (instance == null) { return; } instance.readBufferPosition += bufferSize; audioDataBufferSize = instance.soundEffect.WaveDataSize; while (instance.readBufferPosition >= audioDataBufferSize && instance.IsLooped && !instance.exitLoopRequested) { instance.readBufferPosition -= audioDataBufferSize; } if (instance.readBufferPosition < audioDataBufferSize && !ShouldStop) { WriteNextAudioBufferToTrack(); } } if ((instance.readBufferPosition >= audioDataBufferSize || ShouldStop) && instance.PlayState != SoundPlayState.Paused) { instance.Stop(); } }