Commit cba9fffa authored by Francois Cartegnie's avatar Francois Cartegnie

stream_filter: dash: fix double buffer alloc

parent 58e9be2a
...@@ -58,24 +58,17 @@ void* DASHDownloader::download (void *thread_sys) ...@@ -58,24 +58,17 @@ void* DASHDownloader::download (void *thread_sys)
thread_sys_t *t_sys = (thread_sys_t *) thread_sys; thread_sys_t *t_sys = (thread_sys_t *) thread_sys;
HTTPConnectionManager *conManager = t_sys->conManager; HTTPConnectionManager *conManager = t_sys->conManager;
BlockBuffer *buffer = t_sys->buffer; BlockBuffer *buffer = t_sys->buffer;
block_t *block = block_Alloc(BLOCKSIZE);
int ret = 0; int ret = 0;
do do
{ {
ret = conManager->read(block); block_t *block = NULL;
ret = conManager->read(&block, BLOCKSIZE);
if(ret > 0) if(ret > 0)
{ buffer->put(block);
block_t *bufBlock = block_Alloc(ret);
memcpy(bufBlock->p_buffer, block->p_buffer, ret);
bufBlock->i_length = block->i_length;
buffer->put(bufBlock);
}
}while(ret && !buffer->getEOF()); }while(ret && !buffer->getEOF());
buffer->setEOF(true); buffer->setEOF(true);
block_Release(block);
return NULL; return NULL;
} }
...@@ -58,7 +58,7 @@ void HTTPConnectionManager::closeAllConnections ...@@ -58,7 +58,7 @@ void HTTPConnectionManager::closeAllConnections
vlc_delete_all(this->connectionPool); vlc_delete_all(this->connectionPool);
vlc_delete_all(this->downloadQueue); vlc_delete_all(this->downloadQueue);
} }
int HTTPConnectionManager::read (block_t *block) int HTTPConnectionManager::read(block_t **pp_block, size_t len)
{ {
if(this->downloadQueue.size() == 0) if(this->downloadQueue.size() == 0)
if(!this->addChunk(this->adaptationLogic->getNextChunk())) if(!this->addChunk(this->adaptationLogic->getNextChunk()))
...@@ -70,6 +70,10 @@ int HTTPConnectionManager::read ...@@ -70,6 +70,10 @@ int HTTPConnectionManager::read
int ret = 0; int ret = 0;
block_t *block = block_Alloc(len);
if(!block)
return -1;
mtime_t start = mdate(); mtime_t start = mdate();
ret = this->downloadQueue.front()->getConnection()->read(block->p_buffer, block->i_buffer); ret = this->downloadQueue.front()->getConnection()->read(block->p_buffer, block->i_buffer);
mtime_t end = mdate(); mtime_t end = mdate();
...@@ -80,6 +84,7 @@ int HTTPConnectionManager::read ...@@ -80,6 +84,7 @@ int HTTPConnectionManager::read
if(ret <= 0) if(ret <= 0)
{ {
block_Release(block);
this->bpsLastChunk = this->bpsCurrentChunk; this->bpsLastChunk = this->bpsCurrentChunk;
this->bytesReadChunk = 0; this->bytesReadChunk = 0;
this->timeChunk = 0; this->timeChunk = 0;
...@@ -87,13 +92,16 @@ int HTTPConnectionManager::read ...@@ -87,13 +92,16 @@ int HTTPConnectionManager::read
delete(this->downloadQueue.front()); delete(this->downloadQueue.front());
this->downloadQueue.pop_front(); this->downloadQueue.pop_front();
return this->read(block); return this->read(pp_block, len);
} }
else else
{ {
this->updateStatistics(ret, time); this->updateStatistics(ret, time);
block->i_buffer = ret;
} }
*pp_block = block;
return ret; return ret;
} }
void HTTPConnectionManager::attach (IDownloadRateObserver *observer) void HTTPConnectionManager::attach (IDownloadRateObserver *observer)
......
...@@ -49,7 +49,7 @@ namespace dash ...@@ -49,7 +49,7 @@ namespace dash
void closeAllConnections (); void closeAllConnections ();
bool addChunk (Chunk *chunk); bool addChunk (Chunk *chunk);
int read (block_t *block); int read (block_t **, size_t);
void attach (dash::logic::IDownloadRateObserver *observer); void attach (dash::logic::IDownloadRateObserver *observer);
void notify (); void notify ();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment