Fix immediate playback
authorElias Woods <EliasWoods@gmail.com>
Fri, 25 Jun 2010 09:52:01 +0000 (05:52 -0400)
committerElias Woods <EliasWoods@gmail.com>
Fri, 25 Jun 2010 09:52:01 +0000 (05:52 -0400)
better memory management

Groove.pro.user
playlist.cpp
splayer.cpp

index 334fa29..0bf42b9 100644 (file)
     </valuemap>
     <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">1</value>
     <valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
-     <value key="192.168.1.3" type="QDateTime">2010-06-25T04:22:04</value>
+     <value key="192.168.1.3" type="QDateTime">2010-06-25T05:45:13</value>
     </valuemap>
     <value key="Qt4ProjectManager.MaemoRunConfiguration.Simulator" type="QString"></value>
    </valuemap>
index fbcf8f4..4fbdad7 100644 (file)
@@ -6,7 +6,8 @@ playlist::playlist(QObject *parent) :
    manager = new QNetworkAccessManager();
    this->currentdownloaditem = -1;
    pList = new QList<songElement *>;
-   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);
index a2349b2..e642dd1 100644 (file)
@@ -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;
 }