mplayer.sh and AID 0

Message ID da66ht$3mo$2@video.local.muempf.de
State New
Headers

Commit Message

Stefan Huelswitt July 2, 2005, 1:58 p.m. UTC
  On 02 Jul 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:

> Ok, This is what I have seen so far (while using this new patch for the mplayer
> plugin).
> 
> If I set the AID to "default", and do not make any changes to mplayer.sh-0.8.6
> (reversing my patch above), then I am able to switch AIDs on the fly using the
> "2" key on the remote.  But, without any changes to mplayer.sh, I am not able to
> specify a particular default AID (ie; setting AID to 0,1,2,...).  This would not

Your mplayer.sh at least has to have support for the AID
parameter and (vanilla) mplayer.sh-0.8.6 doesn't have it
(AFAIK).

> Also, it appears that the mplayer plugin is still not returning "AID 0" to the
> mplayer.sh script.

Well, I checked this and found that unfortunaly one change is
missing in the patch:

-    if(MPlayerAid>0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);
+    if(MPlayerAid>=0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);

(I'll attach the whole patch for completenes)

Regards.
  

Comments

C.Y.M July 2, 2005, 2:25 p.m. UTC | #1
Stefan Huelswitt wrote:
> diff -urN -X mp3-unstable/.exclude mp3-0.9.12/mplayer.c mp3-unstable/mplayer.c
> --- mp3-0.9.12/mplayer.c	2005-02-21 18:30:01.000000000 +0100
> +++ mp3-unstable/mplayer.c	2005-07-01 19:26:51.000000000 +0200
> @@ -458,20 +458,15 @@

Thanks for the new patch.  Unfortunately, this does not seem to change anything.

1) AID 0 not returned to mplayer.sh when specified as default.  Note: APID > 0
returns properly.
2) Mplayer prefers to default to APID 1 over APID 0 (probably a mplayer problem,
not a mplayer plugin problem).
3) Mplayer is unable to switch between apids on the fly if mplayer is started
out on a non-existing apid.


In order to make use of the configurable default apid, changes will need to be
made to mplayer.sh to understand what "$AID" is.

Regards,
C.
  
C.Y.M July 2, 2005, 3:49 p.m. UTC | #2
C.Y.M wrote:
> Stefan Huelswitt wrote:
> 
>>diff -urN -X mp3-unstable/.exclude mp3-0.9.12/mplayer.c mp3-unstable/mplayer.c
>>--- mp3-0.9.12/mplayer.c	2005-02-21 18:30:01.000000000 +0100
>>+++ mp3-unstable/mplayer.c	2005-07-01 19:26:51.000000000 +0200
>>@@ -458,20 +458,15 @@
> 
> 
> Thanks for the new patch.  Unfortunately, this does not seem to change anything.
> 
> 1) AID 0 not returned to mplayer.sh when specified as default.  Note: APID > 0
> returns properly.
> 2) Mplayer prefers to default to APID 1 over APID 0 (probably a mplayer problem,
> not a mplayer plugin problem).
> 3) Mplayer is unable to switch between apids on the fly if mplayer is started
> out on a non-existing apid.
> 
> 
> In order to make use of the configurable default apid, changes will need to be
> made to mplayer.sh to understand what "$AID" is.
> 

If we keep the default AID at 0, then something like this would always apply,
wouldn't it (see below)? If there were more audio tracks, then they could be
selected with the "2" button. When attempting to play an AVI without this
change, Mplayer would first try to select AID 0 (because thats the default), and
then we could not use the "2" button to select AID 1 (reference to bug #3 above).

--SNIP--

    if test $VIDEO_FORMAT == "DIV3" -o $VIDEO_FORMAT == "XVID"; then
      echolog "*** INFO: AVI file format detected. Setting default AID to 1"
      AID=1
    fi

--SNIP--

Regards,
C.
  
Stefan Huelswitt July 2, 2005, 4:03 p.m. UTC | #3
On 02 Jul 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
> 
> Thanks for the new patch.  Unfortunately, this does not seem to change anything.
> 
> 1) AID 0 not returned to mplayer.sh when specified as default.  Note: APID > 0
> returns properly.

