diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2017-04-04 11:05:38 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2017-04-04 11:05:38 +0200 |
commit | 63a32ce4833fe7200cea4b85ee31ddc91d23db6e (patch) | |
tree | 23adc8749ed5d99d3f0420800970f0dc84e1c8c1 /svdrp.c | |
parent | 7170c20c7e8e63882415ea5d9569dc1eea200676 (diff) | |
download | vdr-63a32ce4833fe7200cea4b85ee31ddc91d23db6e.tar.gz vdr-63a32ce4833fe7200cea4b85ee31ddc91d23db6e.tar.bz2 |
Fixed a deadlock in the SVDRP command PLAY in case there is currently a recording being replayed
Diffstat (limited to 'svdrp.c')
-rw-r--r-- | svdrp.c | 53 |
1 files changed, 31 insertions, 22 deletions
@@ -10,7 +10,7 @@ * and interact with the Video Disk Recorder - or write a full featured * graphical interface that sits on top of an SVDRP connection. * - * $Id: svdrp.c 4.14 2017/04/04 09:39:36 kls Exp $ + * $Id: svdrp.c 4.15 2017/04/04 11:01:10 kls Exp $ */ #include "svdrp.h" @@ -2057,29 +2057,38 @@ void cSVDRPServer::CmdPLAY(const char *Option) char c = *option; *option = 0; if (isnumber(num)) { - LOCK_RECORDINGS_READ; - if (const cRecording *Recording = Recordings->GetById(strtol(num, NULL, 10))) { - if (c) - option = skipspace(++option); - cReplayControl::SetRecording(NULL); - cControl::Shutdown(); - if (*option) { - int pos = 0; - if (strcasecmp(option, "BEGIN") != 0) - pos = HMSFToIndex(option, Recording->FramesPerSecond()); - cResumeFile Resume(Recording->FileName(), Recording->IsPesRecording()); - if (pos <= 0) - Resume.Delete(); - else - Resume.Save(pos); + cStateKey StateKey; + if (const cRecordings *Recordings = cRecordings::GetRecordingsRead(StateKey)) { + if (const cRecording *Recording = Recordings->GetById(strtol(num, NULL, 10))) { + cString FileName = Recording->FileName(); + cString Title = Recording->Title(); + int FramesPerSecond = Recording->FramesPerSecond(); + bool IsPesRecording = Recording->IsPesRecording(); + StateKey.Remove(); // must give up the lock for the call to cControl::Shutdown() + if (c) + option = skipspace(++option); + cReplayControl::SetRecording(NULL); + cControl::Shutdown(); + if (*option) { + int pos = 0; + if (strcasecmp(option, "BEGIN") != 0) + pos = HMSFToIndex(option, FramesPerSecond); + cResumeFile Resume(FileName, IsPesRecording); + if (pos <= 0) + Resume.Delete(); + else + Resume.Save(pos); + } + cReplayControl::SetRecording(FileName); + cControl::Launch(new cReplayControl); + cControl::Attach(); + Reply(250, "Playing recording \"%s\" [%s]", num, *Title); + } + else { + StateKey.Remove(); + Reply(550, "Recording \"%s\" not found", num); } - cReplayControl::SetRecording(Recording->FileName()); - cControl::Launch(new cReplayControl); - cControl::Attach(); - Reply(250, "Playing recording \"%s\" [%s]", num, Recording->Title()); } - else - Reply(550, "Recording \"%s\" not found", num); } else Reply(501, "Error in recording number \"%s\"", num); |