af8c0f5ccd
Reserves a hardware channel per stream (64-aligned sample count, mono/stereo format) and outputs through sceAudioOutputPannedBlocking, giving PSP real stereo panning from directionality. Enforces the 44100Hz hardware-channel constraint with a clear error instead of silently mispitching, and drops the shared test tone to 44100Hz to match. Verified via the dusk-psp toolchain and a headless PPSSPP run (correct channel reservation, onEnd firing once, no errors).
37 lines
832 B
C
37 lines
832 B
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "audiostreampcm.h"
|
|
#include "audiostream.h"
|
|
#include "assert/assert.h"
|
|
|
|
errorret_t audioStreamPcmInit(
|
|
audiostream_t *stream,
|
|
uint8_t *data,
|
|
const size_t dataSize,
|
|
const uint32_t sampleRate,
|
|
const uint8_t channels
|
|
) {
|
|
assertNotNull(stream, "Stream cannot be NULL.");
|
|
assertNotNull(data, "Data cannot be NULL.");
|
|
|
|
stream->type = AUDIO_STREAM_TYPE_PCM;
|
|
stream->data = data;
|
|
stream->dataSize = dataSize;
|
|
stream->pcm.sampleRate = sampleRate;
|
|
stream->pcm.channels = channels;
|
|
stream->duration = (
|
|
(float_t) dataSize /
|
|
(float_t) (channels * sizeof(int16_t)) /
|
|
(float_t) sampleRate
|
|
);
|
|
|
|
errorChain(audioStreamPlatformInit(stream));
|
|
|
|
errorOk();
|
|
}
|