From ec27c329cfeacf4687197f637d6abddd6fed25a8 Mon Sep 17 00:00:00 2001
From: Klaus Schmidinger <vdr@tvdr.de>
Date: Sat, 8 Jan 2005 10:15:30 +0100
Subject: Displaying audio track description in channel display

---
 HISTORY     |  2 ++
 device.c    | 11 +++++++---
 device.h    |  4 ++--
 menu.c      | 69 ++++++++++++++++++++++++++++++++++---------------------------
 skinsttng.c |  5 ++++-
 5 files changed, 54 insertions(+), 37 deletions(-)

diff --git a/HISTORY b/HISTORY
index c8ceb322..57e766f6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3265,6 +3265,8 @@ Video Disk Recorder Revision History
   used to get notified when the audio track has been switched.
 - Skins need to implement the new cSkinDisplayTrack class to display the audio
   track menu.
+- The ST:TNG skin now displays the current audio track description (if any) at the
+  botton left side.
 - The new setup option "DVB/Audio languages" can be used to control which audio
   language shall be selected in case a channel broadcasts in different languages
   (see MANUAL for details). 
diff --git a/device.c b/device.c
index 390cf92f..a0162fe8 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: device.c 1.70 2005/01/06 16:45:12 kls Exp $
+ * $Id: device.c 1.71 2005/01/08 10:15:00 kls Exp $
  */
 
 #include "device.h"
@@ -644,9 +644,14 @@ void cDevice::SetVolume(int Volume, bool Absolute)
      }
 }
 
-void cDevice::ClrAvailableTracks(void)
+void cDevice::ClrAvailableTracks(bool DescriptionsOnly)
 {
-  memset(availableTracks, 0, sizeof(availableTracks));
+  if (DescriptionsOnly) {
+     for (int i = ttNone; i < ttMaxTrackTypes; i++)
+         *availableTracks[i].description = 0;
+     }
+  else
+     memset(availableTracks, 0, sizeof(availableTracks));
 }
 
 bool cDevice::SetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language, const char *Description, uint32_t Flags)
diff --git a/device.h b/device.h
index 200349ee..4a9e64ea 100644
--- a/device.h
+++ b/device.h
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: device.h 1.50 2005/01/06 13:27:42 kls Exp $
+ * $Id: device.h 1.51 2005/01/08 10:15:00 kls Exp $
  */
 
 #ifndef __DEVICE_H
@@ -319,7 +319,7 @@ protected:
   virtual void SetAudioTrackDevice(eTrackType Type);
        ///< Sets the current audio track to the given value.
 public:
-  void ClrAvailableTracks(void);
+  void ClrAvailableTracks(bool DescriptionsOnly = false);
   bool SetAvailableTrack(eTrackType Type, int Index, uint16_t Id, const char *Language = NULL, const char *Description = NULL, uint32_t Flags = 0);
        ///< Sets the track of the given Type and Index to the given values.
        ///< Type must be one of the basic eTrackType values, like ttAudio or ttDolby.
diff --git a/menu.c b/menu.c
index ddaeee9b..1e8f1e4f 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: menu.c 1.329 2005/01/06 13:27:00 kls Exp $
+ * $Id: menu.c 1.330 2005/01/08 10:15:00 kls Exp $
  */
 
 #include "menu.h"
@@ -2541,6 +2541,40 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
   return state;
 }
 
+// --- SetTrackDescriptions --------------------------------------------------
+
+static void SetTrackDescriptions(void)
+{
+  cDevice::PrimaryDevice()->ClrAvailableTracks(true);
+  cChannel *Channel = Channels.GetByNumber(cDevice::CurrentChannel());
+  if (Channel) {
+     cSchedulesLock SchedulesLock;
+     const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
+     if (Schedules) {
+        const cSchedule *Schedule = Schedules->GetSchedule(Channel->GetChannelID());
+        if (Schedule) {
+           const cEvent *Present = Schedule->GetPresentEvent(true);
+           if (Present) {
+              const cComponents *Components = Present->Components();
+              if (Components) {
+                 int indexAudio = 0;
+                 int indexDolby = 0;
+                 for (int i = 0; i < Components->NumComponents(); i++) {
+                     const tComponent *p = Components->Component(i);
+                     if (p->stream == 2) {
+                        if (p->type == 0x05)
+                           cDevice::PrimaryDevice()->SetAvailableTrack(ttDolby, indexDolby++, 0, NULL, p->description);
+                        else
+                           cDevice::PrimaryDevice()->SetAvailableTrack(ttAudio, indexAudio++, 0, NULL, p->description);
+                        }
+                     }
+                 }
+              }
+           }
+        }
+     }
+}
+
 // --- cDisplayChannel -------------------------------------------------------
 
 #define DIRECTCHANNELTIMEOUT 1000 //ms
@@ -2599,6 +2633,7 @@ void cDisplayChannel::DisplayInfo(void)
            const cEvent *Present = Schedule->GetPresentEvent(true);
            const cEvent *Following = Schedule->GetFollowingEvent(true);
            if (Present != lastPresent || Following != lastFollowing) {
+              SetTrackDescriptions();
               displayChannel->SetEvents(Present, Following);
               cStatus::MsgOsdProgramme(Present ? Present->StartTime() : 0, Present ? Present->Title() : NULL, Present ? Present->ShortText() : NULL, Following ? Following->StartTime() : 0, Following ? Following->Title() : NULL, Following ? Following->ShortText() : NULL);
               lastPresent = Present;
@@ -2818,36 +2853,8 @@ cDisplayTracks::cDisplayTracks(void)
 :cOsdObject(true)
 {
   // Get the actual audio track descriptions from the EPG if we're not replaying:
-  if (!cDevice::PrimaryDevice()->Replaying() || cTransferControl::ReceiverDevice()) {
-     cChannel *Channel = Channels.GetByNumber(cDevice::CurrentChannel());
-     if (Channel) {
-        cSchedulesLock SchedulesLock;
-        const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock);
-        if (Schedules) {
-           const cSchedule *Schedule = Schedules->GetSchedule(Channel->GetChannelID());
-           if (Schedule) {
-              const cEvent *Present = Schedule->GetPresentEvent(true);
-              if (Present) {
-                 const cComponents *Components = Present->Components();
-                 if (Components) {
-                    int indexAudio = 0;
-                    int indexDolby = 0;
-                    for (int i = 0; i < Components->NumComponents(); i++) {
-                        const tComponent *p = Components->Component(i);
-                        if (p->stream == 2) {
-                           if (p->type == 0x05)
-                              cDevice::PrimaryDevice()->SetAvailableTrack(ttDolby, indexDolby++, 0, NULL, p->description);
-                           else
-                              cDevice::PrimaryDevice()->SetAvailableTrack(ttAudio, indexAudio++, 0, NULL, p->description);
-                           }
-                        }
-                    }
-                 }
-              }
-           }
-        }
-     }
-
+  if (!cDevice::PrimaryDevice()->Replaying() || cTransferControl::ReceiverDevice())
+     SetTrackDescriptions();
   currentDisplayTracks = this;
   numTracks = track = 0;
   eTrackType CurrentAudioTrack = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
diff --git a/skinsttng.c b/skinsttng.c
index 8ae0180a..a229838f 100644
--- a/skinsttng.c
+++ b/skinsttng.c
@@ -4,7 +4,7 @@
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: skinsttng.c 1.10 2005/01/02 14:41:49 kls Exp $
+ * $Id: skinsttng.c 1.11 2005/01/08 10:15:00 kls Exp $
  */
 
 // Star Trek: The Next Generation� is a registered trademark of Paramount Pictures
@@ -265,6 +265,9 @@ void cSkinSTTNGDisplayChannel::SetEvents(const cEvent *Present, const cEvent *Fo
          osd->DrawText(x3 + 2, y3 + (2 * i + 1) * lineHeight, e->ShortText(), Theme.Color(clrChannelEpgShortText), Theme.Color(clrBackground), cFont::GetFont(fontSml), x4 - x3 - 2);
          }
       }
+  cDevice *Device = cDevice::PrimaryDevice();
+  const tTrackId *Track = Device->GetTrack(Device->GetCurrentAudioTrack());
+  osd->DrawText(x3 + 2, y6, Track ? Track->description : "", Theme.Color(clrChannelName), frameColor, cFont::GetFont(fontSml), x4 - x3 - 2);
 }
 
 void cSkinSTTNGDisplayChannel::SetMessage(eMessageType Type, const char *Text)
-- 
cgit v1.2.3