From a1864b7956f620644cee8b2dc7070f6f4fba9b49 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 14 May 2010 13:44:56 +0000 Subject: [PATCH] Setting up the mixer levels on call start/stop/etc (untested) --- src/plugins/Makefile | 3 ++- src/plugins/openmoko.c | 40 +++++++++++++++++++++++++++++++++++++++- src/plugins/project.conf | 3 ++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/plugins/Makefile b/src/plugins/Makefile index fb79fbb..6bb9918 100644 --- a/src/plugins/Makefile +++ b/src/plugins/Makefile @@ -5,7 +5,8 @@ LIBDIR = $(PREFIX)/lib CC = cc CPPFLAGSF= -I ../../include CPPFLAGS= -I $(PREFIX)/include -CFLAGSF = -fPIC +CFLAGSF = -W +CFLAGS = -Wall -g -O2 -pedantic -fPIC `pkg-config --cflags gtk+-2.0` AR = ar -rc RANLIB = ranlib LD = $(CC) -shared diff --git a/src/plugins/openmoko.c b/src/plugins/openmoko.c index 4254ac8..ff7b735 100644 --- a/src/plugins/openmoko.c +++ b/src/plugins/openmoko.c @@ -15,8 +15,21 @@ +#include #include +#include +#include +#include +#include #include "Phone.h" +#include "../../config.h" + +#ifndef PREFIX +# define PREFIX "/usr/local" +#endif +#ifndef DATADIR +# define DATADIR PREFIX "/share" +#endif /* Openmoko */ @@ -37,15 +50,40 @@ PhonePlugin plugin = /* private */ /* functions */ /* openmoko_init */ +static int _event_mixer_set(char const * filename); + static void _openmoko_event(PhoneEvent event) { switch(event) { case PHONE_EVENT_CALL_ESTABLISHED: + _event_mixer_set("gsmhandset.xml"); + break; case PHONE_EVENT_CALL_INCOMING: case PHONE_EVENT_CALL_OUTGOING: + /* FIXME is there anything to do? */ + break; case PHONE_EVENT_CALL_TERMINATED: - /* FIXME implement */ + _event_mixer_set("speaker.xml"); break; } } + +static int _event_mixer_set(char const * filename) +{ + char const scenarios[] = DATADIR "/openmoko/scenarios"; + char * pathname; + size_t len; + char * alsactl[] = { "/usr/sbin/alsactl", "alsactl", "-f", NULL, + "restore", NULL }; + + len = sizeof(scenarios) + 1 + strlen(filename); + if((pathname = malloc(len)) == NULL) + return error_set_code(1, "%s", strerror(errno)); + snprintf(pathname, len, "%s/%s", scenarios, filename); + alsactl[3] = pathname; + g_spawn_async(NULL, alsactl, NULL, G_SPAWN_FILE_AND_ARGV_ZERO, + NULL, NULL, NULL, NULL); + free(pathname); + return 0; +} diff --git a/src/plugins/project.conf b/src/plugins/project.conf index 63e8f2e..76e796d 100644 --- a/src/plugins/project.conf +++ b/src/plugins/project.conf @@ -1,7 +1,8 @@ targets=openmoko cppflags_force=-I ../../include cppflags=-I $(PREFIX)/include -cflags_force=-fPIC +cflags_force=-W +cflags=-Wall -g -O2 -pedantic -fPIC `pkg-config --cflags gtk+-2.0` dist=Makefile [openmoko]