|
From: <mla...@us...> - 2007-11-18 23:07:11
|
Revision: 316
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=316&view=rev
Author: mlampard
Date: 2007-11-18 15:07:15 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
respond to volume/mute controls, improve responsiveness. (Thanks to Nedko Arnaudov)
Modified Paths:
--------------
trunk/g15daemon-audio-plugins/g15mpd/AUTHORS
trunk/g15daemon-audio-plugins/g15mpd/ChangeLog
trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c
Modified: trunk/g15daemon-audio-plugins/g15mpd/AUTHORS
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/AUTHORS 2007-09-15 10:47:56 UTC (rev 315)
+++ trunk/g15daemon-audio-plugins/g15mpd/AUTHORS 2007-11-18 23:07:15 UTC (rev 316)
@@ -1 +1,9 @@
Mike Lampard <mla...@us...>
+- Primary developer / Maintainer
+
+*** Contributions:
+
+Nedko Arnaudov
+- patch to improve responsiveness
+- patch to respond to volume control/mute
+
Modified: trunk/g15daemon-audio-plugins/g15mpd/ChangeLog
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/ChangeLog 2007-09-15 10:47:56 UTC (rev 315)
+++ trunk/g15daemon-audio-plugins/g15mpd/ChangeLog 2007-11-18 23:07:15 UTC (rev 316)
@@ -4,3 +4,5 @@
- added ability to scroll through playlist and play selected songs with the
volume control/play button.
- best used with g15daemon wip
+- Respond to volume wheel & mute button
+- Improve responsiveness
Modified: trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c 2007-09-15 10:47:56 UTC (rev 315)
+++ trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c 2007-11-18 23:07:15 UTC (rev 316)
@@ -77,6 +77,9 @@
static int playlist_mode=0;
int playlist_selection=0;
int item_selected=0;
+int volume_adjust=0;
+int mute=0;
+int muted_volume=0;
struct track_info {
char artist[100];
@@ -204,7 +207,10 @@
int code_audio_prev = XKeysymToKeycode(dpy, XF86XK_AudioPrev);
int code_audio_raisevol = XKeysymToKeycode(dpy, XF86XK_AudioRaiseVolume);
int code_audio_lowervol = XKeysymToKeycode(dpy, XF86XK_AudioLowerVolume);
+ int code_audio_mute = XKeysymToKeycode(dpy, XF86XK_AudioMute);
+/* printf("keycode = %d\n", keycode); */
+
if(keycode == code_audio_play) {
if(playing && !playlist_mode) {
if (paused) {
@@ -241,14 +247,25 @@
}
if(keycode == code_audio_raisevol){
- playlist_selection = 1;
+ pthread_mutex_lock(&daemon_mutex);
+ volume_adjust+=1;
+ pthread_mutex_unlock(&daemon_mutex);
return;
}
if(keycode == code_audio_lowervol){
- playlist_selection = -1;
+ pthread_mutex_lock(&daemon_mutex);
+ volume_adjust-=1;
+ pthread_mutex_unlock(&daemon_mutex);
return;
}
+ if(keycode == code_audio_mute){
+ pthread_mutex_lock(&daemon_mutex);
+ mute = 1;
+ pthread_mutex_unlock(&daemon_mutex);
+ return;
+ }
+
/* now the default stuff */
if(own_keyboard) {
menulevel=MENU_MODE1;
@@ -486,7 +503,10 @@
//g15r_renderString (canvas, (unsigned char *)"test", 0, G15_TEXT_SMALL, 36, 36);
}
- if(voltimeout){
+ if(muted_volume != 0){
+ g15r_renderString (canvas, (unsigned char *)"MUTE", 0, G15_TEXT_LARGE, 11, 2);
+ }
+ else if(voltimeout){
g15r_drawBar (canvas,10, 22, 149, 30, G15_COLOR_BLACK, track_info.volume, 100, 1);
canvas->mode_xor=1;
g15r_renderString (canvas, (unsigned char *)"Volume", 0, G15_TEXT_LARGE, 59, 23);
@@ -560,7 +580,7 @@
track_info.random = mpd_player_get_random(obj);
pthread_mutex_unlock(&lockit);
- usleep(100*1000);
+ usleep(10*1000);
}
@@ -578,6 +598,8 @@
int xtest_major_version = 0;
int xtest_minor_version = 0;
int dummy;
+ int volume;
+ int volume_new;
int iport = 6600;
char *hostname = getenv("MPD_HOST");
@@ -638,6 +660,12 @@
False, GrabModeAsync, GrabModeAsync);
XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioNext), AnyModifier, root_win,
False, GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioRaiseVolume), AnyModifier, root_win,
+ False, GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioLowerVolume), AnyModifier, root_win,
+ False, GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioMute), AnyModifier, root_win,
+ False, GrabModeAsync, GrabModeAsync);
/* Create mpd object */
obj = mpd_new(hostname, iport,password);
@@ -662,8 +690,44 @@
pthread_create(&g15display, &attr, g15display_thread, NULL);
do{
+ pthread_mutex_lock(&daemon_mutex);
+ if(mute){
+ volume_adjust = 0;
+ mute = 0;
+ if (muted_volume == 0) {
+ //printf("mute\n");
+ muted_volume = mpd_status_get_volume(obj);
+ mpd_status_set_volume (obj,0);
+ } else {
+ //printf("unmute\n");
+ if (mpd_status_get_volume(obj) == 0) { /* if no other client has set volume up */
+ mpd_status_set_volume (obj,muted_volume);
+ }
+ muted_volume = 0;
+ }
+ }
+ if(volume_adjust != 0){
+ if (muted_volume != 0) {
+ volume=muted_volume;
+ } else {
+ volume=mpd_status_get_volume(obj);
+ }
+ volume_new = volume + volume_adjust;
+ volume_adjust = 0;
+ if(volume_new < 0)
+ volume_new = 0;
+ if(volume_new > 100)
+ volume_new = 100;
+ if(volume != volume_new || muted_volume){
+ //printf("volume %d -> %d\n", volume, volume_new);
+ mpd_status_set_volume (obj,volume_new);
+ }
+ voltimeout=500;
+ muted_volume=0;
+ }
mpd_status_update(obj);
- }while(!usleep(10000) && !leaving);
+ pthread_mutex_unlock(&daemon_mutex);
+ }while(!usleep(5000) && !leaving);
}
mpd_free(obj);
close(fdstdin);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|