mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 05:35:20 -05:00
Make encoder name conversion functions static to the base class.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16305 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
22a5c60af3
commit
8f0c7908b0
7 changed files with 42 additions and 44 deletions
|
|
@ -289,9 +289,9 @@ void Config::setDevices()
|
||||||
|
|
||||||
//encoders
|
//encoders
|
||||||
int index;
|
int index;
|
||||||
QStringList encoders = getEncoderList();
|
QStringList encoders = EncBase::getEncoderList();
|
||||||
for(int a = 0; a < encoders.size(); a++)
|
for(int a = 0; a < encoders.size(); a++)
|
||||||
ui.comboEncoder->addItem(getEncoderName(encoders.at(a)), encoders.at(a));
|
ui.comboEncoder->addItem(EncBase::getEncoderName(encoders.at(a)), encoders.at(a));
|
||||||
//update index of combobox
|
//update index of combobox
|
||||||
index = ui.comboEncoder->findData(settings->curEncoder());
|
index = ui.comboEncoder->findData(settings->curEncoder());
|
||||||
if(index < 0) index = 0;
|
if(index < 0) index = 0;
|
||||||
|
|
@ -332,7 +332,7 @@ void Config::updateTtsState(int index)
|
||||||
void Config::updateEncState(int index)
|
void Config::updateEncState(int index)
|
||||||
{
|
{
|
||||||
QString encoder = ui.comboEncoder->itemData(index).toString();
|
QString encoder = ui.comboEncoder->itemData(index).toString();
|
||||||
EncBase* enc = getEncoder(encoder);
|
EncBase* enc = EncBase::getEncoder(encoder);
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
|
|
||||||
if(enc->configOk())
|
if(enc->configOk())
|
||||||
|
|
@ -599,7 +599,7 @@ void Config::configTts()
|
||||||
void Config::configEnc()
|
void Config::configEnc()
|
||||||
{
|
{
|
||||||
int index = ui.comboEncoder->currentIndex();
|
int index = ui.comboEncoder->currentIndex();
|
||||||
EncBase* enc = getEncoder(ui.comboEncoder->itemData(index).toString());
|
EncBase* enc = EncBase::getEncoder(ui.comboEncoder->itemData(index).toString());
|
||||||
|
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
enc->showCfg();
|
enc->showCfg();
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,11 @@ void CreateVoiceWindow::setSettings(RbSettings* sett)
|
||||||
|
|
||||||
QString encoder = settings->curEncoder();
|
QString encoder = settings->curEncoder();
|
||||||
// only proceed if encoder setting is set
|
// only proceed if encoder setting is set
|
||||||
EncBase* enc = getEncoder(encoder);
|
EncBase* enc = EncBase::getEncoder(encoder);
|
||||||
if(enc != NULL) {
|
if(enc != NULL) {
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
if(enc->configOk())
|
if(enc->configOk())
|
||||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(getEncoderName(encoder)));
|
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder)));
|
||||||
else
|
else
|
||||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,13 @@
|
||||||
#include "encodersguicli.h"
|
#include "encodersguicli.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QMap<QString,QString> encoderList;
|
|
||||||
static QMap<QString,EncBase*> encoderCache;
|
QMap<QString,QString> EncBase::encoderList;
|
||||||
|
QMap<QString,EncBase*> EncBase::encoderCache;
|
||||||
|
|
||||||
|
|
||||||
// initialize list of encoders
|
// initialize list of encoders
|
||||||
void initEncodernamesList()
|
void EncBase::initEncodernamesList()
|
||||||
{
|
{
|
||||||
encoderList["rbspeex"] = "Rockbox Speex Encoder";
|
encoderList["rbspeex"] = "Rockbox Speex Encoder";
|
||||||
encoderList["lame"] = "Lame Mp3 Encoder";
|
encoderList["lame"] = "Lame Mp3 Encoder";
|
||||||
|
|
@ -39,7 +40,7 @@ void initEncodernamesList()
|
||||||
|
|
||||||
|
|
||||||
// get nice name for a specific encoder
|
// get nice name for a specific encoder
|
||||||
QString getEncoderName(QString encoder)
|
QString EncBase::getEncoderName(QString encoder)
|
||||||
{
|
{
|
||||||
if(encoderList.isEmpty())
|
if(encoderList.isEmpty())
|
||||||
initEncodernamesList();
|
initEncodernamesList();
|
||||||
|
|
@ -48,7 +49,7 @@ QString getEncoderName(QString encoder)
|
||||||
|
|
||||||
|
|
||||||
// get a specific encoder object
|
// get a specific encoder object
|
||||||
EncBase* getEncoder(QString encoder)
|
EncBase* EncBase::getEncoder(QString encoder)
|
||||||
{
|
{
|
||||||
// check cache
|
// check cache
|
||||||
if(encoderCache.contains(encoder))
|
if(encoderCache.contains(encoder))
|
||||||
|
|
@ -70,7 +71,7 @@ EncBase* getEncoder(QString encoder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList getEncoderList()
|
QStringList EncBase::getEncoderList()
|
||||||
{
|
{
|
||||||
if(encoderList.isEmpty())
|
if(encoderList.isEmpty())
|
||||||
initEncodernamesList();
|
initEncodernamesList();
|
||||||
|
|
|
||||||
|
|
@ -29,40 +29,37 @@ extern "C"
|
||||||
#include "rbspeex.h"
|
#include "rbspeex.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
class EncBase;
|
|
||||||
|
|
||||||
//inits the encoder List
|
|
||||||
void initEncodernamesList(void);
|
|
||||||
// function to get a specific encoder
|
|
||||||
EncBase* getEncoder(QString encname);
|
|
||||||
// get the list of encoders, nice names
|
|
||||||
QString getEncoderName(QString encoder);
|
|
||||||
QStringList getEncoderList(void);
|
|
||||||
|
|
||||||
|
|
||||||
class EncBase : public QObject
|
class EncBase : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EncBase(QObject *parent );
|
EncBase(QObject *parent );
|
||||||
|
|
||||||
virtual bool encode(QString input,QString output)
|
|
||||||
{(void)input; (void)output; return false;}
|
|
||||||
virtual bool start(){return false;}
|
|
||||||
virtual bool stop(){return false;}
|
|
||||||
virtual void showCfg(){}
|
|
||||||
virtual bool configOk(){return false;}
|
|
||||||
|
|
||||||
void setCfg(RbSettings *sett){settings = sett;}
|
virtual bool encode(QString input,QString output)
|
||||||
|
{(void)input; (void)output; return false;}
|
||||||
public slots:
|
virtual bool start(){return false;}
|
||||||
virtual void accept(void){}
|
virtual bool stop(){return false;}
|
||||||
virtual void reject(void){}
|
virtual void showCfg(){}
|
||||||
virtual void reset(void){}
|
virtual bool configOk(){return false;}
|
||||||
|
|
||||||
protected:
|
void setCfg(RbSettings *sett){settings = sett;}
|
||||||
|
static QString getEncoderName(QString);
|
||||||
RbSettings* settings;
|
static EncBase* getEncoder(QString);
|
||||||
|
static QStringList getEncoderList(void);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void accept(void){}
|
||||||
|
virtual void reject(void){}
|
||||||
|
virtual void reset(void){}
|
||||||
|
private:
|
||||||
|
static void initEncodernamesList(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RbSettings* settings;
|
||||||
|
|
||||||
|
static QMap<QString,QString> encoderList;
|
||||||
|
static QMap<QString,EncBase*> encoderCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@ void InstallTalkWindow::setSettings(RbSettings* sett)
|
||||||
ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
|
ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
|
||||||
|
|
||||||
QString encoder = settings->curEncoder();
|
QString encoder = settings->curEncoder();
|
||||||
EncBase* enc = getEncoder(encoder);
|
EncBase* enc = EncBase::getEncoder(encoder);
|
||||||
if(enc != NULL) {
|
if(enc != NULL) {
|
||||||
enc->setCfg(settings);
|
enc->setCfg(settings);
|
||||||
if(enc->configOk())
|
if(enc->configOk())
|
||||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(getEncoderName(encoder)));
|
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder)));
|
||||||
else
|
else
|
||||||
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoder
|
// Encoder
|
||||||
m_enc = getEncoder(settings->curEncoder());
|
m_enc = EncBase::getEncoder(settings->curEncoder());
|
||||||
m_enc->setCfg(settings);
|
m_enc->setCfg(settings);
|
||||||
|
|
||||||
if(!m_enc->start())
|
if(!m_enc->start())
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoder
|
// Encoder
|
||||||
m_enc = getEncoder(settings->curEncoder());
|
m_enc = EncBase::getEncoder(settings->curEncoder());
|
||||||
m_enc->setCfg(settings);
|
m_enc->setCfg(settings);
|
||||||
|
|
||||||
if(!m_enc->start())
|
if(!m_enc->start())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue