annotate data/fileio/BQAFileReader.h @ 1583:c8fad3c14a2b bqaudiostream

Start wiring in BQAudioStream stuff
author Chris Cannam
date Thu, 06 Dec 2018 12:50:28 +0000
parents
children b67f5b6a7978
rev   line source
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@1583 24
Chris@1583 25 class ProgressReporter;
Chris@1583 26
Chris@1583 27 /**
Chris@1583 28 * Audio file reader using bqaudiostream library AudioReadStream
Chris@1583 29 * classes.
Chris@1583 30 */
Chris@1583 31 class BQAFileReader : public CodedAudioFileReader
Chris@1583 32 {
Chris@1583 33 Q_OBJECT
Chris@1583 34
Chris@1583 35 public:
Chris@1583 36 BQAFileReader(FileSource source,
Chris@1583 37 DecodeMode decodeMode,
Chris@1583 38 CacheMode cacheMode,
Chris@1583 39 sv_samplerate_t targetRate = 0,
Chris@1583 40 bool normalised = false,
Chris@1583 41 ProgressReporter *reporter = 0);
Chris@1583 42 virtual ~BQAFileReader();
Chris@1583 43
Chris@1583 44 virtual QString getError() const { return m_error; }
Chris@1583 45 virtual QString getLocation() const { return m_source.getLocation(); }
Chris@1583 46 virtual QString getTitle() const { return m_title; }
Chris@1583 47 virtual QString getMaker() const { return m_maker; }
Chris@1583 48 virtual TagMap getTags() const { return m_tags; }
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@1583 55 virtual int getDecodeCompletion() const { return m_completion; }
Chris@1583 56
Chris@1583 57 virtual bool isUpdating() const {
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 TagMap m_tags;
Chris@1583 71
Chris@1583 72 breakfastquay::AudioReadStream *m_stream;
Chris@1583 73
Chris@1583 74 bool m_cancelled;
Chris@1583 75 int m_completion;
Chris@1583 76 ProgressReporter *m_reporter;
Chris@1583 77
Chris@1583 78 class DecodeThread : public Thread {
Chris@1583 79 public:
Chris@1583 80 DecodeThread(BQAFileReader *reader) : m_reader(reader) { }
Chris@1583 81 virtual void run();
Chris@1583 82 protected:
Chris@1583 83 BQAFileReader *m_reader;
Chris@1583 84 };
Chris@1583 85 DecodeThread *m_decodeThread;
Chris@1583 86 };
Chris@1583 87
Chris@1583 88 #endif
Chris@1583 89