AudioFileMp3 - Use a configurable setting for lame

There is a new folder setting called Lame Library. AudioFileMp3
will look here for libmp3lame.so.0. If it can't find it it will
notify the user how to make it work and abort rendering gracefully.
This commit is contained in:
Andrew Kelley
2009-07-15 07:00:52 -07:00
parent b99d79b4d2
commit 60a0bf9346
6 changed files with 86 additions and 8 deletions

View File

@@ -102,6 +102,12 @@ public:
return m_dataDir + DEFAULT_THEME_PATH;
}
QString defaultLameLibrary( void ) const
{
return "/usr/lib/libmp3lame.so.0";
}
QString artworkDir( void ) const
{
return m_artworkDir;
@@ -146,6 +152,11 @@ public:
}
#endif
const QString & lameLibrary( void ) const
{
return m_lameLibrary;
}
const QString & backgroundArtwork( void ) const
{
return m_backgroundArtwork;
@@ -175,6 +186,7 @@ public:
void setSTKDir( const QString & _fd );
void setDefaultSoundfont( const ResourceItem * _sf );
void setBackgroundArtwork( const QString & _ba );
void setLameLibrary( const QString & _ll );
private:
@@ -201,6 +213,7 @@ private:
#endif
QString m_backgroundArtwork;
QStringList m_recentlyOpenedProjects;
QString m_lameLibrary;
typedef QVector<QPair<QString, QString> > stringPairVector;

View File

@@ -88,6 +88,7 @@ private slots:
void setSTKDir( const QString & _sd );
void setDefaultSoundfont( const QString & _sf );
void setBackgroundArtwork( const QString & _ba );
void setLameLibrary( const QString & _ll );
// audio settings widget
void audioInterfaceChanged( const QString & _driver );
@@ -112,6 +113,7 @@ private slots:
void openSTKDir( void );
void openDefaultSoundfont( void );
void openBackgroundArtwork( void );
void openLameLibrary( void );
void toggleDisableChActInd( bool _disabled );
void toggleManualChPiano( bool _enabled );
@@ -152,6 +154,7 @@ private:
QLineEdit * m_stkLineEdit;
#endif
QLineEdit * m_baLineEdit;
QLineEdit * m_llLineEdit;
QString m_workingDir;
QString m_vstDir;
@@ -165,6 +168,7 @@ private:
QString m_stkDir;
#endif
QString m_backgroundArtwork;
QString m_lameLibrary;
bool m_disableChActInd;
bool m_manualChPiano;

View File

@@ -24,6 +24,8 @@
*
*/
#include <QtGui/QMessageBox>
#include "lame.h"
#include "audio_file_mp3.h"
@@ -32,6 +34,8 @@
using namespace std;
#include "config_mgr.h"
AudioFileMp3::AudioFileMp3( const sample_rate_t _sample_rate,
const ch_cnt_t _channels, bool & _success_ful,
@@ -51,8 +55,19 @@ AudioFileMp3::AudioFileMp3( const sample_rate_t _sample_rate,
m_hq_mode( false )
{
// connect to lame
m_ok = initLame("/usr/lib/libmp3lame.so.0");
m_ok = initLame(configManager::inst()->lameLibrary());
m_ok = _success_ful = m_ok && startEncoding();
if( ! m_ok )
{
// pop an informative message box
QMessageBox::information( NULL, QObject::tr( "Unable to load LAME" ),
QObject::tr( "LMMS was unable to load Lame MP3 encoder. "
"Please make sure "
"you have Lame installed and then check your folder settings "
"and make sure you tell LMMS where libmp3lame.so.0 is." ),
QMessageBox::Ok | QMessageBox::Default );
}
}

View File

@@ -72,7 +72,8 @@ configManager::configManager( void ) :
#endif
m_vstDir( m_workingDir + "vst" + QDir::separator() ),
m_flDir( QDir::home().absolutePath() ),
m_defaultSoundfont( NULL )
m_defaultSoundfont( NULL ),
m_lameLibrary( defaultLameLibrary() )
{
}
@@ -156,6 +157,10 @@ void configManager::setBackgroundArtwork( const QString & _ba )
}
void configManager::setLameLibrary( const QString & _ll )
{
m_lameLibrary = _ll;
}
void configManager::addRecentlyOpenedProject( const QString & _file )
@@ -300,6 +305,11 @@ void configManager::loadConfigFile( void )
"defaultsf2" ) ) );*/
#endif
setBackgroundArtwork( value( "paths", "backgroundartwork" ) );
// lame library
QString configLameLibrary = value( "paths", "lamelibrary" );
if( configLameLibrary != "" )
setLameLibrary( configLameLibrary );
}
cfg_file.close();
}
@@ -379,6 +389,7 @@ void configManager::saveConfigFile( void )
m_defaultSoundfont->hash() : QString() );
#endif
setValue( "paths", "backgroundartwork", m_backgroundArtwork );
setValue( "paths", "lamelibrary", m_lameLibrary );
QDomDocument doc( "lmms-config-file" );

