diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-10-27 17:25:51 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2017-10-27 17:25:51 +0000 |
| commit | fef0263b8bb4b26db75ce924c3a2af12f8f74928 (patch) | |
| tree | 9ba23f05483e84c3096db66696d7c4230a9dec1b | |
| parent | 79340c153fd0e7a79839b072cf87905da84ce77d (diff) | |
| download | qmmp-fef0263b8bb4b26db75ce924c3a2af12f8f74928.tar.gz qmmp-fef0263b8bb4b26db75ce924c3a2af12f8f74928.tar.bz2 qmmp-fef0263b8bb4b26db75ce924c3a2af12f8f74928.zip | |
sid: fixed memory leak
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7652 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/Input/sid/decoder_sid.cpp | 28 | ||||
| -rw-r--r-- | src/plugins/Input/sid/decoder_sid.h | 4 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/plugins/Input/sid/decoder_sid.cpp b/src/plugins/Input/sid/decoder_sid.cpp index b89617913..289e969c7 100644 --- a/src/plugins/Input/sid/decoder_sid.cpp +++ b/src/plugins/Input/sid/decoder_sid.cpp @@ -32,7 +32,7 @@ #include "decoder_sid.h" // Decoder class -DecoderSID::DecoderSID(SidDatabase *db, const QString &url) : Decoder() +DecoderSID::DecoderSID(SidDatabase *db, const QString &url) : Decoder(), m_tune(0) { m_db = db; m_url = url; @@ -56,34 +56,30 @@ bool DecoderSID::initialize() path.remove(QRegExp("#\\d+$")); int track = m_url.section("#", -1).toInt(); - SidTune *tune = new SidTune(0); - tune->load(qPrintable(path)); - if(!tune->getInfo()) + m_tune.load(qPrintable(path)); + if(!m_tune.getInfo()) { - qWarning("DecoderSID: unable to load tune, error: %s", tune->statusString()); - delete tune; + qWarning("DecoderSID: unable to load tune, error: %s", m_tune.statusString()); return false; } - int count = tune->getInfo()->songs(); + int count = m_tune.getInfo()->songs(); if(track > count || track < 1) { qWarning("DecoderSID: track number is out of range"); - delete tune; return false; } - tune->selectSong(track); + m_tune.selectSong(track); - if(!tune->getStatus()) + if(!m_tune.getStatus()) { - qWarning("DecoderSID: error: %s", tune->statusString()); - delete tune; + qWarning("DecoderSID: error: %s", m_tune.statusString()); return false; } //send metadata for pseudo-protocol - const SidTuneInfo *tune_info = tune->getInfo(); + const SidTuneInfo *tune_info = m_tune.getInfo(); QMap<Qmmp::MetaData, QString> metadata; metadata.insert(Qmmp::TITLE, tune_info->infoString(0)); metadata.insert(Qmmp::ARTIST, tune_info->infoString(1)); @@ -98,7 +94,7 @@ bool DecoderSID::initialize() if(settings.value("use_hvsc", false).toBool()) { char md5[SidTune::MD5_LENGTH+1]; - tune->createMD5(md5); + m_tune.createMD5(md5); m_length = m_db->length(md5, track); } @@ -135,7 +131,7 @@ bool DecoderSID::initialize() return false; } - if(!m_player->load(tune)) + if(!m_player->load(&m_tune)) { qWarning("DecoderSID: unable to load tune, error: %s", m_player->error()); return false; @@ -170,5 +166,5 @@ qint64 DecoderSID::read(unsigned char *data, qint64 size) if(size <= 0) return 0; m_read_bytes += size; - return m_player->play((short *)data, size/2) * 2; + return m_player->play((short *)data, size/2) * 2; } diff --git a/src/plugins/Input/sid/decoder_sid.h b/src/plugins/Input/sid/decoder_sid.h index 7fa178e1e..359000a96 100644 --- a/src/plugins/Input/sid/decoder_sid.h +++ b/src/plugins/Input/sid/decoder_sid.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2013-2016 by Ilya Kotov * + * Copyright (C) 2013-2017 by Ilya Kotov * * forkotov02@ya.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -25,6 +25,7 @@ class sidplayfp; class SidDatabase; +class SidTune; /** @author Ilya Kotov <forkotov02@ya.ru> @@ -49,6 +50,7 @@ private: int m_length; qint64 m_length_in_bytes; qint64 m_read_bytes; + SidTune m_tune; }; #endif // DECODER_SID_H |
