develop.uap-core.de/git
/
uwplayer.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
implement playlist remove
[uwplayer.git]
/
application
/
player.c
diff --git
a/application/player.c
b/application/player.c
index
8c1909c
..
2d63135
100644
(file)
--- a/
application/player.c
+++ b/
application/player.c
@@
-41,6
+41,7
@@
#include "json.h"
#include "utils.h"
#include "settings.h"
#include "json.h"
#include "utils.h"
#include "settings.h"
+#include "playlist.h"
extern char **environ;
extern char **environ;
@@
-108,6
+109,8
@@
static void* wait_for_process(void *data) {
Player *player = data;
int status = 0;
waitpid(player->process, &status, 0);
Player *player = data;
int status = 0;
waitpid(player->process, &status, 0);
+
+ printf("waitpid: %d\n", status);
player->isactive = FALSE;
player->status = status;
player->isactive = FALSE;
player->status = status;
@@
-143,7
+146,7
@@
static int start_player_process(Player *player, MainWindow *win) {
args[ac++] = player_bin;
args[ac++] = "-wid";
args[ac++] = wid_arg;
args[ac++] = player_bin;
args[ac++] = "-wid";
args[ac++] = wid_arg;
- args[ac++] = "--no-terminal";
+
//
args[ac++] = "--no-terminal";
args[ac++] = "--player-operation-mode=pseudo-gui";
args[ac++] = log_arg;
args[ac++] = ipc_arg;
args[ac++] = "--player-operation-mode=pseudo-gui";
args[ac++] = log_arg;
args[ac++] = ipc_arg;
@@
-215,7
+218,7
@@
static int wait_for_ipc(Player *player) {
return 0;
}
return 0;
}
-static int connect_to_ipc(Player *player) {
+static int connect_to_ipc(Player *player) {
// connect to IPC socket
int fd_ipc = socket(AF_UNIX, SOCK_STREAM, 0);
if(fd_ipc < 0) {
// connect to IPC socket
int fd_ipc = socket(AF_UNIX, SOCK_STREAM, 0);
if(fd_ipc < 0) {
@@
-239,6
+242,12
@@
static int connect_to_ipc(Player *player) {
return 0;
}
return 0;
}
+static Boolean update_player_window(XtPointer data) {
+ MainWindow *win = data;
+ WindowUpdate(win);
+ return 0;
+}
+
static void* start_player(void *data) {
MainWindow *win = data;
static void* start_player(void *data) {
MainWindow *win = data;
@@
-256,7
+265,7
@@
static void* start_player(void *data) {
PlayerDestroy(player);
return NULL;
}
PlayerDestroy(player);
return NULL;
}
- close(player->log);
+
//
close(player->log);
if(connect_to_ipc(player)) {
PlayerDestroy(player);
if(connect_to_ipc(player)) {
PlayerDestroy(player);
@@
-269,6
+278,9
@@
static void* start_player(void *data) {
}
win->player = player;
}
win->player = player;
+ // update main window
+ AppExecProc(update_player_window, win);
+
// IO
player_io(player);
// IO
player_io(player);
@@
-280,10
+292,13
@@
static void player_io(Player *p) {
fds[0].fd = p->ipc;
fds[0].events = POLLIN;
fds[0].revents = 0;
fds[0].fd = p->ipc;
fds[0].events = POLLIN;
fds[0].revents = 0;
+ fds[1].fd = p->log;
+ fds[1].events = POLLIN;
+ fds[1].revents = 0;
JSONParser *js = json_parser_new();
JSONParser *js = json_parser_new();
-
+
char buf[PLAYER_IN_BUFSIZE];
char buf[PLAYER_IN_BUFSIZE];
- while(p->isactive &&
poll(fds, 2, PLAYER_POLL_TIMEOUT
)) {
+ while(p->isactive &&
(poll(fds, 2, PLAYER_POLL_TIMEOUT) >= 0
)) {
if(fds[0].revents == POLLIN) {
ssize_t r;
if((r = read(fds[0].fd, buf, PLAYER_IN_BUFSIZE)) <= 0) {
if(fds[0].revents == POLLIN) {
ssize_t r;
if((r = read(fds[0].fd, buf, PLAYER_IN_BUFSIZE)) <= 0) {
@@
-305,8
+320,12
@@
static void player_io(Player *p) {
break;
}
}
break;
}
}
+ if(fds[1].revents == POLLIN) {
+ // just read to clean the log pipe
+ read(fds[1].fd, buf, PLAYER_IN_BUFSIZE);
+ }
- char *cmd = "{ \"command\": [\"get_property\", \"playback-time\"], request_id=\"" REQ_ID_PLAYBACK_TIME "\" }\n";
+
//
char *cmd = "{ \"command\": [\"get_property\", \"playback-time\"], request_id=\"" REQ_ID_PLAYBACK_TIME "\" }\n";
//write(p->ipc, cmd, strlen(cmd));
}
//write(p->ipc, cmd, strlen(cmd));
}
@@
-338,6
+357,10
@@
static void handle_json_rpc_msg(Player *player, JSONValue *v) {
static Boolean player_widget_set_size(XtPointer data) {
Player *player = data;
MainWindow *win = GetMainWindow();
static Boolean player_widget_set_size(XtPointer data) {
Player *player = data;
MainWindow *win = GetMainWindow();
+
+ if(!win->adjustWindowSize) {
+ return 0;
+ }
Dimension win_width, win_height;
XtVaGetValues(win->window, XmNwidth, &win_width, XmNheight, &win_height, NULL);
Dimension win_width, win_height;
XtVaGetValues(win->window, XmNwidth, &win_width, XmNheight, &win_height, NULL);
@@
-563,27
+586,19
@@
static void json_print(JSONValue *value, char *name, int indent) {
}
}
}
}
-static Boolean open_next_file(XtPointer data) {
- char *file = data;
+static Boolean play_next(XtPointer data) {
MainWindow *win = GetMainWindow();
MainWindow *win = GetMainWindow();
- if(win->file) {
- free(file);
- }
- win->file = file;
- PlayerOpenFile(win);
+ PlayListPlayNext(win, false);
return 0;
}
void PlayerEOF(Player *p) {
MainWindow *win = GetMainWindow();
return 0;
}
void PlayerEOF(Player *p) {
MainWindow *win = GetMainWindow();
- if(win->repeatTrack) {
+ if(win->
playlist.
repeatTrack) {
char *cmd = "{ \"command\": [\"set_property\", \"playback-time\", 0] }\n";
write(p->ipc, cmd, strlen(cmd));
char *cmd = "{ \"command\": [\"set_property\", \"playback-time\", 0] }\n";
write(p->ipc, cmd, strlen(cmd));
- } else if(win->autoplayFolder) {
- char *next_file = util_find_next_file(win->file);
- if(next_file) {
- AppExecProc(open_next_file, next_file);
- }
+ } else {
+ AppExecProc(play_next, NULL);
}
}
}
}