mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Tone player "myself" guard
This commit is contained in:
committed by
Mat Sutcliffe
parent
5b3c011a15
commit
5718f95819
@@ -28,12 +28,16 @@ namespace BlackSound
|
||||
|
||||
void CThreadedTonePairPlayer::play(int volume, const QList<CTonePair> &tonePairs)
|
||||
{
|
||||
QPointer<CThreadedTonePairPlayer> myself(this);
|
||||
QMutexLocker ml(&m_mutex);
|
||||
if (m_audioOutput->state() != QAudio::StoppedState) { return; }
|
||||
|
||||
m_bufferData = this->getAudioByTonePairs(tonePairs);
|
||||
m_audioOutput->setVolume(static_cast<qreal>(0.01 * volume));
|
||||
QTimer::singleShot(0, this, &CThreadedTonePairPlayer::playBuffer);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (myself) { myself->playBuffer(); }
|
||||
});
|
||||
}
|
||||
|
||||
bool CThreadedTonePairPlayer::reinitializeAudio(const CAudioDeviceInfo &device)
|
||||
|
||||
@@ -68,9 +68,9 @@ namespace BlackSound
|
||||
|
||||
BlackMisc::Audio::CAudioDeviceInfo m_deviceInfo;
|
||||
QAudioOutput *m_audioOutput = nullptr;
|
||||
QByteArray m_bufferData;
|
||||
QBuffer m_buffer;
|
||||
QAudioFormat m_audioFormat;
|
||||
QByteArray m_bufferData;
|
||||
QBuffer m_buffer;
|
||||
QAudioFormat m_audioFormat;
|
||||
QMap<CTonePair, QByteArray> m_tonePairCache;
|
||||
mutable QMutex m_mutex { QMutex::Recursive };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user