diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-09-12 20:27:01 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-09-12 20:27:01 +0000 |
| commit | a21018491ad5f53521b63dba062e2d7e87efc1c5 (patch) | |
| tree | cd26d1edca01fbd420681405e53214bb96233917 /src/plugins/Input/mad/decoder_mad.cpp | |
| parent | 8fbf582b60b6267463e6a3dc289b52e49fdc2f83 (diff) | |
| download | qmmp-a21018491ad5f53521b63dba062e2d7e87efc1c5.tar.gz qmmp-a21018491ad5f53521b63dba062e2d7e87efc1c5.tar.bz2 qmmp-a21018491ad5f53521b63dba062e2d7e87efc1c5.zip | |
fixed memory leak
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1208 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/mad/decoder_mad.cpp')
| -rw-r--r-- | src/plugins/Input/mad/decoder_mad.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp index bbfd43251..58d21bebd 100644 --- a/src/plugins/Input/mad/decoder_mad.cpp +++ b/src/plugins/Input/mad/decoder_mad.cpp @@ -22,7 +22,7 @@ DecoderMAD::DecoderMAD(QIODevice *i) - : Decoder() + : Decoder(i) { m_inited = false; m_totalTime = 0.; @@ -36,7 +36,6 @@ DecoderMAD::DecoderMAD(QIODevice *i) m_output_at = 0; m_skip_frames = 0; m_eof = false; - m_input = i; } DecoderMAD::~DecoderMAD() @@ -63,7 +62,7 @@ bool DecoderMAD::initialize() m_output_bytes = 0; m_output_at = 0; - if (!m_input) + if (!input()) { qWarning("DecoderMAD: cannot initialize. No input."); return FALSE; @@ -72,18 +71,18 @@ bool DecoderMAD::initialize() if (!m_input_buf) m_input_buf = new char[INPUT_BUFFER_SIZE]; - if (!m_input->isOpen()) + if (!input()->isOpen()) { - if (!m_input->open(QIODevice::ReadOnly)) + if (!input()->open(QIODevice::ReadOnly)) { - qWarning("DecoderMAD: %s", qPrintable(m_input->errorString ())); + qWarning("DecoderMAD: %s", qPrintable(input()->errorString ())); return FALSE; } } - if (m_input->isSequential ()) //for streams only + if (input()->isSequential ()) //for streams only { - TagExtractor extractor(m_input); + TagExtractor extractor(input()); if(!extractor.id3v2tag().isEmpty()) StateHandler::instance()->dispatch(extractor.id3v2tag()); } @@ -212,7 +211,7 @@ bool DecoderMAD::findHeader() memmove (m_input_buf, stream.next_frame, remaining); } - m_input_bytes = m_input->read(m_input_buf + remaining, INPUT_BUFFER_SIZE - remaining); + m_input_bytes = input()->read(m_input_buf + remaining, INPUT_BUFFER_SIZE - remaining); if (m_input_bytes <= 0) break; @@ -235,7 +234,7 @@ bool DecoderMAD::findHeader() } result = TRUE; - if (m_input->isSequential()) + if (input()->isSequential()) break; count ++; @@ -280,9 +279,9 @@ bool DecoderMAD::findHeader() if (!result) return FALSE; - if (!is_vbr && !m_input->isSequential()) + if (!is_vbr && !input()->isSequential()) { - double time = (m_input->size() * 8.0) / (header.bitrate); + double time = (input()->size() * 8.0) / (header.bitrate); double timefrac = (double)time - ((long)(time)); mad_timer_set(&duration, (long)time, (long)(timefrac*100), 100); } @@ -298,7 +297,7 @@ bool DecoderMAD::findHeader() m_channels = MAD_NCHANNELS(&header); m_bitrate = header.bitrate / 1000; mad_header_finish(&header); - m_input->seek(0); + input()->seek(0); m_input_bytes = 0; return TRUE; } @@ -363,8 +362,8 @@ void DecoderMAD::seek(qint64 pos) { if(m_totalTime > 0) { - qint64 seek_pos = qint64(pos * m_input->size() / m_totalTime); - m_input->seek(seek_pos); + qint64 seek_pos = qint64(pos * input()->size() / m_totalTime); + input()->seek(seek_pos); mad_frame_mute(&frame); mad_synth_mute(&synth); stream.error = MAD_ERROR_BUFLEN; @@ -382,7 +381,7 @@ bool DecoderMAD::fillBuffer() m_input_bytes = &m_input_buf[m_input_bytes] - (char *) stream.next_frame; memmove(m_input_buf, stream.next_frame, m_input_bytes); } - int len = m_input->read((char *) m_input_buf + m_input_bytes, INPUT_BUFFER_SIZE - m_input_bytes); + int len = input()->read((char *) m_input_buf + m_input_bytes, INPUT_BUFFER_SIZE - m_input_bytes); if (!len) { qDebug("DecoderMAD: end of file"); |
