mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 00:36:38 +02:00
Another pass looking for gaps, all of it now recorded by audio/blocking/channels and audio/blocking/oneshot. sceAudioOneshotOutput was the last unimplemented entry in the module, returning "library not linked" to anyone who called it. It plays one buffer on a channel it never reserves, so the channel frees itself when the buffer runs out, and its argument checks are their own set: any positive sample count, aligned or not, no upper bound, a negative volume rejected rather than skipped, and no busy check at all. No game is known to use it; it is implemented because tracing it turned out to be cheap, not because anything needed it. The channels test confirms four behaviors: sceAudioChReserve(-1) skips a released channel that is still playing while a reserve of it succeeds, a second channel joining a running mixer doesn't lose a block unlike a first, mono counts down in the same 64-sample steps over the same time as stereo, and the panned blocking output has no extra delay on the high channels. Also: the SRC resampler now interpolates into the next buffer at a buffer join instead of holding the last sample, since the codec reads the two descriptors as one stream. That only shows up at non-native rates and no test can see it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
79 lines
3.1 KiB
C++
79 lines
3.1 KiB
C++
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
// Official git repository and contact information can be found at
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
#pragma once
|
|
|
|
#include "Common/File/Path.h"
|
|
|
|
#include "sceAudio.h"
|
|
|
|
struct AudioDebugStats {
|
|
int buffered;
|
|
int watermark;
|
|
int bufsize;
|
|
int underrunCount;
|
|
int overrunCount;
|
|
int instantSampleRate;
|
|
int targetSampleRate;
|
|
int lastPushSize;
|
|
};
|
|
|
|
// Easy interface for sceAudio to write to, to keep the complexity in check.
|
|
|
|
void __AudioInit();
|
|
void __AudioDoState(PointerWrap &p);
|
|
void __AudioUpdate(bool resetRecording = false);
|
|
void __AudioShutdown();
|
|
void __AudioSetOutputFrequency(int freq);
|
|
void __AudioSetSRCFrequency(int freq);
|
|
|
|
// The driver's single enqueue point for channels 0-7. Returns the channel's reserved sample
|
|
// count, or SCE_ERROR_AUDIO_CHANNEL_BUSY when a buffer is already in flight. A negative
|
|
// volume means "leave it alone".
|
|
u32 __AudioEnqueue(AudioChannel &chan, u32 samplePtr, int leftVol, int rightVol);
|
|
// sceAudioOneshotOutput's variant: hands over a buffer without a reservation, so it carries its
|
|
// own sample count and format and never reports busy.
|
|
void __AudioEnqueueOneshot(AudioChannel &chan, u32 samplePtr, u32 sampleCount, u32 format, int leftVol, int rightVol);
|
|
// Same, but parks the calling thread until the channel frees up. Only one thread can be
|
|
// parked; a second one gets SCE_ERROR_AUDIO_CHANNEL_BUSY straight back.
|
|
u32 __AudioEnqueueBlocking(AudioChannel &chan, u32 samplePtr, int leftVol, int rightVol);
|
|
|
|
// Channel 8 - Output2, SRC and Vaudio all share it. Two buffers fit; a third caller gets
|
|
// SCE_ERROR_AUDIO_CHANNEL_BUSY without waiting. A successful call waits for one buffer to
|
|
// finish before returning, except when nothing was playing to begin with.
|
|
u32 __AudioSRCEnqueueBlocking(AudioSRCChannel &chan, u32 samplePtr, int vol);
|
|
// Hands the SRC channel a completion that the next caller can consume without waiting.
|
|
void __AudioSRCSignal(AudioSRCChannel &chan);
|
|
// What one SRC/Output2 output call costs, in cycles, before it does anything - see the comment
|
|
// on the definition.
|
|
int __AudioSRCCallCycles(const AudioSRCChannel &chan);
|
|
|
|
// Wake everyone parked on the SRC channel with the given error. Mixer channels need no
|
|
// equivalent: releasing one while a thread waits on it is refused outright.
|
|
void __AudioWakeThreads(AudioSRCChannel &chan, int result);
|
|
|
|
void __AudioCPUMHzChange();
|
|
|
|
// AUDIO Dumping stuff
|
|
void __StartLogAudio(const Path &filename);
|
|
void __StopLogAudio();
|
|
|
|
class WAVDump {
|
|
public:
|
|
static void Reset();
|
|
};
|