I cannot understand this. The code is:

if(MPlayerAid>=0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);

which clearly should work with AID==0.

> In order to make use of the configurable default apid, changes will need to be
> made to mplayer.sh to understand what "$AID" is.

Of course. This was mentioned in the HISTORY at the time the AID
feature was introduced (version 0.9.8).

Regards.
  
C.Y.M July 2, 2005, 4:25 p.m. UTC | #4
Stefan Huelswitt wrote:
> On 02 Jul 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
> 
>>Thanks for the new patch.  Unfortunately, this does not seem to change anything.
>>
>>1) AID 0 not returned to mplayer.sh when specified as default.  Note: APID > 0
>>returns properly.
> 
> 
> I cannot understand this. The code is:
> 
> if(MPlayerAid>=0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);
> 
> which clearly should work with AID==0.
> 

If I take this code in mplayer.sh and comment out the following section that
checks if AID is defined..

--SNIP--

declare FILE="$1"
#declare SLAVE="$2"
while shift; do
  if [ "$1" = "SLAVE" ]; then
    declare SLAVE="$1"
  elif [ "$1" = "AID" ]; then
    declare AID="$2"
    shift
  fi
#  if [ "$AID" = "" ]; then
#    declare AID="0"
#  fi
done

echolog "*** INFO: Audio track equals $AID"

and put some debug in to print the value of $AID, the value still comes up blank
when AID is set to 0 in the plugin.


> 
>>In order to make use of the configurable default apid, changes will need to be
>>made to mplayer.sh to understand what "$AID" is.
> 
> 
> Of course. This was mentioned in the HISTORY at the time the AID
> feature was introduced (version 0.9.8).
> 

Best Regards,
C.
  
C.Y.M July 2, 2005, 5:28 p.m. UTC | #5
C.Y.M wrote:
> Stefan Huelswitt wrote:
> 
>>On 02 Jul 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
>>
>>
>>>Thanks for the new patch.  Unfortunately, this does not seem to change anything.
>>>
>>>1) AID 0 not returned to mplayer.sh when specified as default.  Note: APID > 0
>>>returns properly.
>>
>>
>>I cannot understand this. The code is:
>>
>>if(MPlayerAid>=0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);
>>
>>which clearly should work with AID==0.
>>
> 
> 
> If I take this code in mplayer.sh and comment out the following section that
> checks if AID is defined..

> and put some debug in to print the value of $AID, the value still comes up blank
> when AID is set to 0 in the plugin.
> 

I'm sorry, I guess I made a mistake.  Your second patch *is* returning 0. I must
have gotten something mixed up.  Thanks very much.

C.
  
Juri Haberland July 2, 2005, 5:41 p.m. UTC | #6
"C.Y.M" <syphir@syphir.sytes.net> wrote:

> 2) Mplayer prefers to default to APID 1 over APID 0 (probably a mplayer problem,
> not a mplayer plugin problem).

No, this is normal. See 'man mplayer':
MPEG:      0-31
AVI/OGM:   1-99
ASF/RM:    0-127
VOB(AC3):  128-159
VOB(LPCM): 160-191
MPEG-TS:   17-8190

> 3) Mplayer is unable to switch between apids on the fly if mplayer is started
> out on a non-existing apid.
> 
> 
> In order to make use of the configurable default apid, changes will need to be
> made to mplayer.sh to understand what "$AID" is.

IMO the configurable AID stuff should be removed from the mplayer plugin
as it is a work-around for the formerly not existing
switch-audio-on-the-fly function. I've always been against this sort of
hack and told everyone in the german speaking VDR-Portal that it's not
a good idea to implement this, because, as you found out, you have to
examine the video and use different AIDs for the default audio track -
depending on whether it's a mpeg, a avi - with or without AC3 sound and
so on. I'm not willing to do this crap.

