forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move android into own dir * fix name * maybe this works? qt ui doesn't work on mac * fix that * pc sound works * fix pc build * lowercase * that needs to be real_arch * split into classes * fix typo in lib * Fix cycle alerts * Add qt multimedia libs to install scripts * Add ui/android folder * Fix android build * Raise exception if sound init fails * add missing return Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Comma Device <device@comma.ai>
- Loading branch information
1 parent
9eca642
commit acd1bde
Showing
16 changed files
with
178 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include <SLES/OpenSLES.h> | ||
#include <SLES/OpenSLES_Android.h> | ||
|
||
#include "sound.hpp" | ||
|
||
|
||
class SLSound : public Sound { | ||
public: | ||
SLSound(); | ||
~SLSound(); | ||
bool play(AudibleAlert alert); | ||
void stop(); | ||
void setVolume(int volume); | ||
|
||
private: | ||
bool init(); | ||
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <QUrl> | ||
#include "qt/qt_sound.hpp" | ||
|
||
QtSound::QtSound() { | ||
for (auto &kv : sound_map) { | ||
auto path = QUrl::fromLocalFile(kv.second.first); | ||
sounds[kv.first].setSource(path); | ||
} | ||
} | ||
|
||
bool QtSound::play(AudibleAlert alert) { | ||
sounds[alert].setLoopCount(sound_map[alert].second); | ||
sounds[alert].play(); | ||
return true; | ||
} | ||
|
||
void QtSound::stop() { | ||
for (auto &kv : sounds) { | ||
kv.second.stop(); | ||
} | ||
} | ||
|
||
void QtSound::setVolume(int volume) { | ||
// TODO: implement this | ||
} | ||
|
||
QtSound::~QtSound() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <QSoundEffect> | ||
#include "sound.hpp" | ||
|
||
class QtSound : public Sound { | ||
public: | ||
QtSound(); | ||
~QtSound(); | ||
bool play(AudibleAlert alert); | ||
void stop(); | ||
void setVolume(int volume); | ||
|
||
private: | ||
std::map<AudibleAlert, QSoundEffect> sounds; | ||
}; |
Oops, something went wrong.