svcore  1.9
CoreAudioFileReader.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  This file copyright 2006-2012 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _COREAUDIO_FILE_READER_H_
17 #define _COREAUDIO_FILE_READER_H_
18 
19 #ifdef HAVE_COREAUDIO
20 
21 #include "CodedAudioFileReader.h"
22 
23 #include "base/Thread.h"
24 
25 #include <set>
26 
27 class ProgressReporter;
28 
29 class CoreAudioFileReader : public CodedAudioFileReader
30 {
31  Q_OBJECT
32 
33 public:
34  enum DecodeMode {
35  DecodeAtOnce, // decode the file on construction, with progress
36  DecodeThreaded // decode in a background thread after construction
37  };
38 
39  CoreAudioFileReader(FileSource source,
40  DecodeMode decodeMode,
41  CacheMode cacheMode,
42  int targetRate = 0,
43  bool normalised = false,
44  ProgressReporter *reporter = 0);
45  virtual ~CoreAudioFileReader();
46 
47  virtual QString getError() const { return m_error; }
48  virtual QString getLocation() const { return m_source.getLocation(); }
49  virtual QString getTitle() const { return m_title; }
50 
51  static void getSupportedExtensions(std::set<QString> &extensions);
52  static bool supportsExtension(QString ext);
53  static bool supportsContentType(QString type);
54  static bool supports(FileSource &source);
55 
56  virtual int getDecodeCompletion() const { return m_completion; }
57 
58  virtual bool isUpdating() const {
59  return m_decodeThread && m_decodeThread->isRunning();
60  }
61 
62 public slots:
63  void cancelled();
64 
65 protected:
66  FileSource m_source;
67  QString m_path;
68  QString m_error;
69  QString m_title;
70 
71  class D;
72  D *m_d;
73 
74  ProgressReporter *m_reporter;
75  bool m_cancelled;
76  int m_completion;
77 
78  class DecodeThread : public Thread
79  {
80  public:
81  // DecodeThread(QuickTimeFileReader *reader) : m_reader(reader) { }
82  virtual void run();
83 
84  protected:
85  // QuickTimeFileReader *m_reader;
86  };
87 
88  DecodeThread *m_decodeThread;
89 };
90 
91 #endif
92 
93 #endif
virtual QString getError() const
virtual QString getLocation() const
Return the location of the audio data in the reader (as passed in to the FileSource constructor,...
virtual int getDecodeCompletion() const
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
Definition: Thread.h:24
virtual bool isUpdating() const
virtual QString getTitle() const
Return the title of the work in the audio file, if known.