Discard the current packet when XMA context is released
Some more cleanup
This commit is contained in:
parent
a6175dba48
commit
a69d1b7f04
|
@ -61,7 +61,8 @@ int AudioDecoder::Initialize(int bits) {
|
||||||
packet_ = new AVPacket();
|
packet_ = new AVPacket();
|
||||||
av_init_packet(packet_);
|
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_->sample_rate = 0;
|
||||||
context_->block_align = XMAContextData::kBytesPerBlock;
|
context_->block_align = XMAContextData::kBytesPerBlock;
|
||||||
|
|
||||||
|
@ -84,10 +85,6 @@ int AudioDecoder::Initialize(int bits) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDecoder::Cleanup() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int AudioDecoder::PreparePacket(uint8_t* input, size_t size,
|
int AudioDecoder::PreparePacket(uint8_t* input, size_t size,
|
||||||
int sample_rate, int channels) {
|
int sample_rate, int channels) {
|
||||||
if (size != XMAContextData::kBytesPerBlock) {
|
if (size != XMAContextData::kBytesPerBlock) {
|
||||||
|
@ -107,7 +104,6 @@ int AudioDecoder::PreparePacket(uint8_t* input, size_t size,
|
||||||
(*((int*)packet_data_) & 0xFFFEFF08);
|
(*((int*)packet_data_) & 0xFFFEFF08);
|
||||||
offset_ += XMAContextData::kBytesPerBlock; // Sequence number
|
offset_ += XMAContextData::kBytesPerBlock; // Sequence number
|
||||||
|
|
||||||
//std::memcpy(packet_data_, input, size);
|
|
||||||
packet_->data = packet_data_;
|
packet_->data = packet_data_;
|
||||||
packet_->size = XMAContextData::kBytesPerBlock;
|
packet_->size = XMAContextData::kBytesPerBlock;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ class AudioDecoder {
|
||||||
~AudioDecoder();
|
~AudioDecoder();
|
||||||
|
|
||||||
int Initialize(int bits);
|
int Initialize(int bits);
|
||||||
void Cleanup();
|
|
||||||
|
|
||||||
int PreparePacket(uint8_t* input, size_t size, int sample_rate, int channels);
|
int PreparePacket(uint8_t* input, size_t size, int sample_rate, int channels);
|
||||||
void DiscardPacket();
|
void DiscardPacket();
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
#include "xenia/kernel/objects/xthread.h"
|
#include "xenia/kernel/objects/xthread.h"
|
||||||
#include "xenia/profiling.h"
|
#include "xenia/profiling.h"
|
||||||
|
|
||||||
#include "libavutil/log.h"
|
|
||||||
|
|
||||||
// As with normal Microsoft, there are like twelve different ways to access
|
// As with normal Microsoft, there are like twelve different ways to access
|
||||||
// the audio APIs. Early games use XMA*() methods almost exclusively to touch
|
// the audio APIs. Early games use XMA*() methods almost exclusively to touch
|
||||||
// decoders. Later games use XAudio*() and direct memory writes to the XMA
|
// 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;
|
context.in_use = false;
|
||||||
auto context_ptr = memory()->TranslateVirtual(guest_ptr);
|
auto context_ptr = memory()->TranslateVirtual(guest_ptr);
|
||||||
std::memset(context_ptr, 0, kXmaContextSize); // Zero it.
|
std::memset(context_ptr, 0, kXmaContextSize); // Zero it.
|
||||||
|
context.decoder->DiscardPacket();
|
||||||
|
|
||||||
context.lock.unlock();
|
context.lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue