Mixxx
|
00001 00007 /*************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #ifndef SOUNDMANAGERCONFIG_H 00017 #define SOUNDMANAGERCONFIG_H 00018 00019 #ifndef SOUNDMANAGERCONFIG_FILENAME 00020 #define SOUNDMANAGERCONFIG_FILENAME "soundconfig.xml" 00021 #endif 00022 00023 #include <QtCore> 00024 00025 #include "soundmanagerutil.h" 00026 00027 class SoundDevice; 00028 class SoundManager; 00029 00030 class SoundManagerConfig { 00031 public: 00032 enum Defaults { 00033 API = (1 << 0), 00034 DEVICES = (1 << 1), 00035 OTHER = (1 << 2), 00036 ALL = (API | DEVICES | OTHER), 00037 }; 00038 static const unsigned int kMaxLatency; 00039 static const QString kDefaultAPI; 00040 static const unsigned int kDefaultSampleRate; 00041 static const int kDefaultLatency; 00042 00043 SoundManagerConfig(); 00044 ~SoundManagerConfig(); 00045 bool readFromDisk(); 00046 bool writeToDisk() const; 00047 QString getAPI() const; 00048 void setAPI(const QString &api); 00049 bool checkAPI(const SoundManager &soundManager); 00050 unsigned int getSampleRate() const; 00051 void setSampleRate(unsigned int sampleRate); 00052 bool checkSampleRate(const SoundManager &soundManager); 00053 unsigned int getLatency() const; 00054 unsigned int getFramesPerBuffer() const; 00055 void setLatency(unsigned int latency); 00056 void addOutput(const QString &device, const AudioOutput &out); 00057 void addInput(const QString &device, const AudioInput &in); 00058 QMultiHash<QString, AudioOutput> getOutputs() const; 00059 QMultiHash<QString, AudioInput> getInputs() const; 00060 void clearOutputs(); 00061 void clearInputs(); 00062 // I'd prefer for these to be const but SoundManager::getDeviceList isn't 00063 void filterOutputs(SoundManager *soundManager); 00064 void filterInputs(SoundManager *soundManager); 00065 void loadDefaults(SoundManager *soundManager, unsigned int flags); 00066 private: 00067 QFileInfo m_configFile; 00068 QString m_api; 00069 // none of our sample rates are actually decimals, this avoids 00070 // the weirdness using floating point can introduce 00071 unsigned int m_sampleRate; 00072 // m_latency is an index > 0, where 1 is a latency of 1ms and 00073 // higher indices represent subsequently higher latencies (storing 00074 // latency as milliseconds or frames per buffer is bad because those 00075 // values vary with sample rate) -- bkgood 00076 unsigned int m_latency; 00077 QMultiHash<QString, AudioOutput> m_outputs; 00078 QMultiHash<QString, AudioInput> m_inputs; 00079 }; 00080 #endif