X-Git-Url: http://git.maemo.org/git/?p=groove;a=blobdiff_plain;f=playlist.cpp;fp=playlist.cpp;h=10f7d498439d06ceda5713f59467aa1c43d8cc78;hp=4fbdad7f0beb6f60fbd4799dd1a0fe48e1544038;hb=256f3e93e093f74932bbf2ac33d9aa74d24a9134;hpb=80457891b14cd66154daf083a7ad3eae1d7e4b2e diff --git a/playlist.cpp b/playlist.cpp index 4fbdad7..10f7d49 100644 --- a/playlist.cpp +++ b/playlist.cpp @@ -19,6 +19,10 @@ void playlist::freeMemory(int position) pList->at(position)->buffer->~QBuffer(); pList->at(position)->buffer = new QBuffer(); } +bool playlist::existAt(int position) +{ + return (pList->size() > position); +} int playlist::currentplaying() { @@ -26,7 +30,10 @@ int playlist::currentplaying() } bool playlist::bReady(int b) { - return pList->at(b)->bufferready; + if(pList->size() > b) + return pList->at(b)->bufferready; + else + return false; } void playlist::setBufferRdy(int b) { @@ -63,8 +70,7 @@ void playlist::beginDownload(int position) req.setUrl(*pList->at(currentdownloaditem)->server); qDebug() << pList->at(currentdownloaditem)->server; req.setHeader(req.ContentTypeHeader,QVariant("application/x-www-form-urlencoded")); - if(reply) - reply->~QNetworkReply(); + delete reply; reply = manager->post(req,QString("streamKey=" + pList->at(this->currentdownloaditem)->streamkey->toAscii()).toAscii()); pList->at(this->currentdownloaditem)->buffer->open(QBuffer::ReadWrite | QBuffer::Truncate); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadSlot(qint64,qint64))); @@ -88,6 +94,7 @@ void playlist::skeyFound() else if(this->currentplaying() == this->currentSkeyItem) this->beginDownload(this->currentSkeyItem); + this->currentSkeyItem = -1; } int playlist::addSong(QStandardItem *item) @@ -110,7 +117,7 @@ int playlist::addSong(QStandardItem *item) void playlist::downloadDone(int position) { - if(pList->size() < position+1) + if(this->existAt(position+1) && this->currentSkeyItem == -1) beginDownload(position+1); else this->currentdownloaditem = -1;