summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httptnt/resourceStreamer.ecpp22
-rw-r--r--media/mediaManager.cpp4
-rw-r--r--plugins/provider/recProvider/recProvider.cpp6
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){