Chris@1583
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@1583
|
2
|
Chris@1583
|
3 /*
|
Chris@1583
|
4 Sonic Visualiser
|
Chris@1583
|
5 An audio file viewer and annotation editor.
|
Chris@1583
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@1583
|
7
|
Chris@1583
|
8 This program is free software; you can redistribute it and/or
|
Chris@1583
|
9 modify it under the terms of the GNU General Public License as
|
Chris@1583
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@1583
|
11 License, or (at your option) any later version. See the file
|
Chris@1583
|
12 COPYING included with this distribution for more information.
|
Chris@1583
|
13 */
|
Chris@1583
|
14
|
Chris@1583
|
15 #ifndef SV_BQA_FILE_READER_H
|
Chris@1583
|
16 #define SV_BQA_FILE_READER_H
|
Chris@1583
|
17
|
Chris@1583
|
18 #include <bqaudiostream/AudioReadStreamFactory.h>
|
Chris@1583
|
19
|
Chris@1583
|
20 #include "CodedAudioFileReader.h"
|
Chris@1583
|
21 #include "base/Thread.h"
|
Chris@1583
|
22
|
Chris@1583
|
23 #include <set>
|
Chris@1858
|
24 #include <atomic>
|
Chris@1583
|
25
|
Chris@1583
|
26 class ProgressReporter;
|
Chris@1583
|
27
|
Chris@1583
|
28 /**
|
Chris@1583
|
29 * Audio file reader using bqaudiostream library AudioReadStream
|
Chris@1583
|
30 * classes.
|
Chris@1583
|
31 */
|
Chris@1583
|
32 class BQAFileReader : public CodedAudioFileReader
|
Chris@1583
|
33 {
|
Chris@1583
|
34 Q_OBJECT
|
Chris@1583
|
35
|
Chris@1583
|
36 public:
|
Chris@1583
|
37 BQAFileReader(FileSource source,
|
Chris@1583
|
38 DecodeMode decodeMode,
|
Chris@1583
|
39 CacheMode cacheMode,
|
Chris@1583
|
40 sv_samplerate_t targetRate = 0,
|
Chris@1583
|
41 bool normalised = false,
|
Chris@1583
|
42 ProgressReporter *reporter = 0);
|
Chris@1583
|
43 virtual ~BQAFileReader();
|
Chris@1583
|
44
|
Chris@1587
|
45 QString getError() const override { return m_error; }
|
Chris@1587
|
46 QString getLocation() const override { return m_source.getLocation(); }
|
Chris@1587
|
47 QString getTitle() const override { return m_title; }
|
Chris@1587
|
48 QString getMaker() const override { return m_maker; }
|
Chris@1583
|
49
|
Chris@1583
|
50 static void getSupportedExtensions(std::set<QString> &extensions);
|
Chris@1583
|
51 static bool supportsExtension(QString ext);
|
Chris@1583
|
52 static bool supportsContentType(QString type);
|
Chris@1583
|
53 static bool supports(FileSource &source);
|
Chris@1583
|
54
|
Chris@1587
|
55 int getDecodeCompletion() const override { return m_completion; }
|
Chris@1583
|
56
|
Chris@1587
|
57 bool isUpdating() const override {
|
Chris@1583
|
58 return m_decodeThread && m_decodeThread->isRunning();
|
Chris@1583
|
59 }
|
Chris@1583
|
60
|
Chris@1583
|
61 public slots:
|
Chris@1583
|
62 void cancelled();
|
Chris@1583
|
63
|
Chris@1583
|
64 protected:
|
Chris@1583
|
65 FileSource m_source;
|
Chris@1583
|
66 QString m_path;
|
Chris@1583
|
67 QString m_error;
|
Chris@1583
|
68 QString m_title;
|
Chris@1583
|
69 QString m_maker;
|
Chris@1583
|
70
|
Chris@1583
|
71 breakfastquay::AudioReadStream *m_stream;
|
Chris@1583
|
72
|
Chris@1858
|
73 std::atomic<bool> m_cancelled;
|
Chris@1583
|
74 int m_completion;
|
Chris@1583
|
75 ProgressReporter *m_reporter;
|
Chris@1583
|
76
|
Chris@1583
|
77 class DecodeThread : public Thread {
|
Chris@1583
|
78 public:
|
Chris@1583
|
79 DecodeThread(BQAFileReader *reader) : m_reader(reader) { }
|
Chris@1583
|
80 virtual void run();
|
Chris@1583
|
81 protected:
|
Chris@1583
|
82 BQAFileReader *m_reader;
|
Chris@1583
|
83 };
|
Chris@1583
|
84 DecodeThread *m_decodeThread;
|
Chris@1583
|
85 };
|
Chris@1583
|
86
|
Chris@1583
|
87 #endif
|
Chris@1583
|
88
|