diff options
author | methodus <methodus@web.de> | 2012-10-22 04:32:50 +0200 |
---|---|---|
committer | methodus <methodus@web.de> | 2012-10-22 04:32:50 +0200 |
commit | f64cb39000006328cec4204edbce9a89cae3e087 (patch) | |
tree | 63c93a1c79f31d14f2531ace6449641adc69c5f9 | |
parent | b419a39697be8257dfbdf26116ea022adf0da2e8 (diff) | |
download | vdr-plugin-upnp-f64cb39000006328cec4204edbce9a89cae3e087.tar.gz vdr-plugin-upnp-f64cb39000006328cec4204edbce9a89cae3e087.tar.bz2 |
Seeking finally works even on TV sets.
-rw-r--r-- | httptnt/resourceStreamer.ecpp | 22 | ||||
-rw-r--r-- | media/mediaManager.cpp | 4 | ||||
-rw-r--r-- | plugins/provider/recProvider/recProvider.cpp | 6 |
3 files changed, 15 insertions, 17 deletions
diff --git a/httptnt/resourceStreamer.ecpp b/httptnt/resourceStreamer.ecpp index 9fddecc..5d26a43 100644 --- a/httptnt/resourceStreamer.ecpp +++ b/httptnt/resourceStreamer.ecpp @@ -43,7 +43,7 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object reply.setHeader("contentFeatures.dlna.org ", streamer->GetContentFeatures()); reply.setHeader("transferMode.dlna.org ", streamer->GetTransferMode(reply.getHeader("transferMode.dlna.org"))); - unsigned long from = 0, to = 0, contentLength = streamer->GetContentLength(), length = contentLength; + size_t from = 0, to = 0, contentLength = streamer->GetContentLength(), length = contentLength; bool hasRange = false; if(contentLength > 0){ @@ -77,36 +77,30 @@ int doRequest(tnt::HttpReply reply, tnt::HttpRequest request, std::string object if(!request.isMethodHEAD()){ if(!streamer->Open()){ - code = HTTP_INTERNAL_SERVER_ERROR; - goto ret; + return HTTP_INTERNAL_SERVER_ERROR; } if(hasRange && streamer->Seekable() && contentLength > 0){ if(!streamer->Seek(from, SEEK_SET)){ - code = HTTP_INTERNAL_SERVER_ERROR; - goto close; + return HTTP_INTERNAL_SERVER_ERROR; } code = HTTP_PARTIAL_CONTENT; } reply.setDirectMode(code); - ssize_t bytesRead = 0; - char buffer[KB(20)]; - while ((bytesRead = streamer->Read(buffer, KB(20))) > 0) { + size_t bytesRead = 0; + char buffer[KB(16)]; + while ((bytesRead = streamer->Read(buffer, KB(16))) > 0 && length) { reply.out().write(buffer, bytesRead); + length -= bytesRead; if (!reply.out()) { code = HTTP_GONE; - goto close; + break; } } - } else { - goto ret; } - close: - streamer->Close(); - ret: reply.out() << std::flush; return code; </%cpp> diff --git a/media/mediaManager.cpp b/media/mediaManager.cpp index 18f8255..4820a01 100644 --- a/media/mediaManager.cpp +++ b/media/mediaManager.cpp @@ -46,6 +46,8 @@ cResourceStreamer::cResourceStreamer(cMediaManager* manager, cUPnPResourceProvid } cResourceStreamer::~cResourceStreamer(){ + if(provider) + provider->Close(); delete resource; delete provider; } @@ -679,7 +681,7 @@ cResourceStreamer* cMediaManager::GetResourceStreamer(const string& objectID, in if(!row.isNull(property::resource::KEY_SAMPLE_FREQUENCY)) ret = resource->SetSampleFrequency(row.getInt32(property::resource::KEY_SAMPLE_FREQUENCY)); if(!row.isNull(property::resource::KEY_SIZE)) - ret = resource->SetSize(row.getInt32(property::resource::KEY_SIZE)); + ret = resource->SetSize(row.getInt64(property::resource::KEY_SIZE)); if(!ret) { delete resource; diff --git a/plugins/provider/recProvider/recProvider.cpp b/plugins/provider/recProvider/recProvider.cpp index f2e0fa0..fea182a 100644 --- a/plugins/provider/recProvider/recProvider.cpp +++ b/plugins/provider/recProvider/recProvider.cpp @@ -52,8 +52,10 @@ private: vector<size_t> offsets; void CloseFile(){ - fclose(fileFD); - fileFD = NULL; + if(fileFD){ + fclose(fileFD); + fileFD = NULL; + } } bool OpenFile(int i = 1){ |