Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] [PATCH] Re: Re: change volume of soundcard
On Montag 01 März 2004 20:21, Marcel Wiesweg wrote:
> > I want the VolUp, VolDown and Mute keys of my remote
> > to change the volume of my sound card.
> >
> > I could probably do this with the User1 ... keys but they
> > always let some text on the OSD pop up for a moment,
> > and repeat does not seem to work.
>
> You can use cStatus to be informed about volume changes in VDR.
> Look into the code of the plugin described in
> http://www.linuxtv.org/mailinglists/vdr/2004/01-2004/msg00369.html
> to find sample code that keeps the soundcard mixer in sync with VDR.
that is probably much more than I need. Also, If I understand this
correctly the volume of the DVB card is still changed with that patch,
so the output signal which I feed into the soundcard gets weaker and
noisier. I only want to reduce the soundcard output.
Instead I made some changes to keymacros.conf:
1. Macros can be defined for all keys, they override the normal key.
2. A macro can execute a system command
in my case:
Volume+ @execute aumix -v+5
Volume- @execute aumix -v-5
Mute @execute set - `aumix -q | grep vol | sed 's/,//'`; vol=`expr $2 + $3`; if test $vol -eq 0; then aumix -L >/dev/null; else aumix -S; aumix -v0; fi
Notes:
1. this supposes there will never be a plugin called execute
2. my patch also modifies existing macros: it makes them repeat while
key pressed. I am not sure what is the wanted behaviour here. I
certainly need it to be repeatable.
Patch attached.
Could something like this added to vdr?
--
Wolfgang
diff -ur vdr-1.3.5/keys.c vdr-wr/keys.c
--- vdr-1.3.5/keys.c 2003-09-14 12:07:47.000000000 +0200
+++ vdr-wr/keys.c 2004-03-03 09:13:53.000000000 +0100
@@ -184,17 +184,34 @@
for (int i = 0; i < MAXKEYSINMACRO; i++)
macro[i] = kNone;
plugin = NULL;
+ execute = NULL;
}
cKeyMacro::~cKeyMacro()
{
free(plugin);
+ free(execute);
}
bool cKeyMacro::Parse(char *s)
{
int n = 0;
char *p;
+ {
+ char *cmd = s;
+ while (*cmd && strncmp(cmd,"@execute",8)) cmd++;
+ if (*cmd) {
+ cmd += 8;
+ execute=strdup(cmd);
+ p = strtok(s," \t");
+ if (p) {
+ macro[0] = cKey::FromString(p);
+ return(macro[0] != kNone);
+ }
+ else
+ return false;
+ }
+ }
while ((p = strtok(s, " \t")) != NULL) {
if (n < MAXKEYSINMACRO) {
if (*p == '@') {
@@ -248,6 +265,7 @@
const cKeyMacro *cKeyMacros::Get(eKeys Key)
{
+ if (Key==kNone) return NULL;
for (cKeyMacro *k = First(); k; k = Next(k)) {
if (*k->Macro() == Key)
return k;
diff -ur vdr-1.3.5/keys.h vdr-wr/keys.h
--- vdr-1.3.5/keys.h 2002-12-14 16:49:42.000000000 +0100
+++ vdr-wr/keys.h 2004-03-03 07:19:24.000000000 +0100
@@ -113,12 +113,14 @@
private:
eKeys macro[MAXKEYSINMACRO];
char *plugin;
+ char *execute;
public:
cKeyMacro(void);
~cKeyMacro();
bool Parse(char *s);
const eKeys *Macro(void) const { return macro; }
const char *Plugin(void) const { return plugin; }
+ const char *Execute(void) const { return execute; }
};
class cKeyMacros : public cConfig<cKeyMacro> {
diff -ur vdr-1.3.5/remote.c vdr-wr/remote.c
--- vdr-1.3.5/remote.c 2003-10-18 13:35:32.000000000 +0200
+++ vdr-wr/remote.c 2004-03-03 09:03:24.000000000 +0100
@@ -90,6 +90,10 @@
{
const cKeyMacro *km = KeyMacros.Get(Key);
if (km) {
+ if (km->Execute()) {
+ system(km->Execute());
+ return true;
+ }
plugin = km->Plugin();
for (int i = 1; i < MAXKEYSINMACRO; i++) {
if (km->Macro()[i] != kNone) {
diff -ur vdr-1.3.5/vdr.c vdr-wr/vdr.c
--- vdr-1.3.5/vdr.c 2004-02-29 15:21:22.000000000 +0100
+++ vdr-wr/vdr.c 2004-03-03 09:04:00.000000000 +0100
@@ -592,6 +592,11 @@
LastActivity = time(NULL);
}
// Keys that must work independent of any interactive mode:
+ const cKeyMacro *km = KeyMacros.Get(NORMALKEY(key));
+ if (km) {
+ cRemote::PutMacro(NORMALKEY(key));
+ key=kNone;
+ }
switch (key) {
// Menu control:
case kMenu:
Home |
Main Index |
Thread Index