View File

@@ -126,7 +126,6 @@ void exportProjectDialog::startBtnClicked( void )
startButton->setEnabled( FALSE );
progressBar->setEnabled( TRUE );
updateTitleBar( 0 );
mixer::qualitySettings qs = mixer::qualitySettings(
static_cast<mixer::qualitySettings::Interpolation>(
@@ -146,6 +145,7 @@ void exportProjectDialog::startBtnClicked( void )
m_renderer = new projectRenderer( qs, os, ft, m_fileName );
if( m_renderer->isReady() )
{
updateTitleBar( 0 );
connect( m_renderer, SIGNAL( progressChanged( int ) ),
progressBar, SLOT( setValue( int ) ) );
connect( m_renderer, SIGNAL( progressChanged( int ) ),

View File

@@ -116,6 +116,7 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) :
m_stkDir( configManager::inst()->stkDir() ),
#endif
m_backgroundArtwork( configManager::inst()->backgroundArtwork() ),
m_lameLibrary( configManager::inst()->lameLibrary() ),
m_disableChActInd( configManager::inst()->value( "ui",
"disablechannelactivityindicators" ).toInt() ),
m_manualChPiano( configManager::inst()->value( "ui",
@@ -417,14 +418,29 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) :
connect( m_sfLineEdit, SIGNAL( textChanged( const QString & ) ), this,
SLOT( setDefaultSoundfont( const QString & ) ) );
QPushButton * sf_select_btn = new QPushButton(
embed::getIconPixmap( "project_open", 16, 16 ),
"", sf_tw );
QPushButton * sf_select_btn = new QPushButton( embed::getIconPixmap(
"project_open", 16, 16 ), "", sf_tw );
sf_select_btn->setFixedSize( 24, 24 );
sf_select_btn->move( 320, 16 );
connect( sf_select_btn, SIGNAL( clicked() ), this,
SLOT( openDefaultSoundfont() ) );
SLOT( openDefaultSoundfont() ) );
#endif
// Lame library
tabWidget * ll_tw = new tabWidget( tr("Lame MP3 Library").toUpper(), paths);
ll_tw->setFixedHeight(48);
printf("m_lameLibrary: %s\n", m_lameLibrary.toStdString().c_str());
m_llLineEdit = new QLineEdit( m_lameLibrary, ll_tw );
m_llLineEdit->setGeometry( 10, 20, 300, 16);
connect( m_llLineEdit, SIGNAL( textChanged( const QString & ) ), this,
SLOT( setLameLibrary( const QString & ) ) );
QPushButton * ll_select_btn = new QPushButton( embed::getIconPixmap(
"project_open", 16, 16 ), "", ll_tw );
ll_select_btn->setFixedSize( 24, 24 );
ll_select_btn->move( 320, 16 );
connect( ll_select_btn, SIGNAL( clicked() ), this, SLOT(
openLameLibrary() ) );
dir_layout->addWidget( lmms_wd_tw );
@@ -446,6 +462,9 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) :
dir_layout->addSpacing( 10 );
dir_layout->addWidget( sf_tw );
#endif
dir_layout->addSpacing( 10 );
dir_layout->addWidget( ll_tw );
dir_layout->addStretch();
@@ -913,6 +932,7 @@ void setupDialog::accept( void )
configManager::inst()->setSTKDir( m_stkDir );
#endif
configManager::inst()->setBackgroundArtwork( m_backgroundArtwork );
configManager::inst()->setLameLibrary( m_lameLibrary );
// tell all audio-settings-widget to save their settings
for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin();
@@ -1203,6 +1223,16 @@ void setupDialog::openDefaultSoundfont( void )
}
void setupDialog::openLameLibrary( void )
{
QString new_file = QFileDialog::getOpenFileName( this,
tr( "Find LAME Library" ), m_lameLibrary, "libmp3lame.so.0" );
if( new_file != QString::null )
{
m_llLineEdit->setText( new_file );
}
}
void setupDialog::openBackgroundArtwork( void )
@@ -1272,7 +1302,6 @@ void setupDialog::setDefaultSoundfont( const QString & _sf )
void setupDialog::setBackgroundArtwork( const QString & _ba )
{
#ifdef LMMS_HAVE_FLUIDSYNTH
@@ -1282,6 +1311,12 @@ void setupDialog::setBackgroundArtwork( const QString & _ba )
void setupDialog::setLameLibrary( const QString & _ll )
{
m_lameLibrary = _ll;
}
void setupDialog::audioInterfaceChanged( const QString & _iface )
{