diff --git a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp index 7259af6495..e672f9b95a 100644 --- a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp +++ b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.cpp @@ -10,6 +10,8 @@ #include #include +#include "debug.h" + // 10 seconds timeout #define HTTP_TIMEOUT 10000000 @@ -29,7 +31,10 @@ public: fInitSem = create_sem(0, "http_streamer init sem"); } - virtual ~FileListener() {}; + virtual ~FileListener() + { + _ReleaseInit(); + } bool ConnectionSuccessful() const { @@ -47,8 +52,10 @@ public: void DataReceived(BUrlRequest* request, const char* data, off_t position, ssize_t size) { - if (request != fRequest) + if (request != fRequest) { delete request; + return; + } BHttpRequest* httpReq = dynamic_cast(request); if (httpReq != NULL) { @@ -111,16 +118,29 @@ HTTPMediaIO::HTTPMediaIO(BUrl url) BAdapterIO(B_MEDIA_STREAMING | B_MEDIA_SEEKABLE, HTTP_TIMEOUT), fContext(NULL), fReq(NULL), - fReqThread(-1), fListener(NULL), + fReqThread(-1), fUrl(url), fIsMutable(false) { + CALLED(); + + // The context has the same life time of the object + fContext = new BUrlContext(); + fContext->AcquireReference(); } HTTPMediaIO::~HTTPMediaIO() { + CALLED(); + + fReq->Stop(); + status_t status; + wait_for_thread(fReqThread, &status); + + fContext->ReleaseReference(); + delete fContext; } @@ -150,8 +170,7 @@ HTTPMediaIO::SetSize(off_t size) status_t HTTPMediaIO::Open() { - fContext = new BUrlContext(); - fContext->AcquireReference(); + CALLED(); fListener = new FileListener(this); @@ -173,23 +192,6 @@ HTTPMediaIO::Open() } -void -HTTPMediaIO::Close() -{ - fReq->Stop(); - status_t status; - wait_for_thread(fReqThread, &status); - - delete fReq; - delete fListener; - - fContext->ReleaseReference(); - delete fContext; - - BAdapterIO::Close(); -} - - bool HTTPMediaIO::IsRunning() const { diff --git a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h index f844b188d2..f348ef8f64 100644 --- a/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h +++ b/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h @@ -28,7 +28,6 @@ public: virtual status_t SetSize(off_t size); virtual status_t Open(); - virtual void Close(); virtual bool IsRunning() const; diff --git a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp index 60f5dac380..c821b3d12a 100644 --- a/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp +++ b/src/add-ons/media/plugins/http_streamer/HTTPStreamerPlugin.cpp @@ -8,21 +8,28 @@ #include "HTTPMediaIO.h" +#include "debug.h" + HTTPStreamer::HTTPStreamer() { + CALLED(); } HTTPStreamer::~HTTPStreamer() { + CALLED(); } status_t HTTPStreamer::Sniff(const BUrl& url, BDataIO** source) { + CALLED(); + HTTPMediaIO* outSource = new HTTPMediaIO(url); + status_t ret = outSource->Open(); if (ret == B_OK) { *source = outSource;