public void Clear() { recorder?.Stop(); recorder?.Release(); recorder?.Dispose(); recorder = null; audioTrack?.Stop(); audioTrack?.Release(); audioTrack?.Dispose(); audioTrack = null; }
/// <summary> /// Stops the currently playing audio /// </summary> public void StopPlaying() { //This lock is used to ensure that starting and stopping of songs do not happen at the same time. lock (startStopSyncObject) { if (!IsPlaying) { throw new InvalidOperationException("Audio is not playing"); } #if __ANDROID__ //We use pause instead of stop because pause stops playing immediately playingTrack.Pause(); //Lock track disposal so the track is never in a state where it is disposed/released but not null lock (trackDisposedOfSyncObject) { playingTrack.Release(); playingTrack.Dispose(); playingTrack = null; } #endif #if __IOS__ //Pass true to stop immediately audioQueue.Stop(true); //Lock track disposal so the track is never in a state where it is disposed but not null lock (trackDisposedOfSyncObject) { audioQueue.Dispose(); audioQueue = null; } #endif } }
protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); audioTrack?.Dispose(); audioTrackStream?.Dispose(); effectController?.Dispose(); }
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; } }
/// <summary> /// Plays a single note. Separate from the rest of the song playing code /// </summary> public static void PlayNote(Instrument.Note note) { lock (syncObj) { #if __ANDROID__ if (playingTrack != null) { //We use pause instead of stop because pause stops playing immediately playingTrack.Pause(); playingTrack.Release(); playingTrack.Dispose(); } #endif #if __IOS__ if (audioQueue != null) { //Pass true to stop immediately audioQueue.Stop(true); audioQueue.Dispose(); } #endif #if __ANDROID__ playingTrack = new AudioTrack( // Stream type Android.Media.Stream.Music, // Frequency SongPlayer.PLAYBACK_RATE, // Mono or stereo ChannelOut.Mono, // Audio encoding Android.Media.Encoding.Pcm16bit, // Length of the audio clip in bytes (note.data.Length * 2), // Mode. Stream or static. AudioTrackMode.Static); playingTrack.Write(note.data, 0, note.data.Length); playingTrack.Play(); #endif #if __IOS__ audioQueue = new OutputAudioQueue(AudioStreamBasicDescription.CreateLinearPCM(SongPlayer.PLAYBACK_RATE, 1, 16, false)); unsafe { AudioQueueBuffer *buffer; audioQueue.AllocateBuffer(note.data.Length * 2, out buffer); fixed(short *beatData = note.data) { buffer->CopyToAudioData((IntPtr)beatData, note.data.Length * 2); } audioQueue.EnqueueBuffer((IntPtr)buffer, note.data.Length * 2, null); } audioQueue.Start(); #endif } }
public void Dispose() { Stop(); StopImmediate(); audioTrack.Release(); audioTrack.Dispose(); audioTrack = null; }
public void Stop() { if (Track != null) { Track.Stop(); Track.Dispose(); Track = null; } }
protected virtual void Dispose(bool disposing) { if (!isDisposed) { track?.Dispose(); reader?.Dispose(); isDisposed = true; } }
protected virtual void Dispose(bool disposing) { if (!isDisposed) { track?.Dispose(); background?.Dispose(); isDisposed = true; } }
public void Close() { if (audioTrack != null) { audioTrack.Stop(); audioTrack.Release(); audioTrack.Dispose(); } }
private void StopImmediate() { if (audioTrackImmediate != null) { audioTrackImmediate.Stop(); audioTrackImmediate.Release(); audioTrackImmediate.Dispose(); audioTrackImmediate = null; } }
internal virtual void InternalDispose() { Mixer.m_sounds.Remove(this); if (m_audioTrack != null) { m_audioTrack.Pause(); m_audioTrack.Release(); m_audioTrack.Dispose(); m_audioTrack = null; Mixer.m_audioTracksDestroyed++; } }
public void stop() { if (audioPlayer == null) { return; } audioPlayer.Stop(); audioPlayer.Release(); audioPlayer.Dispose(); audioPlayer = null; running = false; }
private void StopStreamingAudio() { #if __ANDROID__ if (playingTrack == null || playingTrack.PlayState != PlayState.Playing) { throw new InvalidOperationException("Audio is not playing"); } playingTrack.Pause(); //playingTrack.Flush(); playingTrack.Release(); playingTrack.Dispose(); #endif }
private static void ResetAudioPreview() { if (sampleTrack != null) { sampleTrack.Dispose(); sampleTrack = null; if (WasPlayingAudio && GameBase.Mode != OsuModes.OnlineSelection && GameBase.Mode != OsuModes.Play) { AudioEngine.AllowRandomSong = true; AudioEngine.TogglePause(); } } }
/// <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(); }
public void Dispose() { Track.Release(); Track.Dispose(); JNIEnv.DeleteGlobalRef(javaDataBuffer); }
/// <summary> /// Called to dispose of the object /// </summary> public void Dispose() { _audioTrack?.Release(); _audioTrack?.Dispose(); }