#ifndef Back_End_H
#define Back_End_H

#include <QObject>
#include <QTimer>
#include <QKeyEvent>
#include <QThread>
#include <map>

class Back_End : public QObject {
    Q_OBJECT
public:
    std::map<QString, Qt::Key> function_map;
    bool match(QKeyEvent* e, const QString& function);
    static Back_End* instance();
    int YsGetAfGain();
    void YsSetAfGain(int value);
    int YsGetRfGain();
    void YsSetRfGain(int value);
    qint64 YsGetFreq();
    void YsSetFreq(quint64 value);
    void YsReceiveFreq(quint64 freq);
    void play(const QString& fileName);
    QString get_screenshot_save_dir_path();
    QString get_screenshot_save_file_name();
    QString get_audio_file_location();
    void stop_mock_thread() {
        if (mock_thread) {
            mock_thread->quit();
            mock_thread->wait();
            mock_thread = nullptr;
        }
    }
    Back_End(const Back_End&) = delete;
    Back_End& operator=(const Back_End&) = delete;
    void call_back_data_func(int channel, void *pData, int i_length);
protected:
    Back_End();
    ~Back_End() override {
        stop_mock_thread();
    }
    QThread* mock_thread{};
};

#endif



