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).
- 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).

View File

@ -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)

View File

@ -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.

12
i18n.c
View File

@ -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",

105
menu.c
View File

@ -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)

15
menu.h
View File

@ -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 {

14
vdr.c
View File

@ -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");