1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Implemented OSD for Volume and Mute

This commit is contained in:
Klaus Schmidinger 2002-03-09 17:11:49 +01:00
parent cb90e9b8dc
commit d5c01bbe5a
7 changed files with 147 additions and 12 deletions

View File

@ -1088,3 +1088,5 @@ Video Disk Recorder Revision History
to debug this one). to debug this one).
- Now starting the Dolby Digital output thread only if the recording actually - Now starting the Dolby Digital output thread only if the recording actually
contains Dolby Digital audio data (thanks to Werner Fink). 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).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "dvbapi.h"
@ -2702,12 +2702,13 @@ bool cDvbApi::ToggleAudioTrack(void)
return false; return false;
} }
void cDvbApi::ToggleMute(void) bool cDvbApi::ToggleMute(void)
{ {
int OldVolume = volume; int OldVolume = volume;
mute = !mute; mute = !mute;
SetVolume(0, mute); SetVolume(0, mute);
volume = OldVolume; volume = OldVolume;
return mute;
} }
void cDvbApi::SetVolume(int Volume, bool Absolute) void cDvbApi::SetVolume(int Volume, bool Absolute)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __DVBAPI_H
@ -309,8 +309,8 @@ private:
int volume; int volume;
public: public:
bool IsMute(void) { return mute; } bool IsMute(void) { return mute; }
void ToggleMute(void); bool ToggleMute(void);
// Turns the volume off or on. // Turns the volume off or on and returns the new mute state.
void SetVolume(int Volume, bool Absolute = false); void SetVolume(int Volume, bool Absolute = false);
// Sets the volume to the given value, either absolutely or relative to // Sets the volume to the given value, either absolutely or relative to
// the current volume. // the current volume.

12
i18n.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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> * Slovenian translations provided by Miha Setina <mihasetina@softhome.net>
* Italian translations provided by Alberto Carraro <bertocar@tin.it> * Italian translations provided by Alberto Carraro <bertocar@tin.it>
@ -1558,6 +1558,16 @@ const tPhrase Phrases[] = {
"", // TODO "", // TODO
"Hyppää:", "Hyppää:",
}, },
{ "Volume ", // note the trailing blank
"Lautstärke ",
"", // TODO
"", // TODO
"", // TODO
"", // TODO
"Volume ",
"", // TODO
"Äänenvoimakkuus ",
},
{ " Stop replaying", // note the leading blank! { " Stop replaying", // note the leading blank!
" Wiedergabe beenden", " Wiedergabe beenden",
" Prekini ponavljanje", " Prekini ponavljanje",

105
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "menu.h"
@ -2347,6 +2347,109 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
return osEnd; 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::cRecordControl(cDvbApi *DvbApi, cTimer *Timer) cRecordControl::cRecordControl(cDvbApi *DvbApi, cTimer *Timer)

15
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef _MENU_H
@ -41,6 +41,19 @@ public:
virtual eOSState ProcessKey(eKeys Key); 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 cMenuRecordingItem;
class cMenuRecordings : public cOsdMenu { class cMenuRecordings : public cOsdMenu {

14
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * 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> #include <getopt.h>
@ -357,10 +357,16 @@ int main(int argc, char *argv[])
case kVolUp: case kVolUp:
case kVolDn|k_Repeat: case kVolDn|k_Repeat:
case kVolDn: case kVolDn:
cDvbApi::PrimaryDvbApi->SetVolume(NORMALKEY(key) == kVolDn ? -VOLUMEDELTA : VOLUMEDELTA);
break;
case kMute: 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; break;
// Power off: // Power off:
case kPower: isyslog(LOG_INFO, "Power button pressed"); case kPower: isyslog(LOG_INFO, "Power button pressed");