MP3/MPlayer plugin 0.9.11 (development)
Commit Message
On 20 Feb 2005 "C.Y.M" <syphir@syphir.sytes.net> 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.
Comments
Stefan Huelswitt wrote:
> 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 -----------------------------------------------------------
Thank you, Stefan. This fixes that threading issue I was talking about a few
days ago when an image is generated (not yet in cache). Although, now with this
new patch, the image does not display until I re-select the mp3 (if the image is
not already in cache). But, its better than before. :)
Thanks again....
On 24 Feb 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
> Thank you, Stefan. This fixes that threading issue I was talking about a few
> days ago when an image is generated (not yet in cache). Although, now with this
> new patch, the image does not display until I re-select the mp3 (if the image is
> not already in cache). But, its better than before. :)
Can you please mail me a console log for the case of a not
already cached image?
Regards.
Stefan Huelswitt wrote:
> On 24 Feb 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
>
>
>>Thank you, Stefan. This fixes that threading issue I was talking about a few
>>days ago when an image is generated (not yet in cache). Although, now with this
>>new patch, the image does not display until I re-select the mp3 (if the image is
>>not already in cache). But, its better than before. :)
>
>
> Can you please mail me a console log for the case of a not
> already cached image?
>
Sure.. I have a default "background.jpg" background image set. First I deleted
the "background.jpg.mpg" file from cache. Then I selected a song to play.. the
background was black. Next, I added another song to the que and the background
image was then shown (because the first song regenerated the cache).
Feb 24 11:11:43 sid vdr[17893]: mp3: playback started with instant playlist
Weird Al Yankovic - it's all about the pentiums.mp3
Feb 24 11:11:43 sid vdr[26611]: transfer thread ended (pid=26611, tid=2392077)
Feb 24 11:11:43 sid vdr[20123]: TS buffer on device 1 thread ended (pid=20123,
tid=2342924)
Feb 24 11:11:43 sid vdr[20122]: buffer stats: 95128 (4%) used
Feb 24 11:11:43 sid vdr[20122]: receiver on device 1 thread ended (pid=20122,
tid=2326539)
Feb 24 11:11:43 sid vdr[17893]: buffer stats: 155852 (7%) used
Feb 24 11:11:43 sid vdr[11463]: Text2Skin: menu display update thread ended
(pid=11463, tid=2441225)
Feb 24 11:11:43 sid vdr[11791]: mp3: player thread started (pid=11791)
Feb 24 11:12:08 sid vdr[11953]: Text2Skin: menu display update thread started
(pid=11953, tid=2523147)
Feb 24 11:12:16 sid vdr[17893]: mp3: playback started with instant playlist
Weird Al Yankovic - Yoda.mp3
Feb 24 11:12:16 sid vdr[11953]: Text2Skin: menu display update thread ended
(pid=11953, tid=2523147)
Best Regards,
C.Y.M.
On 24 Feb 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
Sorry, but...
> Stefan Huelswitt wrote:
>> Can you please mail me a console log for the case of a not
>> already cached image?
Note the word "console"...
Regards.
Stefan Huelswitt wrote:
> On 24 Feb 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
>
> Sorry, but...
>
>
>>Stefan Huelswitt wrote:
>>
>>>Can you please mail me a console log for the case of a not
>>>already cached image?
>
>
> Note the word "console"...
>
Sorry about that...
instant: file Al Green - here I am.mp3
mgr: next -> 0
mgr: background scan thread started (pid=8297)
mgr: scanning (id3) Al Green - here I am.mp3
mgr: background scan idle
mp3: player active true requested...
norm: lim_lev=0.700000 lim_acc=12
norm: table size=13518 start=0b330000 jump=00010000
norm: accuracy 0.000000022352
mp3: play
mp3: player active true done
mp3-dvb: using DVB output
mp3: heartbeat buffer=0 now=3034
mp3: starting play
mgr: bgr-scan -> throttle (26170)
mgr: playing Al Green - here I am.mp3
mp3: found song level=0.363800 peak=1.114500
norm: gain=0.687191 dogain=1 dolimit=0 (target=0.250000 level=0.363800
peak=1.114500)
mp3: isStream=0 levelgood=1 haslevel=1
image: checking image for hades/20's - 70's/A - E/Al Green/Al Green - here I am.mp3
image: check /home/mp3/hades/20's - 70's/A - E/Al Green/Al Green - here I am.jpg
image: check /home/mp3/hades/20's - 70's/A - E/Al Green/Al Green - here I am.png
image: check /home/mp3/hades/20's - 70's/A - E/Al Green/Al Green - here I am.gif
image: check /home/mp3/hades/20's - 70's/A - E/Al Green/cover.jpg
image: check /home/mp3/hades/20's - 70's/A - E/Al Green/cover.png
image: check /home/mp3/hades/20's - 70's/A - E/Al Green/cover.gif
image: check /home/mp3/hades/20's - 70's/A - E/artist.jpg
image: check /home/mp3/hades/20's - 70's/A - E/artist.png
image: check /home/mp3/hades/20's - 70's/A - E/artist.gif
image: check /home/mp3/background.jpg
image: found
image: loading image /home/mp3/background.jpg
image: not cached
image: convert queued
image: using static default image
image: convert started /home/mp3/background.jpg ->
/etc/vdr/images/home/mp3/background.jpg.mpg
mad: decode hdr error, frame=0 count=1: lost synchronization
mp3: heartbeat buffer=0 now=3035
image: still queued
mp3: new input sample rate 44100
mad: new resample ratio 0.918750 (from 44100 kHz to 48000 kHz)
mgr: bgr-scan -> run (26734)
mgr: background scan idle wakeup
mgr: background scan idle
image: still queued
image: still queued
image: still queued
image: convert finished
mp3: heartbeat buffer=1047856 now=3036
image: loading image /home/mp3/background.jpg
image: cached
mp3: write delayed 653 ms
instant: file Al Green - let's get married.mp3
mgr: background scan idle wakeup
mgr: scanning (id3) Al Green - let's get married.mp3
mgr: background scan idle
mp3: heartbeat buffer=1047856 now=3056
mp3: skip to start of song
mp3: stopping play
mp3: scale stats clipped=0 peak_clip=0.000000 peak=0.708483
norm: stats tot=2370816 lim=0/0.000% clip=0/0.000% peak=0.715
mgr: bgr-scan -> throttle (48116)
mp3: starting play
mgr: playing Al Green - here I am.mp3
mp3: found song level=0.363800 peak=1.114500
norm: gain=0.687191 dogain=1 dolimit=0 (target=0.250000 level=0.363800
peak=1.114500)
mp3: isStream=0 levelgood=1 haslevel=1
image: loading image /home/mp3/background.jpg
image: cached
mad: decode hdr error, frame=0 count=1: lost synchronization
mgr: bgr-scan -> run (48486)
mgr: background scan idle wakeup
mgr: background scan idle
action: poll logger 0: Interrupted system call
mp3: player active false requested...
mp3: stopping play
mp3: scale stats clipped=0 peak_clip=0.000000 peak=0.708483
norm: stats tot=1656576 lim=0/0.000% clip=0/0.000% peak=0.715
mp3: player active false done
mgr: background scan idle wakeup
mgr: background scan thread ended (pid=8297)
cache: saved cache to file
@@ -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)
@@ -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);