forked from f1xpl/openauto
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Interface for AudioManagers, and refactor to use that instead …
…of sigc++
- Loading branch information
1 parent
40916f1
commit afcfccc
Showing
12 changed files
with
212 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <autoapp/Managers/IManager.hpp> | ||
#include <aasdk_proto/AudioFocusStateEnum.pb.h> | ||
#include <aasdk_proto/AudioFocusTypeEnum.pb.h> | ||
#include <aasdk/Messenger/ChannelId.hpp> | ||
|
||
|
||
|
||
class IAudioManager: public IManager{ | ||
public: | ||
using Pointer = std::shared_ptr<IAudioManager>; | ||
using focusCallback = std::function<void(aasdk::messenger::ChannelId channelId, aasdk::proto::enums::AudioFocusState_Enum focus)>; | ||
|
||
private: | ||
std::vector<focusCallback> focusCallbacks; | ||
|
||
public: | ||
IAudioManager() = default; | ||
virtual ~IAudioManager() = default; | ||
|
||
virtual void start() = 0; | ||
virtual void stop() = 0; | ||
|
||
virtual void requestFocus(aasdk::messenger::ChannelId channelId, aasdk::proto::enums::AudioFocusType_Enum focus) = 0; | ||
virtual void releaseFocus(aasdk::messenger::ChannelId channelId) = 0; | ||
|
||
|
||
void registerFocusCallback(const focusCallback &callback) { | ||
focusCallbacks.emplace_back(callback); | ||
}; | ||
|
||
void updateFocus(aasdk::messenger::ChannelId channelId, aasdk::proto::enums::AudioFocusState_Enum focus) { | ||
for (auto &callback : focusCallbacks) { | ||
callback(channelId, focus); | ||
} | ||
} | ||
|
||
}; |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,28 +1,36 @@ | ||
#pragma once | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <utility> | ||
#include <sigc++/sigc++.h> | ||
|
||
#include "AudioSignals.hpp" | ||
#include "AASignals.hpp" | ||
#include "NavigationSignals.hpp" | ||
#include "autoapp/Managers/IVideoManager.hpp" | ||
#include "autoapp/Managers/IGPSManager.hpp" | ||
#include <autoapp/Managers/INightManager.hpp> | ||
#include <autoapp/Managers/IAudioManager.hpp> | ||
|
||
class Signals : public sigc::trackable { | ||
public: | ||
typedef std::shared_ptr<Signals> Pointer; | ||
|
||
IVideoManager::Pointer videoManager; | ||
AudioSignals::Pointer audioSignals = std::make_shared<AudioSignals>(); | ||
IAudioManager::Pointer audioManager; | ||
IGPSManager::Pointer gpsManager; | ||
AASignals::Pointer aaSignals; | ||
NavigationSignals::Pointer navSignals = std::make_shared<NavigationSignals>(); | ||
INightManager::Pointer nightManager; | ||
|
||
explicit Signals(IVideoManager::Pointer VideoManager, IGPSManager::Pointer GPSManager, AASignals::Pointer AaSignals, INightManager::Pointer NightManager) : videoManager(std::move( | ||
VideoManager)), gpsManager(std::move(GPSManager)), aaSignals(std::move(AaSignals)), nightManager(std::move(NightManager)) { | ||
explicit Signals(IVideoManager::Pointer VideoManager, | ||
IAudioManager::Pointer AudioManager, | ||
IGPSManager::Pointer GPSManager, | ||
AASignals::Pointer AaSignals, | ||
INightManager::Pointer NightManager) : | ||
videoManager(std::move(VideoManager)), | ||
audioManager(std::move(AudioManager)), | ||
gpsManager(std::move(GPSManager)), | ||
aaSignals(std::move(AaSignals)), | ||
nightManager(std::move(NightManager)) { | ||
}; | ||
}; |
Oops, something went wrong.