]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Bugfixes in the video demo.
authorDario Faggioli <faggioli@gandalf.sssup.it>
Thu, 14 May 2009 11:35:53 +0000 (13:35 +0200)
committerDario Faggioli <faggioli@gandalf.sssup.it>
Thu, 14 May 2009 11:35:53 +0000 (13:35 +0200)
demo/video/Makefile.omk
demo/video/play.c
demo/video/play.h
demo/video/play_th.c
demo/video/play_th.h

index 02ede688864deca0847e0845cfab2da2cda0568e..24c7ba717be82b7c2e0a32078783645ba2b8e48a 100644 (file)
@@ -4,6 +4,6 @@ lib_LOADLIBES+= m pthread rt $(FRSH_LIBS)
 bin_PROGRAMS = fplayer
 fplayer_SOURCES = play.c play.h
 
-bin_PROGRAMS = fplayer_th
+bin_PROGRAMS += fplayer_th
 fplayer_th_SOURCES = play_th.c play_th.h
 
index 259c018bfe83455bfcb9116cad08767045ef0285..4bc7bf8acc01d44422e462c322bd7b6d67608b31 100644 (file)
@@ -21,10 +21,10 @@ void player(struct player_args *args)
                "== Starting playing %s, with %d/%d CPU bandwidth\n",
                args->file, args->budget, args->period);
 
-       snprintf(cmd, 255, "mplayer %s", args->file);
+       snprintf(cmd, 255, PLAYER_BINARY PLAYER_ARGS " %s", args->file);
        fprintf(stdout, "== Issuing command:\n  %s\n", cmd);
 
-       execlp("mplayer", "mplayer", "-fs", "-zoom", args->file, (char*) NULL);
+       execlp(PLAYER_BINARY, PLAYER_BINARY, PLAYER_ARGS, args->file, (char*) NULL);
 }
 
 int main(int argc, char *argv[])
index 93a84f0db69f394ea8b1192308596f25c723fb9e..e7c1c71b18ee9b43603d73664f4c54854e30699f 100644 (file)
@@ -14,6 +14,9 @@
 
 #include <frsh.h>
 
+#define PLAYER_BINARY  "mplayer"
+#define PLAYER_ARGS    " -fs -zoom "
+
 struct player_args {
        int budget, period;
        char file[128];
index 82df285c9aac69d7fd8795caf9514d9b01eba531..c896d2a34ea6c138fca03b29d36794174da49302 100644 (file)
@@ -10,7 +10,7 @@ static void player_cleanup(void *arg)
 
 void *player(void *thread_args)
 {
-       struct player_args args = *((struct player_args*) thread_args);
+       struct player_args *args = (struct player_args*) thread_args;
 
        frsh_rel_time_t player_budget, player_period;
        frsh_contract_t player_contract;
@@ -23,10 +23,10 @@ void *player(void *thread_args)
 
        fprintf(stdout,
                "== Starting playing %s, with %d/%d CPU bandwidth\n",
-               args.file, args.budget, args.period);
+               args->file, args->budget, args->period);
 
-       player_budget = fosa_usec_to_rel_time(args.budget);
-       player_period = fosa_usec_to_rel_time(args.period);
+       player_budget = fosa_usec_to_rel_time(args->budget);
+       player_period = fosa_usec_to_rel_time(args->period);
        PXW(frsh_contract_init(&player_contract));
        PXW(frsh_contract_set_basic_params(&player_contract,
                                           &player_budget,
@@ -47,7 +47,7 @@ void *player(void *thread_args)
        PXW(frsh_thread_bind(player_vres, fosa_thread_self()));
        fprintf(stdout, "== Player thread bound to its contract\n");
 
-       snprintf(cmd, 255, "mplayer -fs -zoom %s", args.file);
+       snprintf(cmd, 255, PLAYER_BINARY PLAYER_ARGS " %s", args->file);
 
        fprintf(stdout, "== Issuing command:\n  %s\n", cmd);
 
@@ -95,12 +95,18 @@ err_usage:
        }
 
        PXW(frsh_init());
+       fprintf(stdout, "FRSH initialized\n");
 
-       terror = pthread_create(&player_thread, &player_attr, player, NULL);
+       terror = pthread_attr_init(&player_attr);
        if (terror) assert_perror(errno);
 
+       terror = pthread_create(&player_thread, &player_attr, player, (void*) &args);
+       if (terror) assert_perror(errno);
+       fprintf(stdout, "FRSH thread created, waiting for its termination...\n");
+
        terror = pthread_join(player_thread, NULL);
        if (terror) assert_perror(errno);
+       fprintf(stdout, "FRSH thread ended. Exiting\n\n");
 
        exit(EXIT_SUCCESS);
 }
index ed4ef4764452da42122e39372f5c58bab4eb954b..4d43c595951ef7156c54843dde10dbc1c0191219 100644 (file)
@@ -14,6 +14,9 @@
 
 #include <frsh.h>
 
+#define PLAYER_BINARY  "mplayer"
+#define PLAYER_ARGS    " -fs -zoom "
+
 struct player_args {
        int budget, period;
        char file[128];