Commit 9067190f authored by Adrien Béraud's avatar Adrien Béraud

audio: emit event and avoid reloading the same device

Tuleap: #207
Change-Id: Ifc593b662072a8c3cc5f8683e360ff3c01237e95
parent 99edfe7d
......@@ -151,7 +151,7 @@ void sendTrustRequest(const std::string& accountId, const std::string& to, const
struct AudioSignal {
struct DeviceEvent {
constexpr static const char* name = "DeviceEvent";
constexpr static const char* name = "audioDeviceEvent";
using cb_type = void(void);
};
};
......
......@@ -1948,6 +1948,23 @@ Manager::setAudioPlugin(const std::string& audioPlugin)
RING_ERR("No audio layer created, possibly built without audio support");
}
int
Manager::getCurrentDeviceIndex(DeviceType type)
{
if (not audiodriver_)
return -1;
switch (type) {
case DeviceType::PLAYBACK:
return audiodriver_->getIndexPlayback();
case DeviceType::RINGTONE:
return audiodriver_->getIndexRingtone();
case DeviceType::CAPTURE:
return audiodriver_->getIndexCapture();
default:
return -1;
}
}
/**
* Set audio output device
*/
......@@ -1960,6 +1977,10 @@ Manager::setAudioDevice(int index, DeviceType type)
RING_ERR("Audio driver not initialized");
return ;
}
if (getCurrentDeviceIndex(type) == index) {
RING_WARN("Audio device already selected ; doing nothing.");
return;
}
const bool wasStarted = audiodriver_->isStarted();
audiodriver_->updatePreference(audioPreference, index, type);
......
......@@ -798,6 +798,8 @@ class Manager {
*/
void playATone(Tone::TONEID toneId);
int getCurrentDeviceIndex(DeviceType type);
/** Current Call ID */
std::string currentCall_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment