- Add volume handling capabilities

This commit is contained in:
Pietro Cerutti 2008-06-27 20:58:02 +00:00
parent 4277c3a2dd
commit d066457c63
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=215843
3 changed files with 63 additions and 4 deletions

View file

@ -7,7 +7,7 @@
PORTNAME= tcd
PORTVERSION= 2.2.0
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= audio
MASTER_SITES= ${MASTER_SITE_SAVANNAH}
MASTER_SITE_SUBDIR= ${PORTNAME}

View file

@ -1,6 +1,41 @@
--- src/tcd.c.orig 2004-06-15 22:32:31.000000000 +0200
+++ src/tcd.c 2008-06-27 01:25:01.000000000 +0200
@@ -217,11 +217,11 @@
+++ src/tcd.c 2008-06-27 22:55:04.000000000 +0200
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <SDL/SDL.h>
+#include <sys/cdio.h>
#include "cd-utils.h"
#include "cddb.h"
@@ -179,6 +180,26 @@
}
}
+static void inc_volume(void)
+{
+ struct ioc_vol arg;
+ if(ioctl(state.cdrom->id, CDIOCGETVOL, &arg) == -1)
+ return;
+ arg.vol[0] += arg.vol[0] > 250 ? 255 - arg.vol[0] : 5;
+ arg.vol[1] += arg.vol[1] > 250 ? 255 - arg.vol[1] : 5;
+ ioctl(state.cdrom->id, CDIOCSETVOL, &arg);
+}
+
+static void dec_volume(void)
+{
+ struct ioc_vol arg;
+ if(ioctl(state.cdrom->id, CDIOCGETVOL, &arg) == -1)
+ return;
+ arg.vol[0] -= arg.vol[0] < 5 ? arg.vol[0] : 5;
+ arg.vol[1] -= arg.vol[1] < 5 ? arg.vol[1] : 5;
+ ioctl(state.cdrom->id, CDIOCSETVOL, &arg);
+}
+
static void init_SDL(int cdrom_num)
{
int err = SDL_Init(SDL_INIT_CDROM);
@@ -217,11 +238,11 @@
static void detect_disc_change(void)
{
unsigned long discid = cddb_discid(state.cdrom);
@ -14,7 +49,7 @@
state.current_discid = discid;
}
}
@@ -237,7 +237,7 @@
@@ -237,7 +258,7 @@
state.play_method = NORMAL;
init_SDL((argc > 1) ? strtol(argv[1], NULL, 0) : 0);
@ -23,3 +58,12 @@
tcd_ui_init();
tcd_ui_update(&state);
state.current_discid = cddb_discid(state.cdrom);
@@ -262,6 +283,8 @@
case 's': case 'S': handle_stop(); break;
case ']': handle_skip_forward(); break;
case '[': handle_skip_back(); break;
+ case '*': inc_volume(); break;
+ case '/': dec_volume(); break;
}
}
tcd_ui_shutdown();

View file

@ -0,0 +1,15 @@
--- src/user-interface.c.orig 2008-06-27 22:55:46.000000000 +0200
+++ src/user-interface.c 2008-06-27 22:55:49.000000000 +0200
@@ -186,8 +186,10 @@
phelp(3, 26, 'G', "- Go to track", playable);
phelp(4, 26, ']', "- Skip ahead", playable);
phelp(5, 26, '[', "- Skip back", playable);
- phelp(7, 1, 'T', "- Edit track database", playable);
- phelp(8, 1, 'Q', "- Quit", 1);
+ phelp(7, 1, '*', "- Increase volume", playable);
+ phelp(8, 1, '/', "- Decrease volume", playable);
+ phelp(10, 1, 'T', "- Edit track database", playable);
+ phelp(11, 1, 'Q', "- Quit", 1);
}
static void draw_info(struct tcd_state *state)