[enjoy] Add fso support, to request CPU resource at startup so mobile doesn't suspend while listening to music

Patch by pespin.



SVN revision: 56308
This commit is contained in:
Leandro Pereira 2011-01-26 18:15:47 +00:00
parent 7b92016ddf
commit 6e40c97ca8
5 changed files with 141 additions and 1 deletions

View File

@ -111,6 +111,22 @@ fi
AM_CONDITIONAL(BUILD_QUICKLAUNCH, test "x${want_quicklaunch}" = "xyes")
AC_ARG_ENABLE([fso],
[AC_HELP_STRING([--enable-fso], [enable FSO support])],
[
if test "x${enableval}" = "xyes" ; then
enable_fso="yes"
else
enable_fso="no"
fi
],
[enable_fso="no"])
if test "x$enable_fso" = "xyes" ; then
CFLAGS="$CFLAGS -D_HAVE_FSO_"
AC_SUBST(CFLAGS)
fi
AC_OUTPUT([
Makefile
enjoy.spec

View File

@ -18,7 +18,7 @@ bin_PROGRAMS += enjoy_ql
endif
enjoy_LDADD = @ELEMENTARY_LIBS@ @EMOTION_LIBS@ @LMS_LIBS@ @SQLITE3_LIBS@ @EDBUS_LIBS@
enjoy_SOURCES = main.c win.c db.c list.c page.c cover.c nowplaying.c libmanager.c mpris.c coverart-lastfm.c
enjoy_SOURCES = main.c win.c db.c list.c page.c cover.c nowplaying.c libmanager.c mpris.c coverart-lastfm.c fso.c
if BUILD_QUICKLAUNCH
############################################################################

86
src/bin/fso.c Normal file
View File

@ -0,0 +1,86 @@
#include "private.h"
#include "fso.h"
#ifdef _HAVE_FSO_
#define FSO_OUSAGED_SERVICE "org.freesmartphone.ousaged"
#define FSO_OUSAGED_OBJECT_PATH "/org/freesmartphone/Usage"
#define FSO_OUSAGED_INTERFACE "org.freesmartphone.Usage"
E_DBus_Connection *sysconn = NULL;
/* callbacks */
void
fso_request_reource_cb(void *data, DBusMessage *replymsg, DBusError *error)
{
DBG("Request sent to fsousaged to enable resource.");
if (error && dbus_error_is_set(error))
ERR("Error requesting FSO resource: %s - %s\n", error->name, error->message);
}
void
fso_release_reource_cb(void *data, DBusMessage *replymsg, DBusError *error)
{
DBG("Request sent to fsousaged to disable resource.");
if (error && dbus_error_is_set(error))
ERR("Error releasing FSO resource: %s - %s", error->name, error->message);
}
/* methods */
void
fso_init(void)
{
if (sysconn) return;
e_dbus_init();
sysconn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
}
void
fso_shutdown(void)
{
if (!sysconn) return;
e_dbus_shutdown();
sysconn = NULL;
}
void
fso_request_resource(const char *resource)
{
DBusMessage *msg;
msg = dbus_message_new_method_call(
FSO_OUSAGED_SERVICE,
FSO_OUSAGED_OBJECT_PATH,
FSO_OUSAGED_INTERFACE,
"RequestResource");
dbus_message_append_args (msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID);
e_dbus_message_send(sysconn, msg, fso_request_reource_cb, -1, NULL);
dbus_message_unref(msg);
}
void
fso_release_resource(const char *resource)
{
DBusMessage *msg;
msg = dbus_message_new_method_call(
FSO_OUSAGED_SERVICE,
FSO_OUSAGED_OBJECT_PATH,
FSO_OUSAGED_INTERFACE,
"ReleaseResource");
dbus_message_append_args (msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID);
e_dbus_message_send(sysconn, msg, fso_release_reource_cb, -1, NULL);
dbus_message_unref(msg);
}
#endif /* _HAVE_FSO_ */

24
src/bin/fso.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef ENJOY_FSO_H
#define ENJOY_FSO_H
#ifdef _HAVE_FSO_
#include <E_DBus.h>
#include "private.h"
void fso_init(void);
void fso_shutdown(void);
void fso_request_reource(const char *resource);
void fso_release_resource(const char *resource);
void fso_request_reource_cb(void *data, DBusMessage *replymsg, DBusError *error);
void fso_release_resource_cb(void *data, DBusMessage *replymsg, DBusError *error);
#endif /* _HAVE_FSO_ */
#endif /* ENJOY_FSO_H */

View File

@ -6,6 +6,9 @@
#include "private.h"
#include "mpris.h"
#ifdef _HAVE_FSO_
#include "fso.h"
#endif
#include <Ecore_Getopt.h>
#include <Ecore_File.h>
@ -148,6 +151,12 @@ elm_main(int argc, char **argv)
app.win = win_new(&app);
if (!app.win) goto end;
#ifdef _HAVE_FSO_
fso_init();
fso_request_resource("CPU");
#endif
mpris_init();
cover_init();
elm_run();
@ -167,6 +176,11 @@ elm_main(int argc, char **argv)
mpris_shutdown();
cover_shutdown();
#ifdef _HAVE_FSO_
fso_release_resource("CPU");
fso_shutdown();
#endif
return r;
}