Commit cba9fffa authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

stream_filter: dash: fix double buffer alloc

parent 58e9be2a
......@@ -58,24 +58,17 @@ void* DASHDownloader::download (void *thread_sys)
thread_sys_t *t_sys = (thread_sys_t *) thread_sys;
HTTPConnectionManager *conManager = t_sys->conManager;
BlockBuffer *buffer = t_sys->buffer;
block_t *block = block_Alloc(BLOCKSIZE);
int ret = 0;
do
{
ret = conManager->read(block);
block_t *block = NULL;
ret = conManager->read(&block, BLOCKSIZE);
if(ret > 0)
{
block_t *bufBlock = block_Alloc(ret);
memcpy(bufBlock->p_buffer, block->p_buffer, ret);
bufBlock->i_length = block->i_length;
buffer->put(bufBlock);
}
buffer->put(block);
}while(ret && !buffer->getEOF());
buffer->setEOF(true);
block_Release(block);
return NULL;
}
......@@ -58,7 +58,7 @@ void HTTPConnectionManager::closeAllConnections
vlc_delete_all(this->connectionPool);
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->addChunk(this->adaptationLogic->getNextChunk()))
......@@ -70,6 +70,10 @@ int HTTPConnectionManager::read
int ret = 0;
block_t *block = block_Alloc(len);
if(!block)
return -1;
mtime_t start = mdate();
ret = this->downloadQueue.front()->getConnection()->read(block->p_buffer, block->i_buffer);
mtime_t end = mdate();
......@@ -80,6 +84,7 @@ int HTTPConnectionManager::read
if(ret <= 0)
{
block_Release(block);
this->bpsLastChunk = this->bpsCurrentChunk;
this->bytesReadChunk = 0;
this->timeChunk = 0;
......@@ -87,13 +92,16 @@ int HTTPConnectionManager::read
delete(this->downloadQueue.front());
this->downloadQueue.pop_front();
return this->read(block);
return this->read(pp_block, len);
}
else
{
this->updateStatistics(ret, time);
block->i_buffer = ret;
}
*pp_block = block;
return ret;
}
void HTTPConnectionManager::attach (IDownloadRateObserver *observer)
......
......@@ -49,7 +49,7 @@ namespace dash
void closeAllConnections ();
bool addChunk (Chunk *chunk);
int read (block_t *block);
int read (block_t **, size_t);
void attach (dash::logic::IDownloadRateObserver *observer);
void notify ();
......
Supports Markdown
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