Files
sunnypilot/selfdrive/ui/sound.hpp
Adeeb Shihadeh 4c19a49586 Fix some alert sounds not repeating (#1763)
* fix sounds not repeating

* fix PC build

* 3 loop

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: af22b282ff
2020-06-22 19:22:02 -07:00

33 lines
791 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);
void stop();
void setVolume(int volume);
~Sound();
#if defined(QCOM) || defined(QCOM2)
private:
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
};