Discard the current packet when XMA context is released

Some more cleanup
This commit is contained in:
Dr. Chat 2015-05-22 21:53:46 -05:00
parent a6175dba48
commit a69d1b7f04
3 changed files with 3 additions and 9 deletions

View File

@ -61,7 +61,8 @@ int AudioDecoder::Initialize(int bits) {
packet_ = new AVPacket();
av_init_packet(packet_);
context_->channels = 0; // Only 1 channel for our purposes.
// Initialize these to 0. They'll actually be set later.
context_->channels = 0;
context_->sample_rate = 0;
context_->block_align = XMAContextData::kBytesPerBlock;
@ -84,10 +85,6 @@ int AudioDecoder::Initialize(int bits) {
return 0;
}
void AudioDecoder::Cleanup() {
}
int AudioDecoder::PreparePacket(uint8_t* input, size_t size,
int sample_rate, int channels) {
if (size != XMAContextData::kBytesPerBlock) {
@ -107,7 +104,6 @@ int AudioDecoder::PreparePacket(uint8_t* input, size_t size,
(*((int*)packet_data_) & 0xFFFEFF08);
offset_ += XMAContextData::kBytesPerBlock; // Sequence number
//std::memcpy(packet_data_, input, size);
packet_->data = packet_data_;
packet_->size = XMAContextData::kBytesPerBlock;

View File

@ -37,7 +37,6 @@ class AudioDecoder {
~AudioDecoder();
int Initialize(int bits);
void Cleanup();
int PreparePacket(uint8_t* input, size_t size, int sample_rate, int channels);
void DiscardPacket();

View File

@ -19,8 +19,6 @@
#include "xenia/kernel/objects/xthread.h"
#include "xenia/profiling.h"
#include "libavutil/log.h"
// As with normal Microsoft, there are like twelve different ways to access
// the audio APIs. Early games use XMA*() methods almost exclusively to touch
// decoders. Later games use XAudio*() and direct memory writes to the XMA
@ -362,6 +360,7 @@ void AudioSystem::ReleaseXmaContext(uint32_t guest_ptr) {
context.in_use = false;
auto context_ptr = memory()->TranslateVirtual(guest_ptr);
std::memset(context_ptr, 0, kXmaContextSize); // Zero it.
context.decoder->DiscardPacket();
context.lock.unlock();
}