70 lines
3.1 KiB
C++
70 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "core/playback_types.h"
|
|
#include "core/runtime_state.h"
|
|
#include "ports/volume_status_provider.h"
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
namespace borla {
|
|
|
|
class IAudioEngine : public IVolumeStatusProvider {
|
|
public:
|
|
~IAudioEngine() override = default;
|
|
|
|
virtual bool Start() = 0;
|
|
virtual void Stop() = 0;
|
|
virtual void ApplyPolicy(AudioPolicy policy) = 0;
|
|
virtual void SetVolume(uint8_t volume_percent) = 0;
|
|
virtual void SetWakeWordEnabled(bool enabled) = 0;
|
|
virtual void SetBargeInEnabled(bool enabled) = 0;
|
|
virtual void SetPlaybackPaused(bool paused) = 0;
|
|
// Frees the WakeNet instance. Only for entering BLE provisioning, where the
|
|
// BT controller needs every spare byte and the wake word is unused; the
|
|
// device reboots out of provisioning anyway. Never call this on an ordinary
|
|
// policy change — reloading the model takes ~110 ms and stalls capture.
|
|
virtual void ReleaseWakeWord() = 0;
|
|
// Blocks until nothing owns the speaker, or the timeout elapses. Returns
|
|
// true when playback actually finished. Only for callers that are about to
|
|
// destroy the audio path — chiefly the provisioning reboot, which used to
|
|
// cut "配网成功啦" mid-sentence.
|
|
virtual bool WaitForPlaybackIdle(uint32_t timeout_ms) = 0;
|
|
// Emits the voice frontend counters (AEC reference misses in particular) to
|
|
// the log. Called by diagnostics; the counters are otherwise invisible.
|
|
virtual void LogAudioMetrics(const char* reason) = 0;
|
|
// Emits one aggregated line covering the capture DSP chain for the frames
|
|
// seen since the previous call: microphone/AEC/reference levels, echo
|
|
// return loss, AGC gain, NS state, VAD state, reference ring depth and the
|
|
// measured frame period. Returns false when nothing was captured, so the
|
|
// caller can stay quiet while the microphone is off. Must be called from a
|
|
// diagnostics task: the capture task cannot afford a console write.
|
|
virtual bool LogAudioFrameStats() = 0;
|
|
virtual void CancelPlayback(PlaybackSessionId session_id) = 0;
|
|
virtual void BeginRemotePlayback(
|
|
PlaybackSessionId session_id,
|
|
PlaybackPriority priority) = 0;
|
|
virtual void EndPlaybackInput(PlaybackSessionId session_id) = 0;
|
|
virtual bool SubmitOpusFrame(
|
|
PlaybackSessionId session_id,
|
|
const uint8_t* data,
|
|
size_t size) = 0;
|
|
virtual PlaybackSessionId PlayLocalPrompt(
|
|
LocalPrompt prompt,
|
|
PlaybackPriority priority,
|
|
int16_t selector = -1) = 0;
|
|
virtual PlaybackSessionId PlayLocalSequence(
|
|
const LocalPromptSequence& sequence,
|
|
PlaybackPriority priority) = 0;
|
|
// Plays a prompt WITHOUT publishing kLocalPromptStarted. Used for the
|
|
// wake acknowledgement, which must be audible while the device is already
|
|
// listening: routing it through the normal lifecycle would drive the
|
|
// conversation state to kSpeaking and close the uplink the child is about
|
|
// to talk into.
|
|
virtual PlaybackSessionId PlayDetachedPrompt(
|
|
LocalPrompt prompt,
|
|
PlaybackPriority priority) = 0;
|
|
};
|
|
|
|
} // namespace borla
|