1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(settings): Play test sound when user enables test sound

Fixes #3735
This commit is contained in:
Alice Weigt 2016-09-27 20:25:44 -07:00
parent 427176ae02
commit 9b46cf6404
3 changed files with 37 additions and 1 deletions

View File

@ -88,6 +88,20 @@ private:
/**
* @class Audio
*
* @enum Audio::Sound
* @brief Provides the different sounds for use in the getSound function.
* @see getSound
*
* @value NewMessage Returns the new message notification sound.
* @value Test Returns the test sound.
* @value IncomingCall Returns the incoming call sound.
*
* @fn QString Audio::getSound(Sound s)
* @brief Function to get the path of the requested sound.
*
* @param s Name of the sound to get the path of.
* @return The path of the requested sound.
*
* @fn void Audio::frameAvailable(const int16_t *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate);
*
* When there are input subscribers, we regularly emit captured audio frames with this signal

View File

@ -28,6 +28,8 @@
#include <QMutex>
#include <QTimer>
#include <cassert>
#if defined(__APPLE__) && defined(__MACH__)
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
@ -49,6 +51,22 @@ class Audio : public QObject
class Private;
public:
enum class Sound { NewMessage, Test, IncomingCall };
inline static QString getSound(Sound s) {
switch (s)
{
case Sound::Test:
return QStringLiteral(":/audio/notification.pcm");
case Sound::NewMessage:
return QStringLiteral(":/audio/notification.pcm");
case Sound::IncomingCall:
return QStringLiteral(":/audio/ToxIncomingCall.pcm");
}
assert(false);
return QString();
}
static Audio& getInstance();
qreal outputVolume() const;

View File

@ -528,13 +528,17 @@ void AVForm::on_playbackSlider_valueChanged(int value)
audio.setOutputVolume(percentage);
if (mPlayTestSound)
audio.playMono16Sound(QStringLiteral(":/audio/notification.pcm"));
audio.playMono16Sound(Audio::getSound(Audio::Sound::Test));
}
}
void AVForm::on_btnPlayTestSound_clicked(bool checked)
{
mPlayTestSound = checked;
Audio& audio = Audio::getInstance();
if (mPlayTestSound && audio.isOutputReady())
audio.playMono16Sound(Audio::getSound(Audio::Sound::Test));
}
void AVForm::on_microphoneSlider_valueChanged(int value)