2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-12-17 15:01:52 -06:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
2012-12-26 12:12:26 -06:00
|
|
|
|
2024-06-06 13:32:26 +02:00
|
|
|
#ifdef HAVE_OPENSL_ES
|
|
|
|
#include <SLES/OpenSLES.h>
|
|
|
|
#include <SLES/OpenSLES_Android.h>
|
|
|
|
#endif // HAVE_OPENSL_ES
|
2014-08-14 01:14:35 -04:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "AudioCommon/SoundStream.h"
|
2012-12-17 15:01:52 -06:00
|
|
|
|
2014-03-18 10:37:45 -04:00
|
|
|
class OpenSLESStream final : public SoundStream
|
2012-12-17 15:01:52 -06:00
|
|
|
{
|
2022-08-08 09:17:41 +10:00
|
|
|
#ifdef HAVE_OPENSL_ES
|
2013-02-26 13:49:00 -06:00
|
|
|
public:
|
2017-10-21 16:23:40 -07:00
|
|
|
~OpenSLESStream() override;
|
|
|
|
bool Init() override;
|
2024-06-04 19:32:04 +02:00
|
|
|
bool SetRunning(bool running) override;
|
2019-11-24 21:34:50 +01:00
|
|
|
void SetVolume(int volume) override;
|
2021-08-08 00:23:58 +01:00
|
|
|
static bool IsValid() { return true; }
|
2018-04-12 14:18:04 +02:00
|
|
|
|
2012-12-17 15:01:52 -06:00
|
|
|
private:
|
2024-06-06 13:32:26 +02:00
|
|
|
static void BQPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void* context);
|
|
|
|
void PushSamples(SLAndroidSimpleBufferQueueItf bq);
|
|
|
|
|
|
|
|
// engine interfaces
|
|
|
|
SLObjectItf m_engine_object;
|
|
|
|
SLEngineItf m_engine_engine;
|
|
|
|
SLObjectItf m_output_mix_object;
|
|
|
|
|
|
|
|
// buffer queue player interfaces
|
|
|
|
SLObjectItf m_bq_player_object = nullptr;
|
|
|
|
SLPlayItf m_bq_player_play;
|
|
|
|
SLAndroidSimpleBufferQueueItf m_bq_player_buffer_queue;
|
|
|
|
SLVolumeItf m_bq_player_volume;
|
|
|
|
|
|
|
|
static constexpr int BUFFER_SIZE = 512;
|
|
|
|
static constexpr int BUFFER_SIZE_IN_SAMPLES = BUFFER_SIZE / 2;
|
|
|
|
|
|
|
|
// Double buffering.
|
|
|
|
short m_buffer[2][BUFFER_SIZE];
|
|
|
|
int m_current_buffer = 0;
|
2022-08-08 09:17:41 +10:00
|
|
|
#endif // HAVE_OPENSL_ES
|
2012-12-17 15:01:52 -06:00
|
|
|
};
|