Add support for pausing MPlayer
[headphoned] / src / headphoned.c
index 2daaf69..adfdf55 100644 (file)
@@ -18,6 +18,7 @@
 #include <gconf/gconf-client.h>
 #include <libosso.h>
 #include <dbus/dbus.h>
+#include <fcntl.h>
 
 #define STATE_FILE "/sys/devices/platform/gpio-switch/headphone/state"
 #define STATE_CONNECTED_STR "connected"
@@ -33,6 +34,8 @@
 #define PANUCCI_PATH "/panucciInterface"
 #define PANUCCI_INTF "org.panucci.panucciInterface"
 
+#define MPLAYER_FIFO "/etc/headphoned/mplayer-input"
+
 // Volume control is currently broken, as something is messing
 // with the controls from outside this process in GConf..
 //#define ENABLE_VOLUME_CONTROL
@@ -90,6 +93,7 @@ on_file_changed(GIOChannel* source, GIOCondition condition, gpointer data)
        gint volume = headphoned->volume[headphoned->state];
 #endif
        gchar* result;
+       int mplayer_fifo;
 
        g_io_channel_seek_position(source, 0, G_SEEK_SET, NULL);
        g_io_channel_read_line(source, &result, NULL, NULL, NULL);
@@ -122,6 +126,13 @@ on_file_changed(GIOChannel* source, GIOCondition condition, gpointer data)
                                                NULL,
                                                DBUS_TYPE_INVALID);
                        }
+
+                       /* MPlayer */
+                       if ((mplayer_fifo = open(MPLAYER_FIFO,
+                                               O_WRONLY | O_NONBLOCK)) != -1) {
+                               write(mplayer_fifo, "pause\n", 6);
+                               close(mplayer_fifo);
+                       }
                }
 #endif
        }