mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 18:38:36 +00:00
Replace the hand-written C++ XMA2/WMA Pro decoder with the Rust decoder already on main. runtime/CMakeLists.txt builds it at configure time when cargo is on PATH and links it into gta6rt and acphal_test (LEONIDA_HAVE_XMA2_DECODER); without cargo, if that build fails, or with the cl.exe fallback, XMA voices output silence for each packet's frame count. The ring engine decodes whole 2048-byte packets: the read offset and the loop points are used per packet, so a loop plays its end packet in full and restarts with a fresh decoder at the packet holding the loop start. The C ABI gains leonida_xma2_decoder_create_hardware (no first-frame drop, no 64-sample start skip), since the context carries its own skip. Tested: acphal_test 129 checks (silence) and 125 checks (Rust decoder, gnullvm build), 0 failures, 3 runs each, clang 23 / mingw x64; cargo fmt and cargo test (gnullvm); pytest build/docs suites 204 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
#ifndef LEONIDA_XMA2_DECODER_H
|
|
#define LEONIDA_XMA2_DECODER_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define LEONIDA_XMA2_PACKET_BYTES 2048u
|
|
|
|
typedef struct LeonidaXma2Decoder LeonidaXma2Decoder;
|
|
typedef struct LeonidaXma2PcmBlock LeonidaXma2PcmBlock;
|
|
|
|
enum LeonidaXma2Status {
|
|
LEONIDA_XMA2_OK = 0,
|
|
LEONIDA_XMA2_INVALID_ARGUMENT = 1,
|
|
LEONIDA_XMA2_INVALID_FORMAT = 2,
|
|
LEONIDA_XMA2_BAD_PACKET_SIZE = 3,
|
|
LEONIDA_XMA2_OUT_OF_MEMORY = 4,
|
|
LEONIDA_XMA2_DECODER_FAILURE = 5,
|
|
LEONIDA_XMA2_PANIC = 6,
|
|
};
|
|
|
|
int32_t leonida_xma2_decoder_create(uint32_t sample_rate, uint32_t channels,
|
|
LeonidaXma2Decoder **out_decoder);
|
|
/* Like leonida_xma2_decoder_create, but decodes like the console's XMA hardware: the first
|
|
frame is kept and there is no 64-sample start skip; the caller applies the context's skip. */
|
|
int32_t leonida_xma2_decoder_create_hardware(uint32_t sample_rate, uint32_t channels,
|
|
LeonidaXma2Decoder **out_decoder);
|
|
int32_t leonida_xma2_decode_buffer(LeonidaXma2Decoder *decoder,
|
|
const uint8_t *input, size_t input_len,
|
|
LeonidaXma2PcmBlock **out_block);
|
|
void leonida_xma2_decoder_destroy(LeonidaXma2Decoder *decoder);
|
|
const int16_t *leonida_xma2_pcm_data(const LeonidaXma2PcmBlock *block);
|
|
size_t leonida_xma2_pcm_sample_count(const LeonidaXma2PcmBlock *block);
|
|
void leonida_xma2_pcm_destroy(LeonidaXma2PcmBlock *block);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|