svcore  1.9
CoreAudioFileReader.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006-2012 Chris Cannam and QMUL.
00008 
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _COREAUDIO_FILE_READER_H_
00017 #define _COREAUDIO_FILE_READER_H_
00018 
00019 #ifdef HAVE_COREAUDIO
00020 
00021 #include "CodedAudioFileReader.h"
00022 
00023 #include "base/Thread.h"
00024 
00025 #include <set>
00026 
00027 class ProgressReporter;
00028 
00029 class CoreAudioFileReader : public CodedAudioFileReader
00030 {
00031     Q_OBJECT
00032 
00033 public:
00034     enum DecodeMode {
00035         DecodeAtOnce, // decode the file on construction, with progress
00036         DecodeThreaded // decode in a background thread after construction
00037     };
00038 
00039     CoreAudioFileReader(FileSource source,
00040                         DecodeMode decodeMode,
00041                         CacheMode cacheMode,
00042                         int targetRate = 0,
00043                         bool normalised = false,
00044                         ProgressReporter *reporter = 0);
00045     virtual ~CoreAudioFileReader();
00046 
00047     virtual QString getError() const { return m_error; }
00048     virtual QString getLocation() const { return m_source.getLocation(); }
00049     virtual QString getTitle() const { return m_title; }
00050     
00051     static void getSupportedExtensions(std::set<QString> &extensions);
00052     static bool supportsExtension(QString ext);
00053     static bool supportsContentType(QString type);
00054     static bool supports(FileSource &source);
00055 
00056     virtual int getDecodeCompletion() const { return m_completion; }
00057 
00058     virtual bool isUpdating() const {
00059         return m_decodeThread && m_decodeThread->isRunning();
00060     }
00061 
00062 public slots:
00063     void cancelled();
00064 
00065 protected:
00066     FileSource m_source;
00067     QString m_path;
00068     QString m_error;
00069     QString m_title;
00070 
00071     class D;
00072     D *m_d;
00073 
00074     ProgressReporter *m_reporter;
00075     bool m_cancelled;
00076     int m_completion;
00077 
00078     class DecodeThread : public Thread
00079     {
00080     public:
00081        // DecodeThread(QuickTimeFileReader *reader) : m_reader(reader) { }
00082         virtual void run();
00083 
00084     protected:
00085        // QuickTimeFileReader *m_reader;
00086     };
00087 
00088     DecodeThread *m_decodeThread;
00089 };
00090 
00091 #endif
00092 
00093 #endif