mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-26 08:22:05 +08:00
8cacc14b31
* Soud refactor * remove files from files_common * add timeout to set_volumn * add param volume to init * done * test.cc * fix typo * add repeat param instead of loop * revert submodule * add member function currentSound * remove function create_player from class member * fix build error fix repeat * rename CHECK_RESULT to ReturnOnError * set currentSound_ before posible err * use std::map to initialize sound table cleanup cleanup cleanup fix bug in stop change paramater name * done * remove function CreatePlayer, create player in init() * resolve conflict * remove sound test * rebase * remove whitespace * Apply great review suggestion * use player's SLVolumeItf interface to set volume * use float * leave the volume control the way it is
34 lines
865 B
C++
34 lines
865 B
C++
#pragma once
|
|
#include <map>
|
|
#include "cereal/gen/cpp/log.capnp.h"
|
|
|
|
#if defined(QCOM) || defined(QCOM2)
|
|
#include <SLES/OpenSLES.h>
|
|
#include <SLES/OpenSLES_Android.h>
|
|
#endif
|
|
|
|
typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert;
|
|
|
|
class Sound {
|
|
public:
|
|
Sound() = default;
|
|
bool init(int volume);
|
|
bool play(AudibleAlert alert, int repeat = 0);
|
|
void stop();
|
|
void setVolume(int volume, int timeout_seconds = 5);
|
|
AudibleAlert currentPlaying();
|
|
~Sound();
|
|
|
|
private:
|
|
#if defined(QCOM) || defined(QCOM2)
|
|
SLObjectItf engine_ = nullptr;
|
|
SLObjectItf outputMix_ = nullptr;
|
|
int last_volume_ = 0;
|
|
double last_set_volume_time_ = 0.;
|
|
AudibleAlert currentSound_ = AudibleAlert::NONE;
|
|
struct Player;
|
|
std::map<AudibleAlert, Player *> player_;
|
|
friend void SLAPIENTRY slplay_callback(SLPlayItf playItf, void *context, SLuint32 event);
|
|
#endif
|
|
};
|