Skip to content

Commit

Permalink
Merge pull request #47 from quom/dbus_fixes
Browse files Browse the repository at this point in the history
Moved DBus onto session bus and added error checks
  • Loading branch information
popcornmix committed Sep 3, 2013
2 parents 5c886fa + ef271d7 commit 40bf71e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Keyboard::restore_term()

void Keyboard::Process()
{
while(!m_bStop && dbus_connection_read_write_dispatch(conn, 0))
while(!m_bStop && conn && dbus_connection_read_write_dispatch(conn, 0))
{
int ch[8];
int chnum = 0;
Expand Down Expand Up @@ -141,7 +141,7 @@ int Keyboard::dbus_connect()
DBusError error;

dbus_error_init(&error);
if (!(conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error)))
if (!(conn = dbus_bus_get_private(DBUS_BUS_SESSION, &error)))
{
CLog::Log(LOGWARNING, "dbus_bus_get_private(): %s", error.message);
goto fail;
Expand Down
9 changes: 6 additions & 3 deletions OMXControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ void OMXControl::init(OMXClock *m_av_clock, OMXPlayerAudio *m_player_audio)
}
void OMXControl::dispatch()
{
dbus_connection_read_write_dispatch(bus, 0);
if (bus)
dbus_connection_read_write_dispatch(bus, 0);
}

int OMXControl::dbus_connect()
{
DBusError error;

dbus_error_init(&error);
if (!(bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error)))
if (!(bus = dbus_bus_get_private(DBUS_BUS_SESSION, &error)))
{
CLog::Log(LOGWARNING, "dbus_bus_get_private(): %s", error.message);
goto fail;
Expand Down Expand Up @@ -101,8 +102,10 @@ void OMXControl::dbus_disconnect()

int OMXControl::getEvent()
{
if (!bus)
return KeyConfig::ACTION_BLANK;

dispatch();

DBusMessage *m = dbus_connection_pop_message(bus);

if (m == NULL)
Expand Down
4 changes: 4 additions & 0 deletions omxplayer
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ if [ -e $FBSET ]; then
fbset -xres 1 -yres 1
fi

if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval $(dbus-launch --sh-syntax)
fi

$OMXPLAYER --font $FONT --italic-font $ITALIC_FONT "$@"

if [ -e $FBSET ]; then
Expand Down

0 comments on commit 40bf71e

Please sign in to comment.