Code cleanup.
This commit is contained in:
parent
45b2d2ceea
commit
6d8a226d7f
|
@ -10,13 +10,11 @@
|
||||||
#include "xenia/apu/xaudio2/xaudio2_audio_driver.h"
|
#include "xenia/apu/xaudio2/xaudio2_audio_driver.h"
|
||||||
|
|
||||||
#include "xenia/apu/apu-private.h"
|
#include "xenia/apu/apu-private.h"
|
||||||
|
|
||||||
#include "xenia/emulator.h"
|
#include "xenia/emulator.h"
|
||||||
|
|
||||||
using namespace xe;
|
namespace xe {
|
||||||
using namespace xe::apu;
|
namespace apu {
|
||||||
using namespace xe::apu::xaudio2;
|
namespace xaudio2 {
|
||||||
|
|
||||||
|
|
||||||
class XAudio2AudioDriver::VoiceCallback : public IXAudio2VoiceCallback {
|
class XAudio2AudioDriver::VoiceCallback : public IXAudio2VoiceCallback {
|
||||||
public:
|
public:
|
||||||
|
@ -26,9 +24,7 @@ public:
|
||||||
void OnStreamEnd() {}
|
void OnStreamEnd() {}
|
||||||
void OnVoiceProcessingPassEnd() {}
|
void OnVoiceProcessingPassEnd() {}
|
||||||
void OnVoiceProcessingPassStart(uint32_t samples_required) {}
|
void OnVoiceProcessingPassStart(uint32_t samples_required) {}
|
||||||
void OnBufferEnd(void* context) {
|
void OnBufferEnd(void* context) { SetEvent(wait_handle_); }
|
||||||
SetEvent(wait_handle_);
|
|
||||||
}
|
|
||||||
void OnBufferStart(void* context) {}
|
void OnBufferStart(void* context) {}
|
||||||
void OnLoopEnd(void* context) {}
|
void OnLoopEnd(void* context) {}
|
||||||
void OnVoiceError(void* context, HRESULT result) {}
|
void OnVoiceError(void* context, HRESULT result) {}
|
||||||
|
@ -37,14 +33,15 @@ private:
|
||||||
HANDLE wait_handle_;
|
HANDLE wait_handle_;
|
||||||
};
|
};
|
||||||
|
|
||||||
XAudio2AudioDriver::XAudio2AudioDriver(Emulator* emulator, HANDLE wait) :
|
XAudio2AudioDriver::XAudio2AudioDriver(Emulator* emulator, HANDLE wait)
|
||||||
audio_(0), mastering_voice_(0), pcm_voice_(0),
|
: audio_(0),
|
||||||
wait_handle_(wait), voice_callback_(0),
|
mastering_voice_(0),
|
||||||
AudioDriver(emulator) {
|
pcm_voice_(0),
|
||||||
}
|
wait_handle_(wait),
|
||||||
|
voice_callback_(0),
|
||||||
|
AudioDriver(emulator) {}
|
||||||
|
|
||||||
XAudio2AudioDriver::~XAudio2AudioDriver() {
|
XAudio2AudioDriver::~XAudio2AudioDriver() {}
|
||||||
}
|
|
||||||
|
|
||||||
const DWORD ChannelMasks[] = {
|
const DWORD ChannelMasks[] = {
|
||||||
0, // TODO: fixme
|
0, // TODO: fixme
|
||||||
|
@ -53,7 +50,8 @@ const DWORD ChannelMasks[] = {
|
||||||
0, // TODO: fixme
|
0, // TODO: fixme
|
||||||
0, // TODO: fixme
|
0, // TODO: fixme
|
||||||
0, // TODO: fixme
|
0, // TODO: fixme
|
||||||
SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT,
|
SPEAKER_FRONT_LEFT | SPEAKER_FRONT_CENTER | SPEAKER_FRONT_RIGHT |
|
||||||
|
SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT,
|
||||||
0, // TODO: fixme
|
0, // TODO: fixme
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,17 +89,19 @@ void XAudio2AudioDriver::Initialize() {
|
||||||
waveformat.Format.nChannels = frame_channels_;
|
waveformat.Format.nChannels = frame_channels_;
|
||||||
waveformat.Format.nSamplesPerSec = 48000;
|
waveformat.Format.nSamplesPerSec = 48000;
|
||||||
waveformat.Format.wBitsPerSample = 32;
|
waveformat.Format.wBitsPerSample = 32;
|
||||||
waveformat.Format.nBlockAlign = (waveformat.Format.nChannels * waveformat.Format.wBitsPerSample) / 8;
|
waveformat.Format.nBlockAlign =
|
||||||
waveformat.Format.nAvgBytesPerSec = waveformat.Format.nSamplesPerSec * waveformat.Format.nBlockAlign;
|
(waveformat.Format.nChannels * waveformat.Format.wBitsPerSample) / 8;
|
||||||
waveformat.Format.cbSize = sizeof(WAVEFORMATIEEEFLOATEX) - sizeof(WAVEFORMATEX);
|
waveformat.Format.nAvgBytesPerSec =
|
||||||
|
waveformat.Format.nSamplesPerSec * waveformat.Format.nBlockAlign;
|
||||||
|
waveformat.Format.cbSize =
|
||||||
|
sizeof(WAVEFORMATIEEEFLOATEX) - sizeof(WAVEFORMATEX);
|
||||||
|
|
||||||
waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
|
waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
|
||||||
waveformat.Samples.wValidBitsPerSample = waveformat.Format.wBitsPerSample;
|
waveformat.Samples.wValidBitsPerSample = waveformat.Format.wBitsPerSample;
|
||||||
waveformat.dwChannelMask = ChannelMasks[waveformat.Format.nChannels];
|
waveformat.dwChannelMask = ChannelMasks[waveformat.Format.nChannels];
|
||||||
|
|
||||||
hr = audio_->CreateSourceVoice(&pcm_voice_, &waveformat.Format,
|
hr = audio_->CreateSourceVoice(&pcm_voice_, &waveformat.Format, 0,
|
||||||
0, XAUDIO2_DEFAULT_FREQ_RATIO,
|
XAUDIO2_DEFAULT_FREQ_RATIO, voice_callback_);
|
||||||
voice_callback_);
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
XELOGE("CreateSourceVoice failed with %.8X", hr);
|
XELOGE("CreateSourceVoice failed with %.8X", hr);
|
||||||
assert_always();
|
assert_always();
|
||||||
|
@ -128,7 +128,8 @@ void XAudio2AudioDriver::SubmitFrame(uint32_t frame_ptr) {
|
||||||
|
|
||||||
// interleave the data
|
// interleave the data
|
||||||
for (int index = 0, o = 0; index < channel_samples_; ++index) {
|
for (int index = 0, o = 0; index < channel_samples_; ++index) {
|
||||||
for (int channel = 0, table = 0; channel < interleave_channels; ++channel, table += channel_samples_) {
|
for (int channel = 0, table = 0; channel < interleave_channels;
|
||||||
|
++channel, table += channel_samples_) {
|
||||||
output_frame[o++] = poly::byte_swap(input_frame[table + index]);
|
output_frame[o++] = poly::byte_swap(input_frame[table + index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,3 +166,7 @@ void XAudio2AudioDriver::Shutdown() {
|
||||||
delete voice_callback_;
|
delete voice_callback_;
|
||||||
CloseHandle(wait_handle_);
|
CloseHandle(wait_handle_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace xaudio2
|
||||||
|
} // namespace apu
|
||||||
|
} // namespace xe
|
||||||
|
|
Loading…
Reference in New Issue