diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-05-19 07:14:59 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-05-19 07:14:59 +0000 |
| commit | 7c3a5146cc623ea2940177e272afdd072a07e690 (patch) | |
| tree | 6a5e4007807fee0fe501f76099ff2c07d1adfe0d /src/plugins/Transports/http/httpstreamreader.cpp | |
| parent | 79795ab834e63c0103a32ba8d5ae4885b9dc4e10 (diff) | |
| download | qmmp-7c3a5146cc623ea2940177e272afdd072a07e690.tar.gz qmmp-7c3a5146cc623ea2940177e272afdd072a07e690.tar.bz2 qmmp-7c3a5146cc623ea2940177e272afdd072a07e690.zip | |
added timeout for transport plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3471 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Transports/http/httpstreamreader.cpp')
| -rw-r--r-- | src/plugins/Transports/http/httpstreamreader.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/plugins/Transports/http/httpstreamreader.cpp b/src/plugins/Transports/http/httpstreamreader.cpp index da71be35d..adf9916e7 100644 --- a/src/plugins/Transports/http/httpstreamreader.cpp +++ b/src/plugins/Transports/http/httpstreamreader.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2012 by Ilya Kotov * + * Copyright (C) 2006-2013 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -201,6 +201,11 @@ qint64 HttpStreamReader::readData(char* data, qint64 maxlen) qint64 len = 0; m_mutex.lock(); + if(m_stream.buf_fill == 0) + { + m_mutex.unlock(); + return 0; + } if (!m_stream.icy_meta_data || m_stream.icy_metaint == 0) len = readBuffer(data, maxlen); else @@ -210,7 +215,6 @@ qint64 HttpStreamReader::readData(char* data, qint64 maxlen) while (maxlen > nread && m_stream.buf_fill > nread) { to_read = qMin<qint64>(m_stream.icy_metaint - m_metacount, maxlen - nread); - //to_read = (maxlen - nread); qint64 res = readBuffer(data + nread, to_read); nread += res; m_metacount += res; @@ -343,6 +347,7 @@ void HttpStreamReader::run() setErrorString(errorBuffer); emit error(); } + QIODevice::close(); } qint64 HttpStreamReader::readBuffer(char* data, qint64 maxlen) @@ -392,7 +397,14 @@ void HttpStreamReader::readICYMetaData() uint8_t packet_size; m_metacount = 0; m_mutex.lock(); - readBuffer((char *)&packet_size, sizeof(packet_size)); + + while (m_stream.buf_fill < 1 && m_thread->isRunning()) + { + m_mutex.unlock(); + qApp->processEvents(); + m_mutex.lock(); + } + readBuffer((char *)&packet_size, 1); if (packet_size != 0) { int size = packet_size * 16; |
