diff options
Diffstat (limited to 'rotord/src/rendercontext.cpp')
| -rw-r--r-- | rotord/src/rendercontext.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index e028773..4825b96 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -6,14 +6,14 @@ using Poco::Logger; void Render_context::runTask() { while (!isCancelled()) { - int cmd=0; + Session_task cmd; mutex.lock(); if (work_queue.size()){ cmd=work_queue[0]; work_queue.pop_front(); } mutex.unlock(); - if(cmd==ANALYSE_AUDIO) { + if(cmd.task==ANALYSE_AUDIO) { state=ANALYSING_AUDIO; vector<Audio_processor*> processors; processors.push_back(audio_thumb); @@ -31,22 +31,25 @@ void Render_context::runTask() { state=IDLE; } } - if(cmd==RENDER) { + if(cmd.task==RENDER) { state=RENDERING; + renders[cmd.uid]=Render_status(RENDERING); if(graph.video_render(output_filename,audio_filename,output_framerate,progress)){ state=IDLE; + renders[cmd.uid].status=RENDER_READY; } else { //an error occurred: TODO have to clean up allocated data. autoptr? cerr<<"Rotor: render failed"<<endl; state=IDLE; + renders[cmd.uid].status=FAILED; } } sleep(100); } printf("Rotor: stopping thread\n"); } -void Render_context::add_queue(int item) { +void Render_context::add_queue(Session_task item) { mutex.lock(); work_queue.push_back(item); mutex.unlock(); @@ -97,7 +100,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H Poco::File f=Poco::File(audio_filename); if (f.exists()) { //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? - add_queue(ANALYSE_AUDIO); + add_queue(Session_task(command.uid,ANALYSE_AUDIO)); status=HTTPResponse::HTTP_OK; logger.information("Starting audio analysis: "+command.body); XML.addValue("status","Starting audio analysis: "+command.body); @@ -172,7 +175,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H logger.information("Loaded graph from http PUT body"); XML.addValue("status","Loaded graph from PUT body"); if (audio_loaded) { - add_queue(ANALYSE_AUDIO); + add_queue(Session_task(command.uid,ANALYSE_AUDIO)); status=HTTPResponse::HTTP_OK; logger.information("Starting audio analysis for graph: "+command.id); XML.addValue("status","Starting audio analysis for graph: "+command.id); @@ -192,7 +195,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H //the graph or the audio could load first- have to analyse the audio with vamp after the graph is loaded //for now the graph must load 1st if (audio_loaded) { - add_queue(ANALYSE_AUDIO); + add_queue(Session_task(command.uid,ANALYSE_AUDIO)); status=HTTPResponse::HTTP_OK; logger.information("Starting audio analysis for graph: "+command.id); XML.addValue("status","Starting audio analysis for graph: "+command.id); @@ -311,7 +314,7 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H if (command.body!="") { // output_framerate=ofToFloat(command.body); } - add_queue(RENDER); + add_queue(Session_task(command.uid,RENDER)); status=HTTPResponse::HTTP_OK; logger.information("Starting render: "+command.body); XML.addValue("status","Starting render: "+command.body); |
