aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/flac/decoderflacfactory.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-02-16 11:49:36 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-02-16 11:49:36 +0000
commite6cdd7a53803f700e7edaa5dea2b0876ada17114 (patch)
tree903e398c1a49ef82bfcd33089d78c47c6c439726 /src/plugins/Input/flac/decoderflacfactory.cpp
parent10204e543c9b32957205ce870f9a71f7b625065f (diff)
downloadqmmp-e6cdd7a53803f700e7edaa5dea2b0876ada17114.tar.gz
qmmp-e6cdd7a53803f700e7edaa5dea2b0876ada17114.tar.bz2
qmmp-e6cdd7a53803f700e7edaa5dea2b0876ada17114.zip
added ogg flac support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1558 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/flac/decoderflacfactory.cpp')
-rw-r--r--src/plugins/Input/flac/decoderflacfactory.cpp75
1 files changed, 46 insertions, 29 deletions
diff --git a/src/plugins/Input/flac/decoderflacfactory.cpp b/src/plugins/Input/flac/decoderflacfactory.cpp
index e87e96b71..0315ef125 100644
--- a/src/plugins/Input/flac/decoderflacfactory.cpp
+++ b/src/plugins/Input/flac/decoderflacfactory.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Ilya Kotov *
+ * Copyright (C) 2008-2010 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -22,6 +22,7 @@
#include <taglib/tag.h>
#include <taglib/fileref.h>
#include <taglib/flacfile.h>
+#include <taglib/oggflacfile.h>
#include <taglib/xiphcomment.h>
#include <taglib/tmap.h>
@@ -35,7 +36,7 @@
bool DecoderFLACFactory::supports(const QString &source) const
{
- return (source.right(5).toLower() == ".flac");
+ return source.endsWith(".flac") || source.endsWith(".oga");
}
bool DecoderFLACFactory::canDecode(QIODevice *input) const
@@ -48,7 +49,7 @@ const DecoderProperties DecoderFLACFactory::properties() const
{
DecoderProperties properties;
properties.name = tr("FLAC Plugin");
- properties.filter = "*.flac";
+ properties.filter = "*.flac *.oga";
properties.description = tr("FLAC Files");
//properties.contentType = ;
properties.shortName = "flac";
@@ -65,11 +66,29 @@ Decoder *DecoderFLACFactory::create(const QString &path, QIODevice *i)
QList<FileInfo *> DecoderFLACFactory::createPlayList(const QString &fileName, bool useMetaData)
{
- FileInfo *info = new FileInfo(fileName);
+ QList <FileInfo*> list;
+ TagLib::Ogg::XiphComment *tag = 0;
+ TagLib::FLAC::Properties *ap = 0;
- TagLib::FLAC::File fileRef(fileName.toLocal8Bit ());
- TagLib::Tag *tag = useMetaData ? fileRef.tag() : 0;
+ TagLib::FLAC::File *flacFile = 0;
+ TagLib::Ogg::FLAC::File *oggFlacFile = 0;
+
+ if(fileName.endsWith(".flac"))
+ {
+ flacFile = new TagLib::FLAC::File(fileName.toLocal8Bit ());
+ tag = useMetaData ? flacFile->xiphComment() : 0;
+ ap = flacFile->audioProperties();
+ }
+ else if(fileName.endsWith(".oga"))
+ {
+ oggFlacFile = new TagLib::Ogg::FLAC::File(fileName.toLocal8Bit ());
+ tag = useMetaData ? oggFlacFile->tag() : 0;
+ ap = oggFlacFile->audioProperties();
+ }
+ else
+ return list;
+ FileInfo *info = new FileInfo(fileName);
if (tag && !tag->isEmpty())
{
info->setMetaData(Qmmp::ALBUM,
@@ -84,37 +103,35 @@ QList<FileInfo *> DecoderFLACFactory::createPlayList(const QString &fileName, bo
QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
info->setMetaData(Qmmp::YEAR, tag->year());
info->setMetaData(Qmmp::TRACK, tag->track());
- }
- if (fileRef.audioProperties())
- info->setLength(fileRef.audioProperties()->length());
-
- //looking for cuesheet comment
- TagLib::Ogg::XiphComment *xiph_comment = useMetaData ? fileRef.xiphComment() : 0;
- QList <FileInfo*> list;
- if(xiph_comment)
- {
- if (xiph_comment->fieldListMap().contains("CUESHEET"))
+ if (tag->fieldListMap().contains("CUESHEET"))
{
- CUEParser parser(xiph_comment->fieldListMap()["CUESHEET"]
- .toString().toCString(TRUE), fileName);
+ CUEParser parser(tag->fieldListMap()["CUESHEET"].toString().toCString(TRUE), fileName);
list = parser.createPlayList();
delete info;
+ if(flacFile)
+ delete flacFile;
+ if(oggFlacFile)
+ delete oggFlacFile;
return list;
}
- else
- {
- //additional metadata
- TagLib::StringList fld;
- if(!(fld = xiph_comment->fieldListMap()["COMPOSER"]).isEmpty())
- info->setMetaData(Qmmp::COMPOSER,
- QString::fromUtf8(fld.toString().toCString(TRUE)).trimmed());
- if(!(fld = xiph_comment->fieldListMap()["DISCNUMBER"]).isEmpty())
- info->setMetaData(Qmmp::DISCNUMBER,
- QString::fromUtf8(fld.toString().toCString(TRUE)).trimmed());
- }
+
+ //additional metadata
+ TagLib::StringList fld;
+ if(!(fld = tag->fieldListMap()["COMPOSER"]).isEmpty())
+ info->setMetaData(Qmmp::COMPOSER,
+ QString::fromUtf8(fld.toString().toCString(TRUE)).trimmed());
+ if(!(fld = tag->fieldListMap()["DISCNUMBER"]).isEmpty())
+ info->setMetaData(Qmmp::DISCNUMBER,
+ QString::fromUtf8(fld.toString().toCString(TRUE)).trimmed());
}
+ if(ap)
+ info->setLength(ap->length());
list << info;
+ if(flacFile)
+ delete flacFile;
+ if(oggFlacFile)
+ delete oggFlacFile;
return list;
}