BQAFileReader.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 #ifndef SV_BQA_FILE_READER_H
16 #define SV_BQA_FILE_READER_H
17 
18 #include <bqaudiostream/AudioReadStreamFactory.h>
19 
20 #include "CodedAudioFileReader.h"
21 #include "base/Thread.h"
22 
23 #include <set>
24 #include <atomic>
25 
26 class ProgressReporter;
27 
33 {
34  Q_OBJECT
35 
36 public:
38  DecodeMode decodeMode,
39  CacheMode cacheMode,
40  sv_samplerate_t targetRate = 0,
41  bool normalised = false,
42  ProgressReporter *reporter = 0);
43  virtual ~BQAFileReader();
44 
45  QString getError() const override { return m_error; }
46  QString getLocation() const override { return m_source.getLocation(); }
47  QString getTitle() const override { return m_title; }
48  QString getMaker() const override { return m_maker; }
49 
50  static void getSupportedExtensions(std::set<QString> &extensions);
51  static bool supportsExtension(QString ext);
52  static bool supportsContentType(QString type);
53  static bool supports(FileSource &source);
54 
55  int getDecodeCompletion() const override { return m_completion; }
56 
57  bool isUpdating() const override {
58  return m_decodeThread && m_decodeThread->isRunning();
59  }
60 
61 public slots:
62  void cancelled();
63 
64 protected:
66  QString m_path;
67  QString m_error;
68  QString m_title;
69  QString m_maker;
70 
71  breakfastquay::AudioReadStream *m_stream;
72 
73  std::atomic<bool> m_cancelled;
76 
77  class DecodeThread : public Thread {
78  public:
79  DecodeThread(BQAFileReader *reader) : m_reader(reader) { }
80  virtual void run();
81  protected:
83  };
85 };
86 
87 #endif
88 
QString m_title
Definition: BQAFileReader.h:68
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
DecodeThread(BQAFileReader *reader)
Definition: BQAFileReader.h:79
QString m_maker
Definition: BQAFileReader.h:69
bool isUpdating() const override
Return true if decoding is still in progress and the frame count may change.
Definition: BQAFileReader.h:57
std::atomic< bool > m_cancelled
Definition: BQAFileReader.h:73
static bool supports(FileSource &source)
QString getLocation() const
Return the location filename or URL as passed to the constructor.
Definition: FileSource.cpp:616
static void getSupportedExtensions(std::set< QString > &extensions)
static bool supportsExtension(QString ext)
QString getError() const override
If isOK() is false, return an error string.
Definition: BQAFileReader.h:45
QString getLocation() const override
Return the location of the audio data in the reader (as passed in to the FileSource constructor...
Definition: BQAFileReader.h:46
QString getMaker() const override
Return the "maker" of the work in the audio file, if known.
Definition: BQAFileReader.h:48
ProgressReporter * m_reporter
Definition: BQAFileReader.h:75
int getDecodeCompletion() const override
Return a percentage value indicating how far through decoding the audio file we are.
Definition: BQAFileReader.h:55
BQAFileReader(FileSource source, DecodeMode decodeMode, CacheMode cacheMode, sv_samplerate_t targetRate=0, bool normalised=false, ProgressReporter *reporter=0)
FileSource m_source
Definition: BQAFileReader.h:65
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
Definition: FileSource.h:59
virtual ~BQAFileReader()
QString m_path
Definition: BQAFileReader.h:66
QString getTitle() const override
Return the title of the work in the audio file, if known.
Definition: BQAFileReader.h:47
breakfastquay::AudioReadStream * m_stream
Definition: BQAFileReader.h:71
Audio file reader using bqaudiostream library AudioReadStream classes.
Definition: BQAFileReader.h:32
Definition: Thread.h:24
DecodeThread * m_decodeThread
Definition: BQAFileReader.h:84
static bool supportsContentType(QString type)
QString m_error
Definition: BQAFileReader.h:67