mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
The reason for moving the implementation out from CSoundGenerator into its own class is, because CSoundGenerator was a very complex and obscure class. It mixed many tasks in one place. CSelcalPlayer is designed to play SELCALs only. The following design changes have been made, compared to CSoundGenerator: * Use pull mode instead of push mode. QBuffer is used as the QIODevice and is a wrapper around QByteArray. Therefore it is not necessary to implement our own QIODevice. * Internally it uses a CThreadedSelcalPlayer to relieve the load of the main thread. CThreadedSelcalPlayer inherits CContinuousWorker, no low level QThread implementation was necessary. * Push mode was not implemented. * It is important that the QAudioOutput is allocated in the worker thread. QAudioOutput allocates internal objects, which cannot be moved to the worker thread. * Data caching. The generated seclal audio data is cached. refs #736
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
/* Copyright (C) 2016
|
|
* swift project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
|
|
//! \file
|
|
|
|
#ifndef BLACKSOUND_SELCALPLAYER_H
|
|
#define BLACKSOUND_SELCALPLAYER_H
|
|
|
|
#include "blacksoundexport.h"
|
|
#include "blacksound/threadedtonepairplayer.h"
|
|
#include "blacksound/tonepair.h"
|
|
#include "blackmisc/aviation/selcal.h"
|
|
#include "blackmisc/worker.h"
|
|
|
|
#include <QAudioDeviceInfo>
|
|
|
|
class QTimer;
|
|
|
|
namespace BlackSound
|
|
{
|
|
//! SELCAL player
|
|
class BLACKSOUND_EXPORT CSelcalPlayer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
//! Constructor
|
|
CSelcalPlayer(const QAudioDeviceInfo &device = QAudioDeviceInfo::defaultOutputDevice(), QObject *parent = nullptr);
|
|
|
|
//! Destructor
|
|
~CSelcalPlayer();
|
|
|
|
//! Play selcal
|
|
void play(int volume, const BlackMisc::Aviation::CSelcal &selcal);
|
|
|
|
private:
|
|
CThreadedTonePairPlayer m_threadedPlayer;
|
|
};
|
|
}
|
|
|
|
#endif // guard
|