From 38edd2e78c326059209c1fd15bf1b543f5fd7a46 Mon Sep 17 00:00:00 2001 From: Comment Date: Mon, 30 Sep 2013 11:51:58 +0100 Subject: mutex locking progress bar --- rotord/src/graph.cpp | 2 ++ rotord/src/graph.h | 3 +++ rotord/src/rendercontext.cpp | 2 ++ rotord/src/rendercontext.h | 14 +++++++++----- rotord/src/rotord.cpp | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) (limited to 'rotord/src') diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index f904a9d..b70684f 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -211,7 +211,9 @@ bool Graph::video_render(const string &output_filename,const float framerate,int exporter.encodeFrame(i->RGBdata); } vf+=vstep; + mutex.lock(); progress=vf/duration; + mutex.unlock(); if (usingaudio) {delete a;}; } diff --git a/rotord/src/graph.h b/rotord/src/graph.h index a13bddf..b775c5a 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -77,6 +77,9 @@ namespace Rotor { float progress; int bitRate; + Poco::Mutex mutex; //lock for access from parent thread + + Audio_thumbnailer *audio_thumb; private: int outW,outH; diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index 1beb6cc..2a9dd62 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -490,9 +490,11 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (command.commands[1]=="render") { if (command.method=="GET") { if(state==RENDERING){ + graph.mutex.lock(); status=HTTPResponse::HTTP_OK; XML.addValue("status","Rendering video"); XML.addValue("progress",toString(graph.progress)); + graph.mutex.unlock(); } else { logger.error("ERROR: Render progress requested but not rendering"); diff --git a/rotord/src/rendercontext.h b/rotord/src/rendercontext.h index 130c678..0cecf49 100644 --- a/rotord/src/rendercontext.h +++ b/rotord/src/rendercontext.h @@ -82,23 +82,25 @@ namespace Rotor { } //interrupt locking process Render_status get_render_status(const string &uid){ - //cerr<<"render status requested: "< work_queue; std::unordered_map renders; - Poco::Mutex mutex; //lock for access from parent thread - std::string output_filename; std::string graph_dir; std::string media_dir; @@ -106,6 +108,8 @@ namespace Rotor { std::string graph_filename; std::string graph_body; + Poco::Mutex mutex; //lock for access from parent thread + Audio_thumbnailer *audio_thumb; Graph graph; float output_framerate; diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp index a22c6c3..de853e4 100644 --- a/rotord/src/rotord.cpp +++ b/rotord/src/rotord.cpp @@ -29,7 +29,7 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS theuri.getPathSegments(command); Logger& logger = Logger::get("Rotor"); - logger.information(request.clientAddress().toString()+" "+request.getMethod()); + //logger.information(request.clientAddress().toString()+" "+request.getMethod()); HTTPResponse::HTTPStatus status=HTTPResponse::HTTP_BAD_REQUEST; //by default -- cgit v1.2.3