summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-03-09 17:11:49 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2002-03-09 17:11:49 +0100
commitd5c01bbe5a4de6861f523450121c6f4c00539561 (patch)
treefb01623822bce89a12e4b4828d4f729e8dba0b16
parentcb90e9b8dc05164c5a3f1b4550003a2a55409144 (diff)
downloadvdr-d5c01bbe5a4de6861f523450121c6f4c00539561.tar.gz
vdr-d5c01bbe5a4de6861f523450121c6f4c00539561.tar.bz2
Implemented OSD for Volume and Mute
-rw-r--r--HISTORY2
-rw-r--r--dvbapi.c5
-rw-r--r--dvbapi.h6
-rw-r--r--i18n.c12
-rw-r--r--menu.c105
-rw-r--r--menu.h15
-rw-r--r--vdr.c14
7 files changed, 147 insertions, 12 deletions
diff --git a/HISTORY b/HISTORY
index 3beab653..d082d344 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1088,3 +1088,5 @@ Video Disk Recorder Revision History
to debug this one).
- Now starting the Dolby Digital output thread only if the recording actually
contains Dolby Digital audio data (thanks to Werner Fink).
+- Implemented OSD for Volume and Mute (works only if there is no other OSD
+ activity, but this should be no problem for normal use).
diff --git a/dvbapi.c b/dvbapi.c
index a0bcb1bd..dc7eba0b 100644
--- a/dvbapi.c
+++ b/dvbapi.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbapi.c 1.160 2002/03/09 11:59:39 kls Exp $
+ * $Id: dvbapi.c 1.161 2002/03/09 14:18:25 kls Exp $
*/
#include "dvbapi.h"
@@ -2702,12 +2702,13 @@ bool cDvbApi::ToggleAudioTrack(void)
return false;
}
-void cDvbApi::ToggleMute(void)
+bool cDvbApi::ToggleMute(void)
{
int OldVolume = volume;
mute = !mute;
SetVolume(0, mute);
volume = OldVolume;
+ return mute;
}
void cDvbApi::SetVolume(int Volume, bool Absolute)
diff --git a/dvbapi.h b/dvbapi.h
index 1767877d..4545eff3 100644
--- a/dvbapi.h
+++ b/dvbapi.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbapi.h 1.66 2002/03/08 17:16:31 kls Exp $
+ * $Id: dvbapi.h 1.67 2002/03/09 14:18:10 kls Exp $
*/
#ifndef __DVBAPI_H
@@ -309,8 +309,8 @@ private:
int volume;
public:
bool IsMute(void) { return mute; }
- void ToggleMute(void);
- // Turns the volume off or on.
+ bool ToggleMute(void);
+ // Turns the volume off or on and returns the new mute state.
void SetVolume(int Volume, bool Absolute = false);
// Sets the volume to the given value, either absolutely or relative to
// the current volume.
diff --git a/i18n.c b/i18n.c
index 3c62a1c6..650c611c 100644
--- a/i18n.c
+++ b/i18n.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: i18n.c 1.60 2002/03/08 16:11:34 kls Exp $
+ * $Id: i18n.c 1.61 2002/03/09 16:21:59 kls Exp $
*
* Slovenian translations provided by Miha Setina <mihasetina@softhome.net>
* Italian translations provided by Alberto Carraro <bertocar@tin.it>
@@ -1558,6 +1558,16 @@ const tPhrase Phrases[] = {
"", // TODO
"Hyppää:",
},
+ { "Volume ", // note the trailing blank
+ "Lautstärke ",
+ "", // TODO
+ "", // TODO
+ "", // TODO
+ "", // TODO
+ "Volume ",
+ "", // TODO
+ "Äänenvoimakkuus ",
+ },
{ " Stop replaying", // note the leading blank!
" Wiedergabe beenden",
" Prekini ponavljanje",
diff --git a/menu.c b/menu.c
index 4ad1fe8a..fd605aa1 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.162 2002/03/08 16:06:11 kls Exp $
+ * $Id: menu.c 1.163 2002/03/09 16:57:34 kls Exp $
*/
#include "menu.h"
@@ -2347,6 +2347,109 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
return osEnd;
}
+// --- cVolumeBar ------------------------------------------------------------
+
+class cVolumeBar : public cBitmap {
+public:
+ cVolumeBar(int Width, int Height, int Current, int Total, const char *Prompt = NULL);
+ };
+
+cVolumeBar::cVolumeBar(int Width, int Height, int Current, int Total, const char *Prompt)
+:cBitmap(Width, Height, 2)
+{
+ int l = Prompt ? cBitmap::Width(Prompt) : 0;
+ int p = (Width - l) * Current / Total;
+ Text(0, 0, Prompt, clrGreen);
+ Fill(l, 0, p, Height - 1, clrGreen);
+ Fill(l + p, 0, Width - 1, Height - 1, clrWhite);
+}
+
+// --- cDisplayVolume --------------------------------------------------------
+
+#define VOLUMETIMEOUT 1000 //ms
+#define MUTETIMEOUT 5000 //ms
+
+cDisplayVolume *cDisplayVolume::displayVolume = NULL;
+
+cDisplayVolume::cDisplayVolume(void)
+:cOsdBase(true)
+{
+ displayVolume = this;
+ timeout = time_ms() + (cDvbApi::PrimaryDvbApi->IsMute() ? MUTETIMEOUT : VOLUMETIMEOUT);
+ Interface->Open(Setup.OSDwidth, -1);
+ Show();
+}
+
+cDisplayVolume::~cDisplayVolume()
+{
+ Interface->Close();
+ displayVolume = NULL;
+}
+
+void cDisplayVolume::Show(void)
+{
+ cDvbApi *dvbApi = cDvbApi::PrimaryDvbApi;
+ if (dvbApi->IsMute()) {
+ Interface->Fill(0, 0, Width(), 1, clrTransparent);
+ Interface->Write(0, 0, tr("Mute"), clrGreen);
+ }
+ else {
+ int Current = cDvbApi::CurrentVolume();
+ int Total = MAXVOLUME;
+ const char *Prompt = tr("Volume ");
+#ifdef DEBUG_OSD
+ int l = strlen(Prompt);
+ int p = int(double(Width() - l) * Current / Total + 0.5);
+ Interface->Write(0, 0, Prompt, clrGreen);
+ Interface->Fill(l, 0, p, 1, clrGreen);
+ Interface->Fill(l + p, 0, Width() - l - p, 1, clrWhite);
+#else
+ cVolumeBar VolumeBar(Width() * dvbApi->CellWidth(), dvbApi->LineHeight(), Current, Total, Prompt);
+ Interface->SetBitmap(0, 0, VolumeBar);
+#endif
+ }
+}
+
+cDisplayVolume *cDisplayVolume::Create(void)
+{
+ if (!displayVolume)
+ new cDisplayVolume;
+ return displayVolume;
+}
+
+void cDisplayVolume::Process(eKeys Key)
+{
+ if (displayVolume)
+ displayVolume->ProcessKey(Key);
+}
+
+eOSState cDisplayVolume::ProcessKey(eKeys Key)
+{
+ switch (Key) {
+ case kVolUp|k_Repeat:
+ case kVolUp:
+ case kVolDn|k_Repeat:
+ case kVolDn:
+ Show();
+ timeout = time_ms() + VOLUMETIMEOUT;
+ break;
+ case kMute:
+ if (cDvbApi::PrimaryDvbApi->IsMute()) {
+ Show();
+ timeout = time_ms() + MUTETIMEOUT;
+ }
+ else
+ timeout = 0;
+ break;
+ case kNone: break;
+ default: if ((Key & k_Release) == 0) {
+ Interface->PutKey(Key);
+ return osEnd;
+ }
+ }
+ return time_ms() < timeout ? osContinue : osEnd;
+}
+
// --- cRecordControl --------------------------------------------------------
cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)
diff --git a/menu.h b/menu.h
index fc0302ec..a5ea0e12 100644
--- a/menu.h
+++ b/menu.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.h 1.38 2002/03/08 15:46:36 kls Exp $
+ * $Id: menu.h 1.39 2002/03/09 15:54:24 kls Exp $
*/
#ifndef _MENU_H
@@ -41,6 +41,19 @@ public:
virtual eOSState ProcessKey(eKeys Key);
};
+class cDisplayVolume : public cOsdBase {
+private:
+ int timeout;
+ static cDisplayVolume *displayVolume;
+ void Show(void);
+ cDisplayVolume(void);
+public:
+ virtual ~cDisplayVolume();
+ static cDisplayVolume *Create(void);
+ static void Process(eKeys Key);
+ eOSState ProcessKey(eKeys Key);
+ };
+
class cMenuRecordingItem;
class cMenuRecordings : public cOsdMenu {
diff --git a/vdr.c b/vdr.c
index 922bdcaa..17ae1488 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/people/kls/vdr
*
- * $Id: vdr.c 1.100 2002/03/08 17:14:43 kls Exp $
+ * $Id: vdr.c 1.101 2002/03/09 17:10:16 kls Exp $
*/
#include <getopt.h>
@@ -357,10 +357,16 @@ int main(int argc, char *argv[])
case kVolUp:
case kVolDn|k_Repeat:
case kVolDn:
- cDvbApi::PrimaryDvbApi->SetVolume(NORMALKEY(key) == kVolDn ? -VOLUMEDELTA : VOLUMEDELTA);
- break;
case kMute:
- cDvbApi::PrimaryDvbApi->ToggleMute();
+ if (key == kMute) {
+ if (!cDvbApi::PrimaryDvbApi->ToggleMute() && !Menu)
+ break; // no need to display "mute off"
+ }
+ else
+ cDvbApi::PrimaryDvbApi->SetVolume(NORMALKEY(key) == kVolDn ? -VOLUMEDELTA : VOLUMEDELTA);
+ if (!Menu && (!ReplayControl || !ReplayControl->Visible()))
+ Menu = cDisplayVolume::Create();
+ cDisplayVolume::Process(key);
break;
// Power off:
case kPower: isyslog(LOG_INFO, "Power button pressed");