#include <sys/fcntl.h>
#include <spawn.h>
#include <sys/wait.h>
+#include <signal.h>
#include <pthread.h>
#define WID_ARG_BUFSIZE 24
static void* start_player(void *data);
+static void* player_io_thread(void *data);
void PlayerOpenFile(MainWindow *win) {
pthread_t tid;
close(pin[0]);
close(pout[1]);
player->process = player_pid;
+ player->isactive = TRUE;
if(win->player) {
PlayerDestroy(win->player);
}
win->player = player;
+ // start thread for mplayer IO
+ pthread_t tid;
+ if(pthread_create(&tid, NULL, player_io_thread, player)) {
+ perror("pthread_create");
+ }
+
return NULL;
}
void PlayerDestroy(Player *p) {
+ if(p->isactive) {
+ close(p->in);
+ close(p->out);
+ kill(p->process, SIGTERM);
+ }
free(p);
}
+
+static void* player_io_thread(void *data) {
+ Player *player = data;
+
+ return NULL;
+}