public void stopDecoding() { if (decoderState >= DecoderState.INITIALIZING) { print(LOG_TAG + " stop decoding."); decoderState = DecoderState.STOP; ReleaseTexture(); if (isAudioEnabled && !isAllAudioChEnabled) { StopCoroutine("audioPlay"); backgroundWorker.CancelAsync(); if (audioSource != null) { for (int i = 0; i < SWAP_BUFFER_NUM; i++) { if (audioSource[i] != null) { AudioClip.Destroy(audioSource[i].clip); AudioSource.Destroy(audioSource[i]); audioSource[i] = null; } } } } nativeDestroyDecoder(decoderID); decoderID = -1; decoderState = DecoderState.NOT_INITIALIZED; isVideoEnabled = isAudioEnabled = isAllAudioChEnabled = false; isVideoReadyToReplay = isAudioReadyToReplay = false; isAllAudioChEnabled = false; } }
private async Task StopAudioStream() { if (AudioSource != null) { DoStopAudioStream(); await AudioSource.Stop(); AudioSource.Destroy(); AudioSource = null; } if (AudioDepacketizer != null) { AudioDepacketizer.Destroy(); AudioDepacketizer = null; } if (AudioDecoder != null) { AudioDecoder.Destroy(); AudioDecoder = null; } if (ResetAudioPipe != null) { ResetAudioPipe.Destroy(); ResetAudioPipe = null; } if (AudioConverter != null) { AudioConverter.Destroy(); AudioConverter = null; } if (AudioEncoder != null) { AudioEncoder.Destroy(); AudioEncoder = null; } if (AudioPacketizer != null) { AudioPacketizer.Destroy(); AudioPacketizer = null; } }
private void StopSound(AudioClip originalClip) { // As it is not 3D audio clip, position doesn't matter. AudioSource.Destroy(originalClip); }