Please, Stefan, remove this mess - it was a mistake to implement it in
the first place...

Cheers,
    Juri
  
Juri Haberland July 2, 2005, 5:46 p.m. UTC | #7
"C.Y.M" <syphir@syphir.sytes.net> wrote:
> 2) Mplayer prefers to default to APID 1 over APID 0 (probably a mplayer problem,
> not a mplayer plugin problem).

For what do you need the AID stuff anyway, now that audio switching
works?

Cheers,
    Juri
  
Stefan Huelswitt July 2, 2005, 5:50 p.m. UTC | #8
On 02 Jul 2005 "C.Y.M" <syphir@syphir.sytes.net> wrote:
> C.Y.M wrote:
>
> I'm sorry, I guess I made a mistake.  Your second patch *is* returning 0. I must
> have gotten something mixed up.  Thanks very much.

No problem. I guessed something like that, but I wanted to test
this in deep before blaming somebody. ;)

Regards.
  
C.Y.M July 2, 2005, 7:15 p.m. UTC | #9
Juri Haberland wrote:
> "C.Y.M" <syphir@syphir.sytes.net> wrote:
> 
>>2) Mplayer prefers to default to APID 1 over APID 0 (probably a mplayer problem,
>>not a mplayer plugin problem).
> 
> 
> For what do you need the AID stuff anyway, now that audio switching
> works?
> 

I just want the mplayer plugin to default to the primary audio track when
playing back a .vdr file.  The way it is now, if I dont specify AID 0, it will
always default to the secondary audio track (if it exists) when playing back
.vdr files.

Best Regards,
C.
  
Stefan Huelswitt July 4, 2005, 7:09 p.m. UTC | #10
On 02 Jul 2005 Juri Haberland <list-linux.vdr@koschikode.com> wrote:

> IMO the configurable AID stuff should be removed from the mplayer plugin
> as it is a work-around for the formerly not existing
> switch-audio-on-the-fly function.
[...]
> Please, Stefan, remove this mess - it was a mistake to implement it in
> the first place...

I don't see a need to remove it.
If you don't want to use it, you can simply leave the AID set to
default or use a mplayer.sh which doesn't parse it.

Or did I miss something?

Regards.
  

Patch

diff -urN -X mp3-unstable/.exclude mp3-0.9.12/mplayer.c mp3-unstable/mplayer.c
--- mp3-0.9.12/mplayer.c	2005-02-21 18:30:01.000000000 +0100
+++ mp3-unstable/mplayer.c	2005-07-01 19:26:51.000000000 +0200
@@ -458,20 +458,15 @@ 
           case kOk: if(visible && !modeOnly) { Hide(); DoShowMode=true; }
                     else ShowTimed();
                     break;
-          case k0:  player->DvdNav(navMenu); break;
           case k1:  player->AudioDelay(1); break;
-          case k2:  player->DvdNav(navUp); break;
+          case k2:  player->SwitchAudio(); break;
           case k3:  if(visible && !modeOnly) {
                       Hide();
                       osdPos--; if(osdPos<-6) osdPos=-6;
                       ShowTimed();
                       }
                     break;
-          case k4:  player->DvdNav(navLeft); break;
-          case k5:  player->DvdNav(navSelect); break;
-          case k6:  player->DvdNav(navRight); break;
           case k7:  player->AudioDelay(-1); break;
