[vlc-commits] dash: Removing useless and potentially harmful recursion.
Hugo Beauzée-Luyssen
git at videolan.org
Fri Jan 6 12:40:39 CET 2012
vlc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Jan 5 16:40:23 2012 +0100| [2a6547a931e61fd117298662176e41751b5e197d] | committer: Jean-Baptiste Kempf
dash: Removing useless and potentially harmful recursion.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2a6547a931e61fd117298662176e41751b5e197d
---
.../dash/http/HTTPConnectionManager.cpp | 49 ++++++++++----------
1 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/modules/stream_filter/dash/http/HTTPConnectionManager.cpp b/modules/stream_filter/dash/http/HTTPConnectionManager.cpp
index d1cf529..ee377bd 100644
--- a/modules/stream_filter/dash/http/HTTPConnectionManager.cpp
+++ b/modules/stream_filter/dash/http/HTTPConnectionManager.cpp
@@ -87,14 +87,27 @@ void HTTPConnectionManager::closeAllConnections ()
this->chunkMap.clear();
}
-int HTTPConnectionManager::read (Chunk *chunk, void *p_buffer, size_t len)
+
+int HTTPConnectionManager::read( Chunk *chunk, void *p_buffer, size_t len )
{
- if(this->chunkMap.find(chunk) != this->chunkMap.end())
+ if(this->chunkMap.find(chunk) == this->chunkMap.end())
{
- mtime_t start = mdate();
- int ret = this->chunkMap[chunk]->read(p_buffer, len);
- mtime_t end = mdate();
+ this->bytesReadChunk = 0;
+ this->timeSecChunk = 0;
+
+ if ( this->initConnection( chunk ) == NULL )
+ return -1;
+ }
+ mtime_t start = mdate();
+ int ret = this->chunkMap[chunk]->read(p_buffer, len);
+ mtime_t end = mdate();
+
+ std::cout << "ret: " << ret << std::endl;
+ if( ret <= 0 )
+ this->closeConnection( chunk );
+ else
+ {
double time = ((double)(end - start)) / 1000000;
this->bytesReadSession += ret;
@@ -116,30 +129,18 @@ int HTTPConnectionManager::read (Chunk *chun
this->bpsLastChunk = 0;
this->notify();
-
- if(ret <= 0)
- this->closeConnection(chunk);
-
- return ret;
}
- else
- {
- this->bytesReadChunk = 0;
- this->timeSecChunk = 0;
+ return ret;
+}
+int HTTPConnectionManager::peek (Chunk *chunk, const uint8_t **pp_peek, size_t i_peek)
+{
+ if(this->chunkMap.find(chunk) == this->chunkMap.end())
+ {
if ( this->initConnection(chunk) == NULL )
return -1;
- return this->read(chunk, p_buffer, len);
}
-}
-int HTTPConnectionManager::peek (Chunk *chunk, const uint8_t **pp_peek, size_t i_peek)
-{
- if(this->chunkMap.find(chunk) != this->chunkMap.end())
- return this->chunkMap[chunk]->peek(pp_peek, i_peek);
-
- if ( this->initConnection(chunk) == NULL )
- return -1;
- return this->peek(chunk, pp_peek, i_peek);
+ return this->chunkMap[chunk]->peek(pp_peek, i_peek);
}
IHTTPConnection* HTTPConnectionManager::initConnection(Chunk *chunk)
More information about the vlc-commits
mailing list