Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlink Dbus tmp file after stop omxplayer session. #620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions OMXControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define OMXPLAYER_DBUS_INTERFACE_ROOT "org.mpris.MediaPlayer2"
#define OMXPLAYER_DBUS_INTERFACE_PLAYER "org.mpris.MediaPlayer2.Player"

#define OMXPLAYER_DBUS_ADDRESS_FRMT "/tmp/omxplayerdbus.%s"
#define OMXPLAYER_DBUS_PID_FRMT "/tmp/omxplayerdbus.%s.pid"

#include <dbus/dbus.h>
#include "OMXClock.h"
#include "OMXPlayerAudio.h"
Expand Down
2 changes: 2 additions & 0 deletions dbuscontrol.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pause)

stop)
dbus-send --print-reply=literal --session --dest=org.mpris.MediaPlayer2.omxplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:15 >/dev/null
rm -fr $OMXPLAYER_DBUS_ADDR
rm -fr $OMXPLAYER_DBUS_PID
;;

seek)
Expand Down
21 changes: 21 additions & 0 deletions omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <sys/ioctl.h>
#include <getopt.h>
#include <string.h>
#include <pwd.h>
#include <unistd.h>

#define AV_NOWARN_DEPRECATED

Expand Down Expand Up @@ -1828,6 +1830,24 @@ int main(int argc, char *argv[])
{
unsigned t = (unsigned)(m_av_clock->OMXMediaTime()*1e-6);
printf("Stopped at: %02d:%02d:%02d\n", (t/3600), (t/60)%60, t%60);
register struct passwd *pw;
register uid_t uid;
int c;
char sDBusAddr[STD_BUF_SIZE];
char sDBusPid[STD_BUF_SIZE];
uid = geteuid ();
pw = getpwuid (uid);
if (pw)
{
snprintf(sDBusAddr, STD_BUF_SIZE-1, OMXPLAYER_DBUS_ADDRESS_FRMT, pw->pw_name);
snprintf(sDBusPid, STD_BUF_SIZE-1, OMXPLAYER_DBUS_PID_FRMT, pw->pw_name);
}else
{
snprintf(sDBusAddr, STD_BUF_SIZE-1, OMXPLAYER_DBUS_ADDRESS_FRMT, "root");
snprintf(sDBusPid, STD_BUF_SIZE-1, OMXPLAYER_DBUS_PID_FRMT, "root");
}
unlink(sDBusAddr);
unlink(sDBusPid);
}

if (m_NativeDeinterlace)
Expand Down Expand Up @@ -1879,3 +1899,4 @@ int main(int argc, char *argv[])
// exit status failure on other cases
return EXIT_FAILURE;
}