mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 15:30:29 +02:00
Oboe uses AAudio on Android 8.1+ and falls back to OpenSL ES on older devices. Output and microphone input both go through it. The mic now gets resampled by Oboe from the device's rate to whatever the game asks for. New: when a stream is disconnected (headphones unplugged, Bluetooth device going away), it's reopened on the new default device instead of going silent. Oboe 1.11.0 is added as a submodule, built through ext/oboe-build for CMake and as a module in Android.mk. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <mutex>
|
|
|
|
typedef void (*AndroidAudioCallback)(short *buffer, int numSamples, int sampleRateHz, void *userdata);
|
|
|
|
class AudioContext {
|
|
public:
|
|
AudioContext(AndroidAudioCallback cb, int _FramesPerBuffer, int _SampleRate);
|
|
virtual bool Init() { return false; }
|
|
virtual bool AudioRecord_Start(int sampleRate) { return false; };
|
|
virtual bool AudioRecord_Stop() { return false; };
|
|
|
|
int SampleRate() const { return sampleRate; }
|
|
|
|
virtual ~AudioContext() {}
|
|
|
|
protected:
|
|
static void SetErrorString(const std::string &error);
|
|
AndroidAudioCallback audioCallback;
|
|
|
|
int framesPerBuffer;
|
|
int sampleRate;
|
|
std::mutex errorMutex_;
|
|
};
|
|
|
|
struct AndroidAudioState;
|
|
|
|
// TODO: Get rid of this unnecessary wrapper layer from the old .so days
|
|
|
|
// It's okay for optimalFramesPerBuffer and optimalSampleRate to be 0. Defaults will be used.
|
|
AndroidAudioState *AndroidAudio_Init(AndroidAudioCallback cb, int optimalFramesPerBuffer, int optimalSampleRate);
|
|
bool AndroidAudio_Recording_SetSampleRate(AndroidAudioState *state, int sampleRate);
|
|
bool AndroidAudio_Recording_Start(AndroidAudioState *state);
|
|
bool AndroidAudio_Recording_Stop(AndroidAudioState *state);
|
|
bool AndroidAudio_Recording_State(AndroidAudioState *state);
|
|
bool AndroidAudio_Pause(AndroidAudioState *state);
|
|
bool AndroidAudio_Resume(AndroidAudioState *state);
|
|
bool AndroidAudio_Shutdown(AndroidAudioState *state);
|
|
const std::string AndroidAudio_GetErrorString(AndroidAudioState *state);
|