mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-01 10:06:43 +01:00
Fix crash when loading CD playlists
This commit is contained in:
parent
fda970a5dc
commit
887e045a63
5
TODO
5
TODO
@ -3,6 +3,9 @@ Strawberry Music Player
|
|||||||
TODO
|
TODO
|
||||||
|
|
||||||
- Fix freeze on exit caused by GStreamer
|
- Fix freeze on exit caused by GStreamer
|
||||||
- Fix crash when loading playlists from Audio CD
|
- Fix Audio CD playback
|
||||||
- Improve status/context
|
- Improve status/context
|
||||||
- Fix crash when switching backend
|
- Fix crash when switching backend
|
||||||
|
|
||||||
|
.
|
||||||
|
|
||||||
|
@ -530,14 +530,12 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
|
|||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
//qLog(Debug) << __PRETTY_FUNCTION__;
|
||||||
//qLog(Debug) << "Song::kColumns.size():" << Song::kColumns.size() << "q.columns_.size():" << q.columns_.size() << "col:" << col;
|
//qLog(Debug) << "Song::kColumns.size():" << Song::kColumns.size() << "q.columns_.size():" << q.columns_.size() << "col:" << col;
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
int x = col;
|
int x = col;
|
||||||
|
|
||||||
d->id_ = toint(col);
|
d->id_ = toint(col);
|
||||||
|
|
||||||
for (i = 0 ; i < Song::kColumns.size(); i++) {
|
for (int i = 0 ; i < Song::kColumns.size(); i++) {
|
||||||
x=i+col+1;
|
x++;
|
||||||
|
|
||||||
if (x >= q.columns_.size()) {
|
if (x >= q.columns_.size()) {
|
||||||
qLog(Error) << "Skipping" << Song::kColumns.value(i);
|
qLog(Error) << "Skipping" << Song::kColumns.value(i);
|
||||||
break;
|
break;
|
||||||
@ -662,7 +660,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (Song::kColumns.value(i) == "cue_path") {
|
else if (Song::kColumns.value(i) == "cue_path") {
|
||||||
d->cue_path_ = tostr(col + x);
|
d->cue_path_ = tostr(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -112,8 +112,7 @@ class Song {
|
|||||||
void InitFromProtobuf(const pb::tagreader::SongMetadata &pb);
|
void InitFromProtobuf(const pb::tagreader::SongMetadata &pb);
|
||||||
void InitFromQuery(const SqlRow &query, bool reliable_metadata, int col = 0);
|
void InitFromQuery(const SqlRow &query, bool reliable_metadata, int col = 0);
|
||||||
void InitFromFilePartial(const QString &filename); // Just store the filename: incomplete but fast
|
void InitFromFilePartial(const QString &filename); // Just store the filename: incomplete but fast
|
||||||
void InitArtManual(); // Check if there is already a art in the cache and
|
void InitArtManual(); // Check if there is already a art in the cache and store the filename in art_manual
|
||||||
// store the filename in art_manual
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
void InitFromLastFM(const lastfm::Track &track);
|
void InitFromLastFM(const lastfm::Track &track);
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,6 +40,8 @@ CddaSongLoader::~CddaSongLoader() {
|
|||||||
|
|
||||||
QUrl CddaSongLoader::GetUrlFromTrack(int track_number) const {
|
QUrl CddaSongLoader::GetUrlFromTrack(int track_number) const {
|
||||||
|
|
||||||
|
qLog(Debug) << url_;
|
||||||
|
|
||||||
if (url_.isEmpty()) {
|
if (url_.isEmpty()) {
|
||||||
return QUrl(QString("cdda://%1").arg(track_number));
|
return QUrl(QString("cdda://%1").arg(track_number));
|
||||||
}
|
}
|
||||||
|
@ -695,9 +695,9 @@ void GstEngine::SeekNow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GstEngine::SetEqualizerEnabled(bool enabled) {
|
void GstEngine::SetEqualizerEnabled(bool enabled) {
|
||||||
|
|
||||||
//qLog(Debug) << "equalizer ENABLED: " << enabled;
|
//qLog(Debug) << "equalizer ENABLED: " << enabled;
|
||||||
|
|
||||||
equalizer_enabled_ = enabled;
|
equalizer_enabled_ = enabled;
|
||||||
|
|
||||||
if (current_pipeline_) current_pipeline_->SetEqualizerEnabled(enabled);
|
if (current_pipeline_) current_pipeline_->SetEqualizerEnabled(enabled);
|
||||||
@ -757,6 +757,7 @@ void GstEngine::timerEvent(QTimerEvent *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GstEngine::HandlePipelineError(int pipeline_id, const QString &message, int domain, int error_code) {
|
void GstEngine::HandlePipelineError(int pipeline_id, const QString &message, int domain, int error_code) {
|
||||||
@ -766,7 +767,7 @@ void GstEngine::HandlePipelineError(int pipeline_id, const QString &message, int
|
|||||||
if (!current_pipeline_.get() || current_pipeline_->id() != pipeline_id)
|
if (!current_pipeline_.get() || current_pipeline_->id() != pipeline_id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qLog(Warning) << "Gstreamer error:" << message;
|
qLog(Warning) << "Gstreamer error:" << domain << error_code << message;
|
||||||
|
|
||||||
current_pipeline_.reset();
|
current_pipeline_.reset();
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ PlaylistBackend::Playlist PlaylistBackend::GetPlaylist(int id) {
|
|||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
|
|
||||||
QSqlQuery q(db);
|
QSqlQuery q(db);
|
||||||
q.prepare("SELECT ROWID, name, last_played, special_type, ui_path, is_favorite FROM playlists WHERE ROWID=:id");
|
q.prepare("SELECT ROWID, name, last_played, special_type, ui_path, is_favorite FROM playlists WHERE ROWID=:id");
|
||||||
|
|
||||||
@ -126,12 +125,11 @@ PlaylistBackend::Playlist PlaylistBackend::GetPlaylist(int id) {
|
|||||||
p.favorite = q.value(5).toBool();
|
p.favorite = q.value(5).toBool();
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSqlQuery PlaylistBackend::GetPlaylistRows(int playlist) {
|
QSqlQuery PlaylistBackend::GetPlaylistRows(int playlist) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
@ -158,8 +156,6 @@ QSqlQuery PlaylistBackend::GetPlaylistRows(int playlist) {
|
|||||||
|
|
||||||
QList<PlaylistItemPtr> PlaylistBackend::GetPlaylistItems(int playlist) {
|
QList<PlaylistItemPtr> PlaylistBackend::GetPlaylistItems(int playlist) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QSqlQuery q = GetPlaylistRows(playlist);
|
QSqlQuery q = GetPlaylistRows(playlist);
|
||||||
// Note that as this only accesses the query, not the db, we don't need the
|
// Note that as this only accesses the query, not the db, we don't need the
|
||||||
// mutex.
|
// mutex.
|
||||||
@ -178,8 +174,6 @@ QList<PlaylistItemPtr> PlaylistBackend::GetPlaylistItems(int playlist) {
|
|||||||
|
|
||||||
QList<Song> PlaylistBackend::GetPlaylistSongs(int playlist) {
|
QList<Song> PlaylistBackend::GetPlaylistSongs(int playlist) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QSqlQuery q = GetPlaylistRows(playlist);
|
QSqlQuery q = GetPlaylistRows(playlist);
|
||||||
// Note that as this only accesses the query, not the db, we don't need the
|
// Note that as this only accesses the query, not the db, we don't need the
|
||||||
// mutex.
|
// mutex.
|
||||||
@ -198,12 +192,8 @@ QList<Song> PlaylistBackend::GetPlaylistSongs(int playlist) {
|
|||||||
|
|
||||||
PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
// The song tables get joined first, plus one each for the song ROWIDs
|
// The song tables get joined first, plus one each for the song ROWIDs
|
||||||
const int playlist_row = (Song::kColumns.count() + 1) * kSongTableJoins;
|
const int playlist_row = (Song::kColumns.count() + 1) * kSongTableJoins;
|
||||||
|
|
||||||
//qLog(Debug) << row.value(playlist_row).toString();
|
|
||||||
|
|
||||||
PlaylistItemPtr item(PlaylistItem::NewFromType(row.value(playlist_row).toString()));
|
PlaylistItemPtr item(PlaylistItem::NewFromType(row.value(playlist_row).toString()));
|
||||||
if (item) {
|
if (item) {
|
||||||
@ -217,8 +207,6 @@ PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std
|
|||||||
}
|
}
|
||||||
|
|
||||||
Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
return NewPlaylistItemFromQuery(row, state)->Metadata();
|
return NewPlaylistItemFromQuery(row, state)->Metadata();
|
||||||
|
|
||||||
@ -227,8 +215,6 @@ Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSon
|
|||||||
// If song had a CUE and the CUE still exists, the metadata from it will be applied here.
|
// If song had a CUE and the CUE still exists, the metadata from it will be applied here.
|
||||||
|
|
||||||
PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::shared_ptr<NewSongFromQueryState> state) {
|
PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::shared_ptr<NewSongFromQueryState> state) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
// we need collection to run a CueParser; also, this method applies only to file-type PlaylistItems
|
// we need collection to run a CueParser; also, this method applies only to file-type PlaylistItems
|
||||||
if (item->type() != "File") return item;
|
if (item->type() != "File") return item;
|
||||||
@ -277,8 +263,6 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::share
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistBackend::SavePlaylistAsync(int playlist, const PlaylistItemList &items, int last_played) {
|
void PlaylistBackend::SavePlaylistAsync(int playlist, const PlaylistItemList &items, int last_played) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
metaObject()->invokeMethod(this, "SavePlaylist", Qt::QueuedConnection, Q_ARG(int, playlist), Q_ARG(PlaylistItemList, items), Q_ARG(int, last_played));
|
metaObject()->invokeMethod(this, "SavePlaylist", Qt::QueuedConnection, Q_ARG(int, playlist), Q_ARG(PlaylistItemList, items), Q_ARG(int, last_played));
|
||||||
|
|
||||||
@ -286,8 +270,6 @@ void PlaylistBackend::SavePlaylistAsync(int playlist, const PlaylistItemList &it
|
|||||||
|
|
||||||
void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items, int last_played) {
|
void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items, int last_played) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
@ -327,8 +309,6 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int PlaylistBackend::CreatePlaylist(const QString& name, const QString& special_type) {
|
int PlaylistBackend::CreatePlaylist(const QString& name, const QString& special_type) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
@ -345,8 +325,6 @@ int PlaylistBackend::CreatePlaylist(const QString& name, const QString& special_
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistBackend::RemovePlaylist(int id) {
|
void PlaylistBackend::RemovePlaylist(int id) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
@ -371,8 +349,6 @@ void PlaylistBackend::RemovePlaylist(int id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistBackend::RenamePlaylist(int id, const QString &new_name) {
|
void PlaylistBackend::RenamePlaylist(int id, const QString &new_name) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
@ -387,8 +363,6 @@ void PlaylistBackend::RenamePlaylist(int id, const QString &new_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistBackend::FavoritePlaylist(int id, bool is_favorite) {
|
void PlaylistBackend::FavoritePlaylist(int id, bool is_favorite) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
@ -403,8 +377,6 @@ void PlaylistBackend::FavoritePlaylist(int id, bool is_favorite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistBackend::SetPlaylistOrder(const QList<int> &ids) {
|
void PlaylistBackend::SetPlaylistOrder(const QList<int> &ids) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
@ -428,8 +400,6 @@ void PlaylistBackend::SetPlaylistOrder(const QList<int> &ids) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistBackend::SetPlaylistUiPath(int id, const QString &path) {
|
void PlaylistBackend::SetPlaylistUiPath(int id, const QString &path) {
|
||||||
|
|
||||||
//qLog(Debug) << __PRETTY_FUNCTION__;
|
|
||||||
|
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
@ -56,7 +56,7 @@ PlaylistItem* PlaylistItem::NewFromSongsTable(const QString &table, const Song &
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistItem::BindToQuery(QSqlQuery* query) const {
|
void PlaylistItem::BindToQuery(QSqlQuery *query) const {
|
||||||
|
|
||||||
query->bindValue(":type", type());
|
query->bindValue(":type", type());
|
||||||
query->bindValue(":collection_id", DatabaseValue(Column_CollectionId));
|
query->bindValue(":collection_id", DatabaseValue(Column_CollectionId));
|
||||||
|
@ -37,7 +37,7 @@ SongPlaylistItem::SongPlaylistItem(const Song &song)
|
|||||||
|
|
||||||
bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
|
bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
|
||||||
|
|
||||||
song_.InitFromQuery(query, false, (Song::kColumns.count() + 1) * 3);
|
song_.InitFromQuery(query, false, (Song::kColumns.count()+1));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user