00001
00002
00003
00004
00005
00006
00007
00008 #include "audiosettings.h"
00009
00010
00011 AudioSettings::AudioSettings() :
00012 main_device(QString::null),
00013 passthru_device(QString::null),
00014 format(FORMAT_NONE),
00015 channels(-1),
00016 codec(0),
00017 codec_profile(-1),
00018 samplerate(-1),
00019 set_initial_vol(false),
00020 use_passthru(false),
00021 source(AUDIOOUTPUT_UNKNOWN),
00022 upmixer(0),
00023 init(false),
00024 custom(NULL)
00025 {
00026 }
00027
00028 AudioSettings::AudioSettings(const AudioSettings &other) :
00029 main_device(other.main_device),
00030 passthru_device(other.passthru_device),
00031 format(other.format),
00032 channels(other.channels),
00033 codec(other.codec),
00034 codec_profile(other.codec_profile),
00035 samplerate(other.samplerate),
00036 set_initial_vol(other.set_initial_vol),
00037 use_passthru(other.use_passthru),
00038 source(other.source),
00039 upmixer(other.upmixer),
00040 init(true)
00041 {
00042 if (other.custom)
00043 {
00044
00045 custom = new AudioOutputSettings;
00046 *custom = *other.custom;
00047 }
00048 else
00049 custom = NULL;
00050 }
00051
00052 AudioSettings::AudioSettings(
00053 const QString &main_device,
00054 const QString &passthru_device,
00055 AudioFormat format,
00056 int channels,
00057 int codec,
00058 int samplerate,
00059 AudioOutputSource source,
00060 bool set_initial_vol,
00061 bool use_passthru,
00062 int upmixer_startup,
00063 AudioOutputSettings *custom) :
00064 main_device(main_device),
00065 passthru_device(passthru_device),
00066 format(format),
00067 channels(channels),
00068 codec(codec),
00069 codec_profile(-1),
00070 samplerate(samplerate),
00071 set_initial_vol(set_initial_vol),
00072 use_passthru(use_passthru),
00073 source(source),
00074 upmixer(upmixer_startup),
00075 init(true)
00076 {
00077 if (custom)
00078 {
00079
00080 this->custom = new AudioOutputSettings;
00081 *this->custom = *custom;
00082 }
00083 else
00084 this->custom = NULL;
00085 }
00086
00087 AudioSettings::AudioSettings(
00088 AudioFormat format,
00089 int channels,
00090 int codec,
00091 int samplerate,
00092 bool use_passthru,
00093 int upmixer_startup,
00094 int codec_profile) :
00095 main_device(QString::null),
00096 passthru_device(QString::null),
00097 format(format),
00098 channels(channels),
00099 codec(codec),
00100 codec_profile(codec_profile),
00101 samplerate(samplerate),
00102 set_initial_vol(false),
00103 use_passthru(use_passthru),
00104 source(AUDIOOUTPUT_UNKNOWN),
00105 upmixer(upmixer_startup),
00106 init(true),
00107 custom(NULL)
00108 {
00109 }
00110
00111 AudioSettings::AudioSettings(
00112 const QString &main_device,
00113 const QString &passthru_device) :
00114 main_device(main_device),
00115 passthru_device(passthru_device),
00116 format(FORMAT_NONE),
00117 channels(-1),
00118 codec(0),
00119 codec_profile(-1),
00120 samplerate(-1),
00121 set_initial_vol(false),
00122 use_passthru(false),
00123 source(AUDIOOUTPUT_UNKNOWN),
00124 upmixer(0),
00125 init(false),
00126 custom(NULL)
00127 {
00128 }
00129
00130 AudioSettings::~AudioSettings()
00131 {
00132 if (custom)
00133 delete custom;
00134 }
00135
00136 void AudioSettings::FixPassThrough(void)
00137 {
00138 if (passthru_device.isEmpty())
00139 passthru_device = "auto";
00140 }
00141
00142 void AudioSettings::TrimDeviceType(void)
00143 {
00144 main_device.remove(0, 5);
00145 if (passthru_device != "auto" && passthru_device.toLower() != "default")
00146 passthru_device.remove(0, 5);
00147 }
00148
00149 QString AudioSettings::GetMainDevice(void) const
00150 {
00151 QString ret = main_device;
00152 ret.detach();
00153 return ret;
00154 }
00155
00156 QString AudioSettings::GetPassthruDevice(void) const
00157 {
00158 QString ret = passthru_device;
00159 ret.detach();
00160 return ret;
00161 }