aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-04-02 19:09:45 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-04-02 19:09:45 +0000
commit135e46debf3795ca09a32edf2b067f8401dea1e1 (patch)
treedb700a3dca45e7a715f93427af8a1d3bab88efce /src/plugins
parent03691f84bc4f919762b4804cda79430ea5f46e7c (diff)
downloadqmmp-135e46debf3795ca09a32edf2b067f8401dea1e1.tar.gz
qmmp-135e46debf3795ca09a32edf2b067f8401dea1e1.tar.bz2
qmmp-135e46debf3795ca09a32edf2b067f8401dea1e1.zip
gme plugin: removed internal api usage
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2145 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Input/gme/decoder_gme.cpp41
-rw-r--r--src/plugins/Input/gme/decoder_gme.h2
-rw-r--r--src/plugins/Input/gme/decodergmefactory.cpp3
-rw-r--r--src/plugins/Input/gme/gmehelper.cpp45
-rw-r--r--src/plugins/Input/gme/gmehelper.h4
5 files changed, 46 insertions, 49 deletions
diff --git a/src/plugins/Input/gme/decoder_gme.cpp b/src/plugins/Input/gme/decoder_gme.cpp
index 7dd42101f..81d9cb718 100644
--- a/src/plugins/Input/gme/decoder_gme.cpp
+++ b/src/plugins/Input/gme/decoder_gme.cpp
@@ -39,34 +39,35 @@ bool DecoderGme::initialize()
if(!m_emu)
return false;
- int count = m_emu->track_count();
+ int count = gme_track_count(m_emu);
if(track > count + 1 || track < 0)
{
qWarning("DecoderGme: track number is out of range");
- delete m_emu;
+ gme_delete(m_emu);
m_emu = 0;
return false;
}
- m_emu->start_track(track - 1);
- track_info_t track_info;
- if(!m_emu->track_info(&track_info))
+ gme_start_track(m_emu, track - 1);
+ gme_info_t *track_info;
+ if(!gme_track_info(m_emu, &track_info, track - 1))
{
- if(track_info.length <= 0)
- track_info.length = track_info.intro_length + track_info.loop_length * 2;
+ if(track_info->length <= 0)
+ track_info->length = track_info->intro_length + track_info->loop_length * 2;
}
- if(track_info.length <= 0)
- track_info.length = (long) (2.5 * 60 * 1000);
- if(track_info.length < m_helper.fadeLength())
- track_info.length += m_helper.fadeLength();
- m_emu->set_fade(track_info.length - m_helper.fadeLength(), m_helper.fadeLength());
+ if(track_info->length <= 0)
+ track_info->length = (long) (2.5 * 60 * 1000);
+ if(track_info->length < m_helper.fadeLength())
+ track_info->length += m_helper.fadeLength();
+ gme_set_fade(m_emu, track_info->length - m_helper.fadeLength());
QMap<Qmmp::MetaData, QString> metadata;
- metadata.insert(Qmmp::TITLE, track_info.song);
- metadata.insert(Qmmp::ARTIST, track_info.author);
- metadata.insert(Qmmp::COMMENT, track_info.comment);
+ metadata.insert(Qmmp::TITLE, track_info->song);
+ metadata.insert(Qmmp::ARTIST, track_info->author);
+ metadata.insert(Qmmp::COMMENT, track_info->comment);
metadata.insert(Qmmp::TRACK, QString("%1").arg(track));
metadata.insert(Qmmp::URL, m_path);
StateHandler::instance()->dispatch(metadata);
- m_totalTime = track_info.length;
+ m_totalTime = track_info->length;
+ gme_free_info(track_info);
configure(44100, 2);
qDebug("DecoderGme: initialize succes");
return true;
@@ -79,7 +80,7 @@ qint64 DecoderGme::totalTime()
void DecoderGme::seek(qint64 pos)
{
- m_emu->seek(pos);
+ gme_seek(m_emu, pos);
}
int DecoderGme::bitrate()
@@ -89,9 +90,11 @@ int DecoderGme::bitrate()
qint64 DecoderGme::read(char *data, qint64 size)
{
- if(m_emu->track_ended())
+ if(gme_track_ended(m_emu))
return 0;
- if (m_emu->play(size/2, (short*)data))
+ if(m_totalTime && gme_tell(m_emu) > m_totalTime)
+ return 0;
+ if (gme_play(m_emu, size/2, (short*)data))
{
return 0;
}
diff --git a/src/plugins/Input/gme/decoder_gme.h b/src/plugins/Input/gme/decoder_gme.h
index 4041c6d64..43ecaa7e2 100644
--- a/src/plugins/Input/gme/decoder_gme.h
+++ b/src/plugins/Input/gme/decoder_gme.h
@@ -21,7 +21,7 @@
#ifndef DECODER_GME_H
#define DECODER_GME_H
-#include <gme/Music_Emu.h>
+#include <gme/gme.h>
#include <qmmp/decoder.h>
class GmeHelper;
diff --git a/src/plugins/Input/gme/decodergmefactory.cpp b/src/plugins/Input/gme/decodergmefactory.cpp
index 4d086bb38..b3283ce47 100644
--- a/src/plugins/Input/gme/decodergmefactory.cpp
+++ b/src/plugins/Input/gme/decodergmefactory.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010 by Ilya Kotov *
+ * Copyright (C) 2010-2011 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,7 +20,6 @@
#include <QtGui>
#include <QRegExp>
-#include <gme/Gme_File.h>
#include "gmehelper.h"
#include "decoder_gme.h"
#include "decodergmefactory.h"
diff --git a/src/plugins/Input/gme/gmehelper.cpp b/src/plugins/Input/gme/gmehelper.cpp
index 30a2191cd..34c30a269 100644
--- a/src/plugins/Input/gme/gmehelper.cpp
+++ b/src/plugins/Input/gme/gmehelper.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010 by Ilya Kotov *
+ * Copyright (C) 2010-2011 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,14 +30,14 @@ GmeHelper::GmeHelper()
GmeHelper::~GmeHelper()
{
if(m_emu)
- delete m_emu;
+ gme_delete(m_emu);
m_emu = 0;
}
Music_Emu *GmeHelper::load(const QString &url, int sample_rate)
{
if(m_emu)
- delete m_emu;
+ gme_delete(m_emu);
m_emu = 0;
QString path = url;
if(url.contains("://"))
@@ -60,24 +60,19 @@ Music_Emu *GmeHelper::load(const QString &url, int sample_rate)
qWarning("DecoderGme: unsupporetd music type");
return 0;
}
- if(!(m_emu = file_type->new_emu()))
+ if(!(m_emu = gme_new_emu(file_type, sample_rate)))
{
qWarning("GmeHelper: out of memory");
return 0;
}
- if((err = m_emu->set_sample_rate(sample_rate)))
- {
- qWarning("GmeHelper: %s", err);
- return 0;
- }
- if((err = m_emu->load_file(qPrintable(path))))
+ if((err = gme_load_file(m_emu, qPrintable(path))))
{
qWarning("GmeHelper: %s", err);
return 0;
}
QString m3u_path = path.left(path.lastIndexOf("."));
m3u_path.append(".m3u");
- m_emu->load_m3u(qPrintable(m3u_path));
+ gme_load_m3u(m_emu, qPrintable(m3u_path));
m_path = path;
return m_emu;
}
@@ -87,26 +82,25 @@ QList <FileInfo*> GmeHelper::createPlayList(bool meta)
QList <FileInfo*> list;
if(!m_emu)
return list;
- int count = m_emu->track_count();
- track_info_t track_info;
+ int count = gme_track_count(m_emu);
+ gme_info_t *track_info;
for(int i = 0; i < count; ++i)
{
FileInfo *info = new FileInfo();
- m_emu->start_track(i);
- if(!m_emu->track_info(&track_info))
+ if(!gme_track_info(m_emu, &track_info, i))
{
- if(track_info.length <= 0)
- track_info.length = track_info.intro_length + track_info.loop_length * 2;
+ if(track_info->length <= 0)
+ track_info->length = track_info->intro_length + track_info->loop_length * 2;
}
- if(track_info.length <= 0)
- track_info.length = (long) (2.5 * 60 * 1000);
- if(track_info.length < FADE_LENGTH)
- track_info.length += FADE_LENGTH;
+ if(track_info->length <= 0)
+ track_info->length = (long) (2.5 * 60 * 1000);
+ if(track_info->length < FADE_LENGTH)
+ track_info->length += FADE_LENGTH;
if(meta)
{
- info->setMetaData(Qmmp::TITLE, track_info.song);
- info->setMetaData(Qmmp::ARTIST, track_info.author);
- info->setMetaData(Qmmp::COMMENT, track_info.comment);
+ info->setMetaData(Qmmp::TITLE, track_info->song);
+ info->setMetaData(Qmmp::ARTIST, track_info->author);
+ info->setMetaData(Qmmp::COMMENT, track_info->comment);
info->setMetaData(Qmmp::TRACK, i+1);
}
QString path = m_path;
@@ -115,7 +109,8 @@ QList <FileInfo*> GmeHelper::createPlayList(bool meta)
path.replace("?", QString(QUrl::toPercentEncoding("?")));
path.replace(":", QString(QUrl::toPercentEncoding(":")));
info->setPath("gme://"+path+QString("#%1").arg(i+1));
- info->setLength(track_info.length/1000);
+ info->setLength(track_info->length/1000);
+ gme_free_info(track_info);
list << info;
}
return list;
diff --git a/src/plugins/Input/gme/gmehelper.h b/src/plugins/Input/gme/gmehelper.h
index bb90abc16..e1a98333d 100644
--- a/src/plugins/Input/gme/gmehelper.h
+++ b/src/plugins/Input/gme/gmehelper.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010 by Ilya Kotov *
+ * Copyright (C) 2010-2011 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -23,7 +23,7 @@
#include <QString>
#include <QList>
-#include <gme/Music_Emu.h>
+#include <gme/gme.h>
#include <qmmp/fileinfo.h>
/**