fix(SoundManager): use logarithmic sound volume scale
Needed for status-im/status-desktop#8426
This commit is contained in:
parent
555192427e
commit
68096fe9ab
|
@ -1,5 +1,4 @@
|
|||
#ifndef STATUS_SOUND_MANAGER_H
|
||||
#define STATUS_SOUND_MANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QMediaPlayer>
|
||||
|
@ -10,30 +9,13 @@ namespace Status
|
|||
class SoundManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_DISABLE_COPY_MOVE(SoundManager)
|
||||
public:
|
||||
/*!
|
||||
* Singleton instance.
|
||||
*/
|
||||
static SoundManager &instance();
|
||||
|
||||
/*!
|
||||
* Delete copy constructor.
|
||||
*/
|
||||
SoundManager(const SoundManager &) = delete;
|
||||
/*!
|
||||
* Delete move constructor.
|
||||
*/
|
||||
SoundManager(SoundManager &&) = delete;
|
||||
/*!
|
||||
* Delete copy asignment operator.
|
||||
*/
|
||||
SoundManager &operator=(const SoundManager &) = delete;
|
||||
/*!
|
||||
* Delete move asignment operator.
|
||||
*/
|
||||
SoundManager &operator=(SoundManager &&) = delete;
|
||||
|
||||
/*!
|
||||
* Plays a sound with soundUrl.
|
||||
*
|
||||
|
@ -60,5 +42,3 @@ namespace Status
|
|||
std::unique_ptr<QMediaPlayer> m_player;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@ void SoundManager::playSound(const QUrl &soundUrl)
|
|||
{
|
||||
if (m_player->state() != QMediaPlayer::PlayingState)
|
||||
{
|
||||
if (m_player->currentMedia().canonicalUrl() != soundUrl)
|
||||
if (m_player->currentMedia().request().url() != soundUrl)
|
||||
{
|
||||
m_player->setMedia(soundUrl);
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ void SoundManager::playSound(const QUrl &soundUrl)
|
|||
|
||||
void SoundManager::setPlayerVolume(int volume)
|
||||
{
|
||||
m_player->setVolume(volume);
|
||||
m_player->setVolume(QAudio::convertVolume(volume / qreal(100.0),
|
||||
QAudio::LogarithmicVolumeScale,
|
||||
QAudio::LinearVolumeScale) * 100);
|
||||
}
|
||||
|
||||
void SoundManager::stopPlayer()
|
||||
|
|
Loading…
Reference in New Issue