r4351 - in trunk/src/target/OM-2007.2/daemons/neod: . src
olv at sita.openmoko.org
olv at sita.openmoko.org
Sat Apr 12 10:08:46 CEST 2008
Author: olv
Date: 2008-04-12 10:08:42 +0200 (Sat, 12 Apr 2008)
New Revision: 4351
Modified:
trunk/src/target/OM-2007.2/daemons/neod/configure.ac
trunk/src/target/OM-2007.2/daemons/neod/src/buttonactions.c
Log:
* lock pa_threaded_mainloop before accessing pa_context
* initialize glib thread system
* fix warnings
Modified: trunk/src/target/OM-2007.2/daemons/neod/configure.ac
===================================================================
--- trunk/src/target/OM-2007.2/daemons/neod/configure.ac 2008-04-12 03:55:17 UTC (rev 4350)
+++ trunk/src/target/OM-2007.2/daemons/neod/configure.ac 2008-04-12 08:08:42 UTC (rev 4351)
@@ -18,7 +18,7 @@
AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
-PKG_CHECK_MODULES(NEOD, gtk+-2.0 gconf-2.0 libpulse)
+PKG_CHECK_MODULES(NEOD, gtk+-2.0 gthread-2.0 gconf-2.0 libpulse)
AC_ARG_WITH([platform],
AC_HELP_STRING([--with-platform], [Which platform to use [[default=vanilla]]]),
Modified: trunk/src/target/OM-2007.2/daemons/neod/src/buttonactions.c
===================================================================
--- trunk/src/target/OM-2007.2/daemons/neod/src/buttonactions.c 2008-04-12 03:55:17 UTC (rev 4350)
+++ trunk/src/target/OM-2007.2/daemons/neod/src/buttonactions.c 2008-04-12 08:08:42 UTC (rev 4351)
@@ -46,32 +46,26 @@
static gchar* backlight_node = NULL;
static int backlight_max_brightness = 1;
-#define AUX_BUTTON_KEYCODE 0x22
-#define POWER_BUTTON_KEYCODE 0x23
-#define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
-
#ifdef NEOD_PLATFORM_FIC_NEO1973
#define AUX_BUTTON_KEYCODE 169 /* aux */
#define POWER_BUTTON_KEYCODE 116 /* power */
#define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
-#endif
-
-#ifdef NEOD_PLATFORM_MOTOROLA_EZX
+#elif NEOD_PLATFORM_MOTOROLA_EZX
#define AUX_BUTTON_KEYCODE 0xa7 /* voice */
#define POWER_BUTTON_KEYCODE 0xd4 /* camera */
#define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
-#endif
-
-#ifdef NEOD_PLATFORM_HTC
+#elif NEOD_PLATFORM_HTC
#define AUX_BUTTON_KEYCODE 0xd4 /* camera */
#define POWER_BUTTON_KEYCODE 0x74 /* power */
#define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
-#endif
-
-#ifdef NEOD_PLATFORM_IPAQ
+#elif NEOD_PLATFORM_IPAQ
#define AUX_BUTTON_KEYCODE 89 /* record */
#define POWER_BUTTON_KEYCODE 0x74 /* power */
#define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
+#else
+ #define AUX_BUTTON_KEYCODE 0x22
+ #define POWER_BUTTON_KEYCODE 0x23
+ #define TOUCHSCREEN_BUTTON_KEYCODE 0x14a
#endif
#define HEADPHONE_INSERTION_SWITCHCODE 0x02
@@ -153,6 +147,7 @@
} PowerState;
PowerState power_state = NORMAL;
+static pa_threaded_mainloop* pam;
static pa_context* pac;
static Window last_active_window = 0;
@@ -314,7 +309,7 @@
neod_buttonactions_powersave_reset();
- moko_debug = getenv( "MOKO_DEBUG" );
+ moko_debug = ( getenv( "MOKO_DEBUG" ) != NULL );
g_debug( "setting debug output to %s", moko_debug ? "true" : "false" );
return TRUE;
@@ -1150,27 +1145,50 @@
return FALSE;
}
-void neod_buttonactions_sound_state_cb( pa_context* pac, void* userdata )
+static void _sound_play( const gchar* samplename )
{
+ pa_context_play_sample( pac,
+ samplename, // Name of my sample
+ NULL, // Use default sink
+ PA_VOLUME_NORM, // Full volume
+ NULL, // Don't need a callback
+ NULL
+ );
+}
+
+void neod_buttonactions_sound_play( const gchar* samplename )
+{
+ g_return_if_fail( pac );
+
+ pa_threaded_mainloop_lock( pam );
+ _sound_play( samplename );
+ pa_threaded_mainloop_unlock( pam );
+}
+
+/* this function is called within the pulseaudio event thread */
+static void neod_buttonactions_sound_state_cb( pa_context* pac, void* userdata )
+{
g_debug( "mainmenu sound state callback. state = %d", pa_context_get_state( pac ) );
if ( pa_context_get_state( pac ) == PA_CONTEXT_READY )
{
- neod_buttonactions_sound_play( "startup" );
+ _sound_play ( "startup" );
}
}
void neod_buttonactions_sound_init()
{
g_debug( "panel mainmenu sound init" );
- pa_threaded_mainloop* mainloop = pa_threaded_mainloop_new();
+
+ g_thread_init( NULL );
- if ( !mainloop )
+ pam = pa_threaded_mainloop_new();
+ if ( !pam )
{
printf( "couldn't create mainloop: %s", strerror( errno ) );
return;
}
- pa_mainloop_api* mapi = pa_threaded_mainloop_get_api( mainloop );
+ pa_mainloop_api* mapi = pa_threaded_mainloop_get_api( pam );
pac = pa_context_new( mapi, "test client" );
if ( !pac )
@@ -1181,24 +1199,11 @@
pa_context_set_state_callback( pac, neod_buttonactions_sound_state_cb, NULL );
pa_context_connect( pac, NULL, 0, NULL );
- pa_threaded_mainloop_start( mainloop );
+ pa_threaded_mainloop_start( pam );
g_debug( "sound init ok. threaded mainloop started" );
}
-void neod_buttonactions_sound_play( const gchar* samplename )
-{
- g_return_if_fail( pac );
- pa_context_play_sample( pac,
- samplename, // Name of my sample
- NULL, // Use default sink
- PA_VOLUME_NORM, // Full volume
- NULL, // Don't need a callback
- NULL
- );
-
-}
-
gboolean neod_buttonactions_initial_update()
{
// need a workaround until OM bug #991 has been fixed
More information about the commitlog
mailing list