Fix a race condition on startup, and a crash when trying to play a stream's next track
This commit is contained in:
parent
98f23c3ddc
commit
b10bf1e40d
@ -62,6 +62,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
track_position_timer_->setInterval(1000);
|
||||
connect(track_position_timer_, SIGNAL(timeout()), SLOT(UpdateTrackPosition()));
|
||||
|
||||
// Start initialising the player
|
||||
multi_loading_indicator_->TaskStarted("Loading audio engine");
|
||||
player_->Init();
|
||||
|
||||
// Models
|
||||
library_sort_model_->setSourceModel(library_);
|
||||
library_sort_model_->setSortRole(Library::Role_SortText);
|
||||
@ -197,7 +201,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(radio_model_, SIGNAL(TaskStarted(QString)), multi_loading_indicator_, SLOT(TaskStarted(QString)));
|
||||
connect(radio_model_, SIGNAL(TaskFinished(QString)), multi_loading_indicator_, SLOT(TaskFinished(QString)));
|
||||
connect(radio_model_, SIGNAL(StreamError(QString)), SLOT(ReportError(QString)));
|
||||
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(Next()));
|
||||
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(NextItem()));
|
||||
connect(radio_model_, SIGNAL(StreamReady(QUrl,QUrl)), player_, SLOT(StreamReady(QUrl,QUrl)));
|
||||
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
||||
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*)), SLOT(InsertRadioItem(RadioItem*)));
|
||||
@ -266,9 +270,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
show();
|
||||
|
||||
library_->StartThreads();
|
||||
|
||||
player_->Init();
|
||||
multi_loading_indicator_->TaskStarted("Loading audio engine");
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
@ -55,6 +55,10 @@ void Player::Next() {
|
||||
return;
|
||||
}
|
||||
|
||||
NextItem();
|
||||
}
|
||||
|
||||
void Player::NextItem() {
|
||||
int i = playlist_->next_index();
|
||||
playlist_->set_current_index(i);
|
||||
if (i == -1) {
|
||||
|
@ -35,6 +35,7 @@ class Player : public QObject {
|
||||
void PlayAt(int index);
|
||||
void PlayPause();
|
||||
void Next();
|
||||
void NextItem();
|
||||
void Previous();
|
||||
void Stop();
|
||||
void SetVolume(int value);
|
||||
|
@ -122,6 +122,8 @@ XineEngine::init()
|
||||
QCoreApplication::applicationDirPath() + "/xine/plugins").toAscii().constData());
|
||||
#endif
|
||||
|
||||
QMutexLocker l(&m_initMutex);
|
||||
|
||||
m_xine = xine_new();
|
||||
|
||||
if( !m_xine ) {
|
||||
@ -619,8 +621,7 @@ XineEngine::canDecode( const QUrl &url ) const
|
||||
static QStringList list;
|
||||
if(list.isEmpty())
|
||||
{
|
||||
static QMutex mutex;
|
||||
QMutexLocker l(&mutex);
|
||||
QMutexLocker l(&const_cast<XineEngine*>(this)->m_initMutex);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
char* exts = xine_get_file_extensions( m_xine );
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <QThread>
|
||||
#include <QEvent>
|
||||
#include <QSettings>
|
||||
#include <QMutex>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -110,6 +111,8 @@ class XineEngine : public Engine::Base
|
||||
int m_intPreamp;
|
||||
QList<int> m_equalizerGains;
|
||||
|
||||
QMutex m_initMutex;
|
||||
|
||||
QSettings m_settings;
|
||||
bool m_fadeoutOnExit;
|
||||
bool m_fadeoutEnabled;
|
||||
|
Loading…
x
Reference in New Issue
Block a user