From patchwork Wed Feb 23 20:44:49 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Huelswitt X-Patchwork-Id: 11788 Received: from moutng.kundenserver.de ([212.227.126.188]) by www.linuxtv.org with esmtp (Exim 4.34) id 1D43O1-0001Mt-0k for vdr@linuxtv.org; Wed, 23 Feb 2005 21:45:33 +0100 Received: from [212.227.126.162] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1D43O4-0000Qo-00 for vdr@linuxtv.org; Wed, 23 Feb 2005 21:45:36 +0100 Received: from [80.132.205.239] (helo=video.local.muempf.de) by mrelayng.kundenserver.de with asmtp (TLSv1:EDH-RSA-DES-CBC3-SHA:168) (Exim 3.35 #1) id 1D43O4-0002Cb-00 for vdr@linuxtv.org; Wed, 23 Feb 2005 21:45:36 +0100 Received: from video.local.muempf.de (localhost [127.0.0.1]) by video.local.muempf.de (8.12.6/8.12.6/SuSE Linux 0.6) with ESMTP id j1NKinjW015555 for ; Wed, 23 Feb 2005 21:44:49 +0100 Received: (from news@localhost) by video.local.muempf.de (8.12.6/8.12.6/Submit) id j1NKindS015554 for vdr@linuxtv.org; Wed, 23 Feb 2005 21:44:49 +0100 To: vdr@linuxtv.org Path: not-for-mail From: s.huelswitt@gmx.de (Stefan Huelswitt) Newsgroups: local.linux.vdr Subject: Re: [vdr] MP3/MPlayer plugin 0.9.11 (development) Date: Wed, 23 Feb 2005 20:44:49 +0000 (UTC) Organization: Home, sweet home Lines: 259 Sender: nathan@gmx.de Message-ID: References: <4218268A.10001@syphir.sytes.net> <4218B9C2.4020302@syphir.sytes.net> <4218D894.20008@syphir.sytes.net> NNTP-Posting-Host: master.local.muempf.de Mime-Version: 1.0 X-Trace: video.local.muempf.de 1109191489 14796 192.168.1.1 (23 Feb 2005 20:44:49 GMT) X-Complaints-To: s.huelswitt@gmx.de NNTP-Posting-Date: Wed, 23 Feb 2005 20:44:49 +0000 (UTC) X-Newsreader: knews 1.0b.1 X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:ad11259134df5e6b2749af0524d71867 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2005 20:45:33 -0000 Status: O X-Status: X-Keywords: X-UID: 289 On 20 Feb 2005 "C.Y.M" wrote: > Here is an example of the error in the syslog: > > Feb 20 10:28:06 sid vdr[7544]: mp3: player thread started (pid=7544) > Feb 20 10:28:08 sid vdr[4248]: error reading '/dev/input/event2' > Feb 20 10:28:11 sid vdr[7545]: ERROR: thread 81926 won't end (waited 3 seconds) > - canceling it... > Feb 20 10:28:22 sid vdr[7544]: mp3: player thread ended (pid=7544) > > How to reproduce: > > Put an image file in a directory with a matching mp3 file. This error occurs > the first time the image is converted to a mpg file. Once the cache file > exists, the error does not happen any more. > > I would also like to add that everything *appears* to work correctly from a > users standpoint. The only problem is the error in the syslog (but VDR does not > actually shutdown). Does this patch solves the problem? Regards. diff -urN -x '*.o' -x .dependencies mp3-0.9.11/data-mp3.c mp3-unstable/data-mp3.c --- mp3-0.9.11/data-mp3.c 2005-02-19 12:11:41.000000000 +0100 +++ mp3-unstable/data-mp3.c 2005-02-22 18:18:58.000000000 +0100 @@ -45,7 +39,65 @@ const char *imagecache = "/var/cache/images/mp3"; const char *imageconv = "image_convert.sh"; -// --- cSong ------------------------------------------------------------- +// --- cImageConvert ----------------------------------------------------------- + +class cImageConvert : private cThread { +private: + char *image; + enum eStatus { stNone, stRun, stFin }; + eStatus status; +protected: + virtual void Action(void); +public: + cImageConvert(void); + ~cImageConvert(); + bool Convert(const char *Image); + bool Status(void); + }; + +cImageConvert::cImageConvert(void) +{ + image=0; status=stNone; +} + +cImageConvert::~cImageConvert() +{ + if(status==stRun) Cancel(10); + free(image); +} + +bool cImageConvert::Convert(const char *Image) +{ + if(status==stNone) { + image=strdup(Image); + status=stRun; + Start(); + return true; + } + return false; +} + +bool cImageConvert::Status(void) +{ + if(status==stRun && !Active()) status=stFin; + return status==stFin; +} + +void cImageConvert::Action(void) +{ + nice(3); + char *m, *cmd, *qp, *qm; + asprintf(&m,"%s%s.mpg",imagecache,image); + di(printf("image: convert started %s -> %s\n",image,m)) + asprintf(&cmd,"%s \"%s\" \"%s\"",imageconv,qp=Quote(image),qm=Quote(m)); + int r=system(cmd); + if(r!=0) di(printf("image: convert returned with code %d. Failed?\n",r)) + free(cmd); free(qp); free(qm); free(m); + di(printf("image: convert finished\n")) + status=stFin; +} + +// --- cSong ------------------------------------------------------------------- cSong::cSong(cFileObj *Obj) { @@ -67,10 +119,7 @@ cSong::~cSong() { - if(queuePid>0) { - kill(queuePid,SIGTERM); - waitpid(queuePid,0,0); - } + delete conv; delete decoder; obj->Source()->Unblock(); delete obj; @@ -79,15 +128,23 @@ void cSong::Init(void) { - decoder=0; user=0; image=0; queuePid=0; + decoder=0; user=0; image=0; conv=0; queueStat=0; fromDOS=decoderFailed=false; obj->Source()->Block(); } +#if VDRVERSNUM >= 10315 int cSong::Compare(const cListObject &ListObject) const +#else +bool cSong::operator<(const cListObject &ListObject) +#endif { cSong *song=(cSong *)&ListObject; +#if VDRVERSNUM >= 10315 return strcasecmp(obj->Path(),song->obj->Path()); +#else + return strcasecmp(obj->Path(),song->obj->Path())<0; +#endif } cSongInfo *cSong::Info(bool get) @@ -229,12 +286,13 @@ bool cSong::Image(unsigned char * &mem, int &len) { mem=0; - if(queuePid>0) { - if(!waitpid(queuePid,0,WNOHANG)) { + if(queueStat>0) { + if(!conv->Status()) { di(printf("image: still queued\n")) return false; } - queuePid=-1; + queueStat=-1; + delete conv; conv=0; } int res=0; @@ -244,31 +302,19 @@ asprintf(&m,"%s%s.mpg",imagecache,image); if(access(m,R_OK)) { di(printf("image: not cached\n")) - if(queuePid<0) { + if(queueStat<0) { di(printf("image: obviously convert failed...\n")) } else { - int pid=fork(); - if(pid==0) { // child - nice(3); - di(printf("image: convert started %s -> %s\n",image,m)) - char *m, *cmd, *qp, *qm; - asprintf(&m,"%s%s.mpg",imagecache,image); - asprintf(&cmd,"%s \"%s\" \"%s\"",imageconv,qp=Quote(image),qm=Quote(m)); - int r=system(cmd); - if(r!=0) di(printf("image: convert returned with code %d. Failed?\n",r)) - free(cmd); free(qp); free(qm); free(m); - di(printf("image: convert finished\n")) - exit(0); - } - else if(pid>0) { + if(!conv) conv=new cImageConvert; + if(conv && conv->Convert(image)) { di(printf("image: convert queued\n")) - queuePid=pid; + queueStat=1; res=-1; } else { di(printf("image: queueing failed\n")) - queuePid=-1; + queueStat=-1; } } } @@ -349,10 +395,18 @@ } } +#if VDRVERSNUM >= 10315 int cPlayList::Compare(const cListObject &ListObject) const +#else +bool cPlayList::operator<(const cListObject &ListObject) +#endif { cPlayList *list=(cPlayList *)&ListObject; +#if VDRVERSNUM >= 10315 return strcasecmp(obj->Name(),list->obj->Name()); +#else + return strcasecmp(obj->Name(),list->obj->Name())<0; +#endif } bool cPlayList::Load(void) diff -urN -x '*.o' -x .dependencies mp3-0.9.11/data-mp3.h mp3-unstable/data-mp3.h --- mp3-0.9.11/data-mp3.h 2005-02-11 18:00:07.000000000 +0100 +++ mp3-unstable/data-mp3.h 2005-02-22 18:12:09.000000000 +0100 @@ -30,6 +30,7 @@ class cDecoder; class cSongInfo; +class cImageConvert; extern const char *imagecache, *imageconv; @@ -45,7 +46,8 @@ cMutex decLock; // const char *image; - int queuePid; + cImageConvert *conv; + int queueStat; // void Init(void); char *Convert2Unix(const char *name) const; @@ -56,7 +58,11 @@ cSong(cFileSource *Source, const char *Subdir, const char *Name); cSong(cSong *Song); ~cSong(); +#if VDRVERSNUM >= 10315 virtual int Compare(const cListObject &ListObject) const; +#else + virtual bool operator<(const cListObject &ListObject); +#endif bool Parse(char *s, const char *reldir) const; bool Save(FILE *f, const char *reldir) const; void Convert(void); @@ -86,7 +92,11 @@ ~cPlayList(); virtual bool Load(void); virtual bool Save(void); +#if VDRVERSNUM >= 10315 virtual int Compare(const cListObject &ListObject) const; +#else + virtual bool operator<(const cListObject &ListObject); +#endif // bool Rename(const char *newName); bool Delete(void);