From 3389b9e421c5aea02ffe6b140f36f2b4991ffc50 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Fri, 22 May 2015 22:02:11 -0500 Subject: [PATCH] AudioDecoder destructor --- src/xenia/apu/audio_decoder.cc | 15 +++++++++++++++ src/xenia/apu/audio_system.cc | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/xenia/apu/audio_decoder.cc b/src/xenia/apu/audio_decoder.cc index 53a6b6496..f296b645a 100644 --- a/src/xenia/apu/audio_decoder.cc +++ b/src/xenia/apu/audio_decoder.cc @@ -26,6 +26,21 @@ AudioDecoder::AudioDecoder() : offset_(0) { } AudioDecoder::~AudioDecoder() { + if (context_) { + if (context_->extradata) { + delete context_->extradata; + } + if (avcodec_is_open(context_)) { + avcodec_close(context_); + } + av_free(context_); + } + if (decoded_frame_) { + avcodec_free_frame(&decoded_frame_); + } + if (current_frame_) { + delete current_frame_; + } } int AudioDecoder::Initialize(int bits) { diff --git a/src/xenia/apu/audio_system.cc b/src/xenia/apu/audio_system.cc index 776704315..cf37cebdc 100644 --- a/src/xenia/apu/audio_system.cc +++ b/src/xenia/apu/audio_system.cc @@ -95,11 +95,14 @@ X_STATUS AudioSystem::Setup() { // Create a new decoder per context // Needed because some data needs to be persisted across calls + // TODO: Need to destroy this on class destruction xma_context_array_[i].decoder = new AudioDecoder(); xma_context_array_[i].decoder->Initialize(16); } registers_.next_context = 1; + // Threads + worker_running_ = true; worker_thread_ = new kernel::XHostThread(emulator()->kernel_state(), 128 * 1024, 0, [this]() {