mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-20 10:32:42 -05:00
rbutil: Command line fallback on libmp3lame failure.
When loading libmp3lame fails fall back to using the command line lame. Avoids an unresolvable error when trying to create voice / talk files for Archos. Modernize code a bit. Change-Id: I2e8fd5786fda972cb24adbcb9ced531e08093b4f
This commit is contained in:
parent
bb7aa6f311
commit
07604d62ab
3 changed files with 22 additions and 10 deletions
|
|
@ -23,6 +23,8 @@
|
||||||
#include "encoderlame.h"
|
#include "encoderlame.h"
|
||||||
#include "encoderexe.h"
|
#include "encoderexe.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* Encoder Base
|
* Encoder Base
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
@ -61,6 +63,14 @@ EncoderBase* EncoderBase::getEncoder(QObject* parent,QString encoder)
|
||||||
enc = new EncoderExe(encoder, parent);
|
enc = new EncoderExe(encoder, parent);
|
||||||
#else
|
#else
|
||||||
enc = new EncoderLame(parent);
|
enc = new EncoderLame(parent);
|
||||||
|
if (!enc->configOk())
|
||||||
|
{
|
||||||
|
LOG_WARNING() << "Could not load lame dll, falling back to command "
|
||||||
|
"line lame. This is notably slower.";
|
||||||
|
delete enc;
|
||||||
|
enc = new EncoderExe(encoder, parent);
|
||||||
|
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return enc;
|
return enc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,19 @@
|
||||||
/** Resolve a symbol from loaded library.
|
/** Resolve a symbol from loaded library.
|
||||||
*/
|
*/
|
||||||
#define SYMBOLRESOLVE(symbol, type) \
|
#define SYMBOLRESOLVE(symbol, type) \
|
||||||
do { m_##symbol = (type)lib->resolve(#symbol); \
|
do { m_##symbol = (type)lib.resolve(#symbol); \
|
||||||
if(!m_##symbol) return; \
|
if(!m_##symbol) return; \
|
||||||
LOG_INFO() << "Resolved symbol " #symbol; } \
|
LOG_INFO() << "Resolved symbol " #symbol; } \
|
||||||
while(0)
|
while(0)
|
||||||
|
|
||||||
EncoderLame::EncoderLame(QObject *parent) : EncoderBase(parent)
|
EncoderLame::EncoderLame(QObject *parent) : EncoderBase(parent),
|
||||||
|
lib("libmp3lame", this), m_symbolsResolved(false)
|
||||||
{
|
{
|
||||||
m_symbolsResolved = false;
|
lib.load();
|
||||||
lib = new QLibrary("libmp3lame", this);
|
if (!lib.isLoaded()) {
|
||||||
|
LOG_WARNING() << "Loading mp3lame lib failed:" << lib.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SYMBOLRESOLVE(get_lame_short_version, const char* (*)());
|
SYMBOLRESOLVE(get_lame_short_version, const char* (*)());
|
||||||
SYMBOLRESOLVE(lame_set_out_samplerate, int (*)(lame_global_flags*, int));
|
SYMBOLRESOLVE(lame_set_out_samplerate, int (*)(lame_global_flags*, int));
|
||||||
|
|
@ -51,8 +55,6 @@ EncoderLame::EncoderLame(QObject *parent) : EncoderBase(parent)
|
||||||
SYMBOLRESOLVE(lame_encode_flush, int (*)(lame_global_flags*, unsigned char*, int));
|
SYMBOLRESOLVE(lame_encode_flush, int (*)(lame_global_flags*, unsigned char*, int));
|
||||||
SYMBOLRESOLVE(lame_close, int (*)(lame_global_flags*));
|
SYMBOLRESOLVE(lame_close, int (*)(lame_global_flags*));
|
||||||
|
|
||||||
LOG_INFO() << "libmp3lame loaded:" << lib->isLoaded();
|
|
||||||
|
|
||||||
m_encoderVolume = RbSettings::subValue("lame", RbSettings::EncoderVolume).toDouble();
|
m_encoderVolume = RbSettings::subValue("lame", RbSettings::EncoderVolume).toDouble();
|
||||||
m_encoderQuality = RbSettings::subValue("lame", RbSettings::EncoderQuality).toDouble();
|
m_encoderQuality = RbSettings::subValue("lame", RbSettings::EncoderQuality).toDouble();
|
||||||
m_symbolsResolved = true;
|
m_symbolsResolved = true;
|
||||||
|
|
@ -305,6 +307,6 @@ bool EncoderLame::encode(QString input,QString output)
|
||||||
*/
|
*/
|
||||||
bool EncoderLame::configOk()
|
bool EncoderLame::configOk()
|
||||||
{
|
{
|
||||||
return (lib->isLoaded() && m_symbolsResolved);
|
return m_symbolsResolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class EncoderLame : public EncoderBase
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
EncoderLame(QObject *parent = NULL);
|
EncoderLame(QObject *parent = nullptr);
|
||||||
bool encode(QString input,QString output);
|
bool encode(QString input,QString output);
|
||||||
bool start();
|
bool start();
|
||||||
bool stop() {return true;}
|
bool stop() {return true;}
|
||||||
|
|
@ -45,7 +45,7 @@ class EncoderLame : public EncoderBase
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLibrary *lib;
|
QLibrary lib;
|
||||||
const char*(*m_get_lame_short_version)(void);
|
const char*(*m_get_lame_short_version)(void);
|
||||||
int (*m_lame_set_out_samplerate)(lame_global_flags*, int);
|
int (*m_lame_set_out_samplerate)(lame_global_flags*, int);
|
||||||
int (*m_lame_set_in_samplerate)(lame_global_flags*, int);
|
int (*m_lame_set_in_samplerate)(lame_global_flags*, int);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue