File: AudioDecoder.h

package info (click to toggle)
js8call 2.2.0%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 22,416 kB
  • sloc: cpp: 563,285; f90: 9,265; ansic: 937; python: 132; sh: 93; makefile: 7
file content (50 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef AUDIODECODER_H
#define AUDIODECODER_H

#include <QAudioDecoder>
#include <QAudioFormat>
#include <QBuffer>
#include <QIODevice>
#include <QPointer>


class AudioDecoder :
    public QIODevice
{
    Q_OBJECT
public:
    enum State { Decoding, Stopped };
    explicit AudioDecoder(QObject *parent = 0);
    ~AudioDecoder();

    bool atEnd() const override;

public slots:
    void init(const QAudioFormat &format);
    void start(const QString &filePath);
    void stop();

protected:
    qint64 readData(char* data, qint64 maxlen) override;
    qint64 writeData(const char* data, qint64 len) override;

private:
    State m_state;
    QPointer<QAudioDecoder> m_decoder;
    QBuffer m_input;
    QBuffer m_output;
    QByteArray m_data;
    bool m_init;
    bool m_isDecodingFinished;

private slots:
    void bufferReady();
    void finished();
    void errored(QAudioDecoder::Error);

signals:
    void initialized();
    void newData(const QByteArray& data);
};

#endif // AUDIODECODER_H