Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(settings): Play test sound when user enables test sound
Browse files Browse the repository at this point in the history
Fixes #3735
  • Loading branch information
AliceGrey committed Oct 9, 2016
1 parent 427176a commit 9b46cf6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/audio/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ class Audio::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
Expand Down
18 changes: 18 additions & 0 deletions src/audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <QMutex>
#include <QTimer>

#include <cassert>

#if defined(__APPLE__) && defined(__MACH__)
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
Expand All @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/widget/form/settings/avform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9b46cf6

Please sign in to comment.