Commit cf5d18df authored by Adrien Béraud's avatar Adrien Béraud Committed by Guillaume Roguez

audio: allow to mute ringtone device

On Android, if the device is in silent or ringtone mode,
the ringtone device should be muted, while keeping the possibility
to hear the peer during a call.

Tuleap: #262
Change-Id: Ie64da9cb3a940b4749bb163f169474ca237c4b37
parent 25ea2a72
......@@ -362,6 +362,22 @@
</arg>
</method>
<method name="muteRingtone" tp:name-for-bindings="muteRingtone">
<arg type="b" name="mute" direction="in">
<tp:docstring>
True to mute ringtone, false otherwise.
</tp:docstring>
</arg>
</method>
<method name="isRingtoneMuted" tp:name-for-bindings="isRingtoneMuted">
<arg type="b" name="muted" direction="out">
<tp:docstring>
Returns true if ringtone is muted, false otherwise.
</tp:docstring>
</arg>
</method>
<method name="getAudioManager" tp:name-for-bindings="getAudioManager">
<arg type="s" name="api" direction="out">
</arg>
......
......@@ -272,6 +272,18 @@ DBusConfigurationManager::mutePlayback(const bool& mute)
DRing::mutePlayback(mute);
}
auto
DBusConfigurationManager::isRingtoneMuted() -> decltype(DRing::isRingtoneMuted())
{
return DRing::isRingtoneMuted();
}
void
DBusConfigurationManager::muteRingtone(const bool& mute)
{
DRing::muteRingtone(mute);
}
auto
DBusConfigurationManager::getAudioManager() -> decltype(DRing::getAudioManager())
{
......
......@@ -96,6 +96,8 @@ class DBusConfigurationManager :
void muteCapture(const bool& mute);
bool isPlaybackMuted();
void mutePlayback(const bool& mute);
bool isRingtoneMuted();
void muteRingtone(const bool& mute);
std::string getAudioManager();
bool setAudioManager(const std::string& api);
std::vector<std::string> getSupportedAudioManagers();
......
......@@ -716,6 +716,26 @@ mutePlayback(bool mute)
return;
}
bool
isRingtoneMuted()
{
if (auto audiolayer = ring::Manager::instance().getAudioDriver())
return audiolayer->isRingtoneMuted();
RING_ERR("Audio layer not valid");
return false;
}
void
muteRingtone(bool mute)
{
if (auto audiolayer = ring::Manager::instance().getAudioDriver())
return audiolayer->muteRingtone(mute);
RING_ERR("Audio layer not valid");
return;
}
std::map<std::string, std::string>
getHookSettings()
{
......
......@@ -86,6 +86,8 @@ bool isCaptureMuted();
void muteCapture(bool mute);
bool isPlaybackMuted();
void mutePlayback(bool mute);
bool isRingtoneMuted();
void muteRingtone(bool mute);
std::string getAudioManager();
bool setAudioManager(const std::string& api);
......
......@@ -130,7 +130,7 @@ const AudioBuffer& AudioLayer::getToRing(AudioFormat format, size_t writableSamp
ringtoneBuffer_.setFormat(fileformat);
ringtoneBuffer_.resize(readableSamples);
fileToPlay->getNext(ringtoneBuffer_, 1.0);
fileToPlay->getNext(ringtoneBuffer_, isRingtoneMuted_ ? 0. : 1.);
ringtoneBuffer_.setChannelNum(format.nb_channels, true);
AudioBuffer* out;
if (resample) {
......
......@@ -155,6 +155,13 @@ class AudioLayer {
isPlaybackMuted_ = muted;
}
bool isRingtoneMuted() const {
return isRingtoneMuted_;
}
void muteRingtone(bool muted) {
isRingtoneMuted_ = muted;
}
/**
* Set capture stream gain (microphone)
* Range should be [-1.0, 1.0]
......@@ -235,6 +242,11 @@ class AudioLayer {
*/
bool isPlaybackMuted_;
/**
* True if ringtone should be muted
*/
bool isRingtoneMuted_ {false};
/**
* Gain applied to mic signal
*/
......
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