summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-01-29 15:36:30 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-01-29 22:55:18 +0100
commit0ae49c2719b9b2cceab33ad1c6b44873b38e71b1 (patch)
tree4d59e9752258981fd6d3c5d98a2b9ddfdc52a12a /rbutil/rbutilqt
parent933a67489111ed8372f29cc213e2399465592c19 (diff)
downloadrockbox-0ae49c2719b9b2cceab33ad1c6b44873b38e71b1.tar.gz
rockbox-0ae49c2719b9b2cceab33ad1c6b44873b38e71b1.zip
Separate default quality setting for encoders.
Instead of having a global quality setting for the encoder make the encoder provide its default value by itself. Fixes the libmp3lame encoder using an unsuitable value since the range differs greatly between the encoders. Centralize reading the configuration values for rbspeex. The values are stored in member variables, so it's not necessary to read them multiple times. Change-Id: Ia26cb1fc3bb4f927d13212fe7883bdfe2571a711
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/encoderrbspeex.cpp49
-rw-r--r--rbutil/rbutilqt/base/encoderrbspeex.h1
-rw-r--r--rbutil/rbutilqt/base/rbsettings.cpp2
3 files changed, 28 insertions, 24 deletions
diff --git a/rbutil/rbutilqt/base/encoderrbspeex.cpp b/rbutil/rbutilqt/base/encoderrbspeex.cpp
index 2d57082aa6..b5b516ec87 100644
--- a/rbutil/rbutilqt/base/encoderrbspeex.cpp
+++ b/rbutil/rbutilqt/base/encoderrbspeex.cpp
@@ -28,14 +28,15 @@ EncoderRbSpeex::EncoderRbSpeex(QObject *parent) : EncoderBase(parent)
void EncoderRbSpeex::generateSettings()
{
- insertSetting(eVOLUME,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,
- tr("Volume:"),RbSettings::subValue("rbspeex",RbSettings::EncoderVolume),1.0,10.0));
- insertSetting(eQUALITY,new EncTtsSetting(this,EncTtsSetting::eDOUBLE,
- tr("Quality:"),RbSettings::subValue("rbspeex",RbSettings::EncoderQuality),0,10.0));
- insertSetting(eCOMPLEXITY,new EncTtsSetting(this,EncTtsSetting::eINT,
- tr("Complexity:"),RbSettings::subValue("rbspeex",RbSettings::EncoderComplexity),0,10));
- insertSetting(eNARROWBAND,new EncTtsSetting(this,EncTtsSetting::eBOOL,
- tr("Use Narrowband:"),RbSettings::subValue("rbspeex",RbSettings::EncoderNarrowBand)));
+ loadSettings();
+ insertSetting(eVOLUME, new EncTtsSetting(this, EncTtsSetting::eDOUBLE,
+ tr("Volume:"), volume, 1.0, 10.0));
+ insertSetting(eQUALITY, new EncTtsSetting(this, EncTtsSetting::eDOUBLE,
+ tr("Quality:"), quality, 0, 10.0));
+ insertSetting(eCOMPLEXITY, new EncTtsSetting(this, EncTtsSetting::eINT,
+ tr("Complexity:"), complexity, 0, 10));
+ insertSetting(eNARROWBAND,new EncTtsSetting(this, EncTtsSetting::eBOOL,
+ tr("Use Narrowband:"), narrowband));
}
void EncoderRbSpeex::saveSettings()
@@ -53,16 +54,25 @@ void EncoderRbSpeex::saveSettings()
RbSettings::sync();
}
-bool EncoderRbSpeex::start()
-{
+void EncoderRbSpeex::loadSettings(void)
+{
// try to get config from settings
quality = RbSettings::subValue("rbspeex", RbSettings::EncoderQuality).toDouble();
+ if(quality < 0) {
+ quality = 8.0;
+ }
complexity = RbSettings::subValue("rbspeex", RbSettings::EncoderComplexity).toInt();
volume = RbSettings::subValue("rbspeex", RbSettings::EncoderVolume).toDouble();
narrowband = RbSettings::subValue("rbspeex", RbSettings::EncoderNarrowBand).toBool();
+}
+bool EncoderRbSpeex::start()
+{
+
+ // make sure configuration parameters are set.
+ loadSettings();
return true;
}
@@ -98,18 +108,11 @@ bool EncoderRbSpeex::encode(QString input,QString output)
bool EncoderRbSpeex::configOk()
{
- bool result=true;
- // check config
-
- if(RbSettings::subValue("rbspeex", RbSettings::EncoderVolume).toDouble() <= 0)
- result =false;
-
- if(RbSettings::subValue("rbspeex", RbSettings::EncoderQuality).toDouble() <= 0)
- result =false;
-
- if(RbSettings::subValue("rbspeex", RbSettings::EncoderComplexity).toInt() <= 0)
- result =false;
-
- return result;
+ // check config. Make sure current settings are loaded.
+ loadSettings();
+ if(volume <= 0 || quality <= 0 || complexity <= 0)
+ return false;
+ else
+ return true;
}
diff --git a/rbutil/rbutilqt/base/encoderrbspeex.h b/rbutil/rbutilqt/base/encoderrbspeex.h
index 9f51d8e264..b3028b3250 100644
--- a/rbutil/rbutilqt/base/encoderrbspeex.h
+++ b/rbutil/rbutilqt/base/encoderrbspeex.h
@@ -45,6 +45,7 @@ class EncoderRbSpeex : public EncoderBase
void saveSettings();
private:
+ void loadSettings(void);
float quality;
float volume;
int complexity;
diff --git a/rbutil/rbutilqt/base/rbsettings.cpp b/rbutil/rbutilqt/base/rbsettings.cpp
index e7e47af7b4..a74b167e92 100644
--- a/rbutil/rbutilqt/base/rbsettings.cpp
+++ b/rbutil/rbutilqt/base/rbsettings.cpp
@@ -64,7 +64,7 @@ const static struct {
{ RbSettings::WavtrimThreshold, "wavtrimthreshold", "500"},
{ RbSettings::TtsSpeed, ":tts:/speed", "175" },
{ RbSettings::EncoderComplexity, ":encoder:/complexity", "10" },
- { RbSettings::EncoderQuality, ":encoder:/quality", "8.0" },
+ { RbSettings::EncoderQuality, ":encoder:/quality", "-1.0" },
{ RbSettings::EncoderVolume, ":encoder:/volume", "1.0" },
};