comparison src/lirc/lirc.c @ 2277:5e54ffc4f46f

Apply lirc patch from bugzilla. (Bugzilla #62).
author Andrew O. Shadoura <bugzilla@tut.by>
date Tue, 01 Jan 2008 16:03:44 -0600
parents 5e88191720a7
children 738914331374
comparison
equal deleted inserted replaced
2272:a7c0e58fa489 2277:5e54ffc4f46f
44 44
45 #include <lirc/lirc_client.h> 45 #include <lirc/lirc_client.h>
46 46
47 #include "lirc.h" 47 #include "lirc.h"
48 48
49 #include "common.h"
50
49 const char *plugin_name="LIRC Plugin"; 51 const char *plugin_name="LIRC Plugin";
50 52
51 GeneralPlugin lirc_plugin = { 53 GeneralPlugin lirc_plugin = {
52 .description = "LIRC Plugin", 54 .description = "LIRC Plugin",
53 .init = init, 55 .init = init,
54 .about = about, 56 .about = about,
55 .configure = NULL, 57 .configure = configure,
56 .cleanup = cleanup 58 .cleanup = cleanup
57 }; 59 };
58 60
59 GeneralPlugin *lirc_gplist[] = { &lirc_plugin, NULL }; 61 GeneralPlugin *lirc_gplist[] = { &lirc_plugin, NULL };
60 DECLARE_PLUGIN(lirc, NULL, NULL, NULL, NULL, NULL, lirc_gplist, NULL, NULL); 62 DECLARE_PLUGIN(lirc, NULL, NULL, NULL, NULL, NULL, lirc_gplist, NULL, NULL);
65 gint mute=0; /* mute flag */ 67 gint mute=0; /* mute flag */
66 gint mute_vol=0; /* holds volume before mute */ 68 gint mute_vol=0; /* holds volume before mute */
67 69
68 gint input_tag; 70 gint input_tag;
69 71
70 void init(void) 72 void init_lirc(void)
71 { 73 {
72 int flags; 74 int flags;
73 75
74 if((lirc_fd=lirc_init("audacious",1))==-1) 76 if((lirc_fd=lirc_init("audacious",1))==-1)
75 { 77 {
94 if(flags!=-1) 96 if(flags!=-1)
95 { 97 {
96 fcntl(lirc_fd,F_SETFL,flags|O_NONBLOCK); 98 fcntl(lirc_fd,F_SETFL,flags|O_NONBLOCK);
97 } 99 }
98 fflush(stdout); 100 fflush(stdout);
101 }
102
103 void init(void)
104 {
105 load_cfg();
106 init_lirc();
107 }
108
109 gboolean reconnect_lirc(gpointer data)
110 {
111 fprintf(stderr,_("%s: trying to reconnect...\n"),plugin_name);
112 init();
113 return (lirc_fd==-1);
99 } 114 }
100 115
101 void lirc_input_callback(gpointer data,gint source, 116 void lirc_input_callback(gpointer data,gint source,
102 GdkInputCondition condition) 117 GdkInputCondition condition)
103 { 118 {
302 if(ret==-1) 317 if(ret==-1)
303 { 318 {
304 /* something went badly wrong */ 319 /* something went badly wrong */
305 fprintf(stderr,_("%s: disconnected from LIRC\n"),plugin_name); 320 fprintf(stderr,_("%s: disconnected from LIRC\n"),plugin_name);
306 cleanup(); 321 cleanup();
307 return; 322 if(b_enable_reconnect)
323 {
324 fprintf(stderr,_("%s: will try reconnect every %d seconds...\n"),plugin_name,reconnect_timeout);
325 g_timeout_add(1000*reconnect_timeout, reconnect_lirc, NULL);
326 }
308 } 327 }
309 } 328 }
310 329
311 void cleanup() 330 void cleanup()
312 { 331 {