From e006b301436516a819a53aa4aa5ca8f79625ebfa Mon Sep 17 00:00:00 2001 From: Elias Woods Date: Fri, 25 Jun 2010 05:52:01 -0400 Subject: [PATCH] Fix immediate playback better memory management --- Groove.pro.user | 2 +- playlist.cpp | 10 +++++++--- splayer.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Groove.pro.user b/Groove.pro.user index 334fa29..0bf42b9 100644 --- a/Groove.pro.user +++ b/Groove.pro.user @@ -194,7 +194,7 @@ 1 - 2010-06-25T04:22:04 + 2010-06-25T05:45:13 diff --git a/playlist.cpp b/playlist.cpp index fbcf8f4..4fbdad7 100644 --- a/playlist.cpp +++ b/playlist.cpp @@ -6,7 +6,8 @@ playlist::playlist(QObject *parent) : manager = new QNetworkAccessManager(); this->currentdownloaditem = -1; pList = new QList; - this->currentplayingitem =-1; + this->currentplayingitem = -1; + this->currentSkeyItem = -1; } void playlist::markPlayed(int position) { @@ -86,7 +87,7 @@ void playlist::skeyFound() this->beginDownload(this->currentSkeyItem); else if(this->currentplaying() == this->currentSkeyItem) - this->beginDownload(this->currentplayingitem); + this->beginDownload(this->currentSkeyItem); } int playlist::addSong(QStandardItem *item) @@ -103,6 +104,7 @@ int playlist::addSong(QStandardItem *item) pList->append(newelement); gs->getSong(item->text()); emit this->freeze(); + this->currentSkeyItem = pList->size()-1; return pList->size()-1; } @@ -137,7 +139,9 @@ void playlist::downloadSlot(qint64 b, qint64 t) { emit this->downloadProgress(this->currentdownloaditem,b,t); pList->at(this->currentdownloaditem)->buffer->buffer().append(reply->readAll()); - if ( b >= t*0.05 && !pList->at(currentdownloaditem)->bufferready && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 10) + //qDebug() << !pList->at(this->currentdownloaditem)->bufferready << this->currentdownloaditem; + if ( b >= t*0.05 && !pList->at(this->currentdownloaditem)->bufferready) + //if(!pList->at(currentdownloaditem)->bufferready && b/(startStreamT.msecsTo(QTime::currentTime()) + 1)*100/1024 >= 10) { this->setBufferRdy(this->currentdownloaditem); emit this->bufferReady(this->currentdownloaditem); diff --git a/splayer.cpp b/splayer.cpp index a2349b2..e642dd1 100644 --- a/splayer.cpp +++ b/splayer.cpp @@ -63,14 +63,19 @@ void sPlayer::play() } void sPlayer::play(int p) { + if(pl->currentplaying() != -1) + pl->freeMemory(pl->currentplaying()); pl->setCurrentPlaying(p); //pl->beginDownload(p); } void sPlayer::stop() { - pl->setCurrentPlaying(-1); + media->stop(); + if(pl->currentplaying() != -1) + pl->markPlayed(pl->currentplaying()); + pl->setCurrentPlaying(-1); playing = false; } -- 1.7.9.5