-          case k8:  player->DvdNav(navDown); break;
           case k9:  if(visible && !modeOnly) {
                       Hide();
                       osdPos++; if(osdPos>0) osdPos=0;
@@ -499,7 +494,7 @@ 
 cMenuMPlayAid::cMenuMPlayAid(void)
 :cOsdMenu(tr("MPlayer Audio ID"),20)
 {
-  Add(new cMenuEditIntItem(tr("Audiostream ID"),&MPlayerAid,0,255));
+  Add(new cMenuEditIntItem(tr("Audiostream ID"),&MPlayerAid,-1,255));
   Display();
 }
 
@@ -538,7 +533,7 @@ 
 void cMenuMPlayBrowse::SetButtons(void)
 {
   static char blue[12];
-  snprintf(blue,sizeof(blue),"AID:%d",MPlayerAid);
+  snprintf(blue,sizeof(blue),MPlayerAid>=0 ? "AID:%d" : "AID:def",MPlayerAid);
   SetHelp(tr("Play"), MPlayerSetup.ResumeMode ? tr("Rewind"):0, tr("Source"), blue);
   Display();
 }
--- mp3-0.9.12/player-mplayer.c	2005-01-12 18:07:22.000000000 +0100
+++ mp3-unstable/player-mplayer.c	2005-07-01 19:15:41.000000000 +0200
@@ -48,7 +49,7 @@ 
 #define MPLAYER_2_VDR(x) (MIN((int)((x)*2.55),255))
 
 const char *MPlayerCmd = "mplayer.sh";
-int MPlayerAid=0;
+int MPlayerAid=-1;
 
 // -- cMPlayerStatus -----------------------------------------------------------
 
@@ -378,7 +380,7 @@ 
 
     char cmd[64+PATH_MAX*2], aid[20];
     char *fname=Quote(file->FullPath());
-    if(MPlayerAid>0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);
+    if(MPlayerAid>=0) snprintf(aid,sizeof(aid)," AID %d",MPlayerAid);
     else aid[0]=0;
     snprintf(cmd,sizeof(cmd),"%s \"%s\" %s%s",MPlayerCmd,fname,MPlayerSetup.SlaveMode?"SLAVE":"",aid);
     free(fname);
@@ -611,17 +640,10 @@ 
     }
 }
 
-void cMPlayerPlayer::DvdNav(eDvdNav mode)
+void cMPlayerPlayer::SwitchAudio(void)
 {
   if(slave) {
-    switch(mode) {
-      case navUp:     MPlayerControl("dvdnav 1"); break;
-      case navDown:   MPlayerControl("dvdnav 2"); break;
-      case navLeft:   MPlayerControl("dvdnav 3"); break;
-      case navRight:  MPlayerControl("dvdnav 4"); break;
-      case navMenu:   MPlayerControl("dvdnav 5"); break;
-      case navSelect: MPlayerControl("dvdnav 6"); break;
-      }
+    MPlayerControl("switch_audio");
     }
 }
 
diff -urN -X mp3-unstable/.exclude mp3-0.9.12/player-mplayer.h mp3-unstable/player-mplayer.h
--- mp3-0.9.12/player-mplayer.h	2005-01-09 13:33:23.000000000 +0100
+++ mp3-unstable/player-mplayer.h	2005-07-01 19:13:56.000000000 +0200
@@ -48,8 +48,6 @@ 
 
 // ----------------------------------------------------------------
 
-enum eDvdNav { navUp, navDown, navLeft, navRight, navMenu, navSelect };
-
 class cMPlayerPlayer : public cPlayer, cThread {
 private:
   cFileObj *file;
@@ -57,6 +55,7 @@ 
   cMPlayerResume *resume;
   bool started, slave, run;
   int pid, inpipe[2], outpipe[2], pipefl;
+  bool brokenPipe;
   enum ePlayMode { pmPlay, pmPaused };
   ePlayMode playMode;
   int index, total, saveIndex;
@@ -82,7 +81,7 @@ 
   void SkipSeconds(int secs);
   void Osd(void);
   void AudioDelay(int del);
-  void DvdNav(eDvdNav mode);
+  void SwitchAudio(void);
   virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame);
   virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed);
   };