diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-04-26 16:42:15 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2016-04-26 16:42:15 +0000 |
| commit | eb89e79122c587b4abdc18570d46c81bbbe65aa9 (patch) | |
| tree | 4661ed4d66928f5931f78a83f2ae904e0e002af8 /src/plugins | |
| parent | 6bc7fa9112f3f22efb87ed8e1c7c990ce0c55cb5 (diff) | |
| download | qmmp-eb89e79122c587b4abdc18570d46c81bbbe65aa9.tar.gz qmmp-eb89e79122c587b4abdc18570d46c81bbbe65aa9.tar.bz2 qmmp-eb89e79122c587b4abdc18570d46c81bbbe65aa9.zip | |
flac: fixed windows support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6268 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/Input/flac/flacmetadatamodel.cpp | 78 | ||||
| -rw-r--r-- | src/plugins/Input/flac/flacmetadatamodel.h | 8 |
2 files changed, 38 insertions, 48 deletions
diff --git a/src/plugins/Input/flac/flacmetadatamodel.cpp b/src/plugins/Input/flac/flacmetadatamodel.cpp index a53ab2c9d..b5d0cd1bb 100644 --- a/src/plugins/Input/flac/flacmetadatamodel.cpp +++ b/src/plugins/Input/flac/flacmetadatamodel.cpp @@ -31,6 +31,8 @@ FLACMetaDataModel::FLACMetaDataModel(const QString &path, QObject *parent) : MetaDataModel(parent) { + m_file = 0; + if(path.startsWith("flac://")) { QString p = path; @@ -39,39 +41,49 @@ FLACMetaDataModel::FLACMetaDataModel(const QString &path, QObject *parent) : Met m_path = p; } else - { m_path = path; - m_tags << new VorbisCommentModel(path); + + TagLib::Ogg::XiphComment *tag = 0; + + if(m_path.endsWith(".flac", Qt::CaseInsensitive)) + { + TagLib::FLAC::File *f = new TagLib::FLAC::File(QStringToFileName(m_path)); + tag = f->xiphComment(); + m_file = f; } + else if(m_path.endsWith(".oga", Qt::CaseInsensitive)) + { + TagLib::Ogg::FLAC::File *f = new TagLib::Ogg::FLAC::File(QStringToFileName(m_path)); + tag = f->tag(); + m_file = f; + } + + if(m_file && m_file->isValid() && !path.startsWith("flac://")) + m_tags << new VorbisCommentModel(tag, m_file); } FLACMetaDataModel::~FLACMetaDataModel() { while(!m_tags.isEmpty()) delete m_tags.takeFirst(); + if(m_file) + { + delete m_file; + m_file = 0; + } } QHash<QString, QString> FLACMetaDataModel::audioProperties() { QHash<QString, QString> ap; - TagLib::FLAC::File *flacFile = 0; - TagLib::Ogg::FLAC::File *oggFlacFile = 0; - TagLib::FLAC::Properties *taglib_ap = 0; + TagLib::AudioProperties *taglib_ap = 0; qint64 size = 0; - if(m_path.endsWith(".flac", Qt::CaseInsensitive)) - { - flacFile = new TagLib::FLAC::File(QStringToFileName(m_path)); - taglib_ap = flacFile->audioProperties(); - size = flacFile->length(); - } - else if(m_path.endsWith(".oga", Qt::CaseInsensitive)) + + if(m_file && m_file->isValid()) { - oggFlacFile = new TagLib::Ogg::FLAC::File(QStringToFileName(m_path)); - taglib_ap = oggFlacFile->audioProperties(); - size = oggFlacFile->length(); + taglib_ap = m_file->audioProperties(); + size = m_file->length(); } - else - return ap; if(taglib_ap) { @@ -81,12 +93,8 @@ QHash<QString, QString> FLACMetaDataModel::audioProperties() ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(taglib_ap->sampleRate())); ap.insert(tr("Channels"), QString("%1").arg(taglib_ap->channels())); ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(taglib_ap->bitrate())); + ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(size/1000)); } - ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(size/1024)); - if(flacFile) - delete flacFile; - if(oggFlacFile) - delete oggFlacFile; return ap; } @@ -120,30 +128,14 @@ QString FLACMetaDataModel::coverPath() return MetaDataManager::instance()->getCoverPath(m_path); } -VorbisCommentModel::VorbisCommentModel(const QString &path) : TagModel(TagModel::Save) +VorbisCommentModel::VorbisCommentModel(TagLib::Ogg::XiphComment *tag, TagLib::File *file) : TagModel(TagModel::Save) { - m_file = 0; - m_ogg_file = 0; - m_tag = 0; - if(path.endsWith(".flac")) - { - m_file = new TagLib::FLAC::File (QStringToFileName(path)); - m_tag = m_file->xiphComment(); - } - else if (path.endsWith(".oga")) - { - m_ogg_file = new TagLib::Ogg::FLAC::File(QStringToFileName(path)); - m_tag = m_ogg_file->tag(); - } + m_file = file; + m_tag = tag; } VorbisCommentModel::~VorbisCommentModel() -{ - if(m_file) - delete m_file; - if(m_ogg_file) - delete m_ogg_file; -} +{} const QString VorbisCommentModel::name() { @@ -236,6 +228,4 @@ void VorbisCommentModel::save() { if(m_file) m_file->save(); - else if(m_ogg_file) - m_ogg_file->save(); } diff --git a/src/plugins/Input/flac/flacmetadatamodel.h b/src/plugins/Input/flac/flacmetadatamodel.h index da2b0f6e9..c21a0afa9 100644 --- a/src/plugins/Input/flac/flacmetadatamodel.h +++ b/src/plugins/Input/flac/flacmetadatamodel.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2012 by Ilya Kotov * + * Copyright (C) 2009-2016 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -40,12 +40,13 @@ public: private: QString m_path; QList<TagModel* > m_tags; + TagLib::File *m_file; }; class VorbisCommentModel : public TagModel { public: - VorbisCommentModel(const QString &path); + VorbisCommentModel(TagLib::Ogg::XiphComment *tag, TagLib::File *file); ~VorbisCommentModel(); const QString name(); const QString value(Qmmp::MetaData key); @@ -53,8 +54,7 @@ public: void save(); private: - TagLib::FLAC::File *m_file; - TagLib::Ogg::FLAC::File *m_ogg_file; + TagLib::File *m_file; TagLib::Ogg::XiphComment *m_tag; }; |
