Commit f34fa60d authored by Donald Haase's avatar Donald Haase
Browse files

First pass of upporting, compiles but doesn't link.

parent 997c32ef
...@@ -85,11 +85,6 @@ ...@@ -85,11 +85,6 @@
/* Maximum index of optional LOT.VCD (the List ID Offset Table.) */ /* Maximum index of optional LOT.VCD (the List ID Offset Table.) */
#define LOT_VCD_OFFSETS ((1 << 15)-1) #define LOT_VCD_OFFSETS ((1 << 15)-1)
typedef enum {
false,
true
} bool; /* I actually have to declare this? Ugh... */
#if defined(__GNUC__) #if defined(__GNUC__)
/* this is strict ISO C99 which allows only 'unsigned int', 'signed /* this is strict ISO C99 which allows only 'unsigned int', 'signed
int' and '_Bool' explicitly as bit-field type */ int' and '_Bool' explicitly as bit-field type */
...@@ -613,7 +608,9 @@ typedef struct _EntriesVcd_simple { ...@@ -613,7 +608,9 @@ typedef struct _EntriesVcd_simple {
PRAGMA_END_PACKED PRAGMA_END_PACKED
int open_vcd(); int open_vcd(void);
void close_vcd(void);
int play_vcd_image(const char* fn);
void Start_Pbc(); void Start_Pbc();
#endif #endif
...@@ -119,7 +119,7 @@ static void *incoming_video; /* A pointer to the incoming video. We should get ...@@ -119,7 +119,7 @@ static void *incoming_video; /* A pointer to the incoming video. We should get
static kthread_t *txr_thd; /* We should have a function down below which keeps looping while vid_set is 1, static kthread_t *txr_thd; /* We should have a function down below which keeps looping while vid_set is 1,
and if got_new_video is 1, it'll tell vo_txr_load to get busy. */ and if got_new_video is 1, it'll tell vo_txr_load to get busy. */
static mutex_t * video_mut = NULL; /* We're running the decoder and the video display in separate threads static mutex_t video_mut = MUTEX_INITIALIZER; /* We're running the decoder and the video display in separate threads
so we need to keep the dc_draw_frame function from moving the pointer so we need to keep the dc_draw_frame function from moving the pointer
to incoming_video before vo_draw_frame is done uploading to the PVR. */ to incoming_video before vo_draw_frame is done uploading to the PVR. */
...@@ -153,6 +153,15 @@ psd_area_t *highlight; /* In Extended PSD Selection Lists, we'll need to highlig ...@@ -153,6 +153,15 @@ psd_area_t *highlight; /* In Extended PSD Selection Lists, we'll need to highlig
(c)2001 Andrew Kieschnick */ (c)2001 Andrew Kieschnick */
static void vo_txr_load(void *src) { static void vo_txr_load(void *src) {
/* dh - Pretty sure I rewrote this correctly. May be that it's open to optimization */
#if 1
size_t count = g_width * 2 * g_height;
count += count % 4;
sq_cpy(vid_tex[tx_cur], src, count);
#else
int i, n; int i, n;
uint32 count; uint32 count;
unsigned int *d, *s; unsigned int *d, *s;
...@@ -197,7 +206,7 @@ unsigned int *d, *s; ...@@ -197,7 +206,7 @@ unsigned int *d, *s;
/* Wait for both store queues to complete */ /* Wait for both store queues to complete */
d = (unsigned int *)0xe0000000; d = (unsigned int *)0xe0000000;
d[0] = d[8] = 0; d[0] = d[8] = 0;
#endif
} }
extern void vidclock_handle_frame(); extern void vidclock_handle_frame();
...@@ -205,7 +214,7 @@ extern void vidclock_handle_frame(); ...@@ -205,7 +214,7 @@ extern void vidclock_handle_frame();
static void draw_texture(int which) static void draw_texture(int which)
{ {
/* Display the picture--ripped from the kos png example. */ /* Display the picture--ripped from the kos png example. */
//mutex_lock(video_mut); //mutex_lock(&video_mut);
pvr_vertex_t vert; pvr_vertex_t vert;
// vidclock_handle_frame(); // vidclock_handle_frame();
...@@ -300,29 +309,30 @@ pvr_vertex_t vert; ...@@ -300,29 +309,30 @@ pvr_vertex_t vert;
pvr_scene_finish(); pvr_scene_finish();
/* tx_cur = 1-tx_cur; */ /* tx_cur = 1-tx_cur; */
// mutex_unlock(video_mut); // mutex_unlock(&video_mut);
} }
static int redraw_flag = 0; static int redraw_flag = 0;
static void video_loop(void* yarr) /* This loop will start when we open the video driver static void* video_loop(void* yarr) /* This loop will start when we open the video driver
and keep looping until we close the driver. */ and keep looping until we close the driver. */
{ {
while (vid_set == 1)
while (vid_set == 1) {
{ if (got_new_video > 0)
if (got_new_video > 0) {
{ mutex_lock(&video_mut);
mutex_lock(video_mut); if (redraw_flag)
if (redraw_flag) goto no_handle_frame; goto no_handle_frame;
vidclock_handle_frame(); vidclock_handle_frame();
no_handle_frame: no_handle_frame:
redraw_flag = 0; redraw_flag = 0;
draw_texture(got_new_video-1); /* Draw our texture. */ draw_texture(got_new_video-1); /* Draw our texture. */
got_new_video = 0; got_new_video = 0;
mutex_unlock(video_mut); mutex_unlock(&video_mut);
} }
thd_pass(); /* We're done here for a bit. */ thd_pass(); /* We're done here for a bit. */
} }
return NULL;
} }
/* IMPORTANT! DON'T FORGET TO PUT CHECKS IN HERE! /* IMPORTANT! DON'T FORGET TO PUT CHECKS IN HERE!
...@@ -340,8 +350,7 @@ void redraw_frame() /* This is really a hack, but oh well. */ ...@@ -340,8 +350,7 @@ void redraw_frame() /* This is really a hack, but oh well. */
{ {
vid_set = 1; vid_set = 1;
got_new_video = 0; got_new_video = 0;
if (video_mut == NULL) mutex_create(video_mut); /* Create our mutex if it doesn't exist. */ txr_thd = thd_create(0, video_loop, NULL); /* Start our display thread. */
txr_thd = thd_create(video_loop, NULL); /* Start our display thread. */
} }
#else #else
if (!vid_set) if (!vid_set)
...@@ -357,14 +366,14 @@ retry_redraw: ...@@ -357,14 +366,14 @@ retry_redraw:
{ {
goto retry_redraw; goto retry_redraw;
} }
mutex_lock (video_mut); /* Request a turn at exclusive access to mutex_lock (&video_mut); /* Request a turn at exclusive access to
the incoming_video pointer and got_new_video. */ the incoming_video pointer and got_new_video. */
vo_txr_load(last_buf); vo_txr_load(last_buf);
redraw_flag = 1; redraw_flag = 1;
got_new_video = tx_cur+1; /* Alert txr_thd that we have some new data for it. */ got_new_video = tx_cur+1; /* Alert txr_thd that we have some new data for it. */
mutex_unlock (video_mut); /* Let txr_thd have access to incoming_video now that it mutex_unlock (&video_mut); /* Let txr_thd have access to incoming_video now that it
knows where to find it.*/ knows where to find it.*/
tx_cur = 1-tx_cur; tx_cur = 1-tx_cur;
} }
...@@ -377,22 +386,21 @@ static void dc_draw_frame (vo_instance_t * instance, ...@@ -377,22 +386,21 @@ static void dc_draw_frame (vo_instance_t * instance,
{ {
vid_set = 1; vid_set = 1;
got_new_video = 0; got_new_video = 0;
if (video_mut == NULL) mutex_create(video_mut); /* Create our mutex if it doesn't exist. */ txr_thd = thd_create(0, video_loop, NULL); /* Start our display thread. */
txr_thd = thd_create(video_loop, NULL); /* Start our display thread. */
} }
retry: retry:
if (got_new_video > 0) if (got_new_video > 0)
{ {
goto retry; goto retry;
} }
mutex_lock (video_mut); /* Request a turn at exclusive access to mutex_lock (&video_mut); /* Request a turn at exclusive access to
the incoming_video pointer and got_new_video. */ the incoming_video pointer and got_new_video. */
vo_txr_load(buf[0]); vo_txr_load(buf[0]);
last_buf = buf[0]; /* Point at the new data so we know where it is if we need to redraw. */ last_buf = buf[0]; /* Point at the new data so we know where it is if we need to redraw. */
got_new_video = tx_cur+1; /* Alert txr_thd that we have some new data for it. */ got_new_video = tx_cur+1; /* Alert txr_thd that we have some new data for it. */
mutex_unlock (video_mut); /* Let txr_thd have access to incoming_video now that it mutex_unlock (&video_mut); /* Let txr_thd have access to incoming_video now that it
knows where to find it.*/ knows where to find it.*/
tx_cur = 1-tx_cur; tx_cur = 1-tx_cur;
} }
...@@ -402,7 +410,7 @@ static void dc_close (vo_instance_t * _instance) ...@@ -402,7 +410,7 @@ static void dc_close (vo_instance_t * _instance)
vid_set = 0; /* This will cause our looping thread to exit. */ vid_set = 0; /* This will cause our looping thread to exit. */
thd_wait (txr_thd); /* Now give it a chance to exit if it's still doing something. */ thd_join(txr_thd, NULL); /* Now give it a chance to exit if it's still doing something. */
if (tx_allocated ==1) if (tx_allocated ==1)
{ {
...@@ -457,7 +465,7 @@ static int dc_setup (vo_instance_t * instance, unsigned int width, ...@@ -457,7 +465,7 @@ static int dc_setup (vo_instance_t * instance, unsigned int width,
video thread to exit before we try to start it again. */ video thread to exit before we try to start it again. */
{ {
vid_set = 0; /* This will cause the thread to exit. */ vid_set = 0; /* This will cause the thread to exit. */
thd_wait(txr_thd); /* Wait for it to exit. */ thd_join(txr_thd, NULL); /* Wait for it to exit. */
vid_set = 1; /* Set this back. Otherwise we'll allocate stuff that's already allocated! */ vid_set = 1; /* Set this back. Otherwise we'll allocate stuff that's already allocated! */
} }
...@@ -489,8 +497,7 @@ static int dc_setup (vo_instance_t * instance, unsigned int width, ...@@ -489,8 +497,7 @@ static int dc_setup (vo_instance_t * instance, unsigned int width,
got_new_video = 0; got_new_video = 0;
} }
if (video_mut == NULL) mutex_create(video_mut); /* Create our mutex if it doesn't exist. */ txr_thd = thd_create(0, video_loop, NULL); /* Start our display thread. */
txr_thd = thd_create(video_loop, NULL); /* Start our display thread. */
return 0; return 0;
} }
......
...@@ -191,7 +191,7 @@ static kthread_t * loop_thread; ...@@ -191,7 +191,7 @@ static kthread_t * loop_thread;
/* This loops as long as the audio driver is open. /* This loops as long as the audio driver is open.
Do we want to poll more frequently? */ Do we want to poll more frequently? */
static void play_loop(void* yarr) static void* play_loop(void* yarr)
{ {
while (aud_set == 1) while (aud_set == 1)
...@@ -207,7 +207,7 @@ static void play_loop(void* yarr) ...@@ -207,7 +207,7 @@ static void play_loop(void* yarr)
thd_pass(); thd_pass();
if (aud_set == 0) if (aud_set == 0)
{ {
return; return NULL;
} }
} }
...@@ -225,7 +225,7 @@ static void start_audio() ...@@ -225,7 +225,7 @@ static void start_audio()
aud_set = 1; aud_set = 1;
//snd_stream_prefill(shnd); //snd_stream_prefill(shnd);
snd_stream_start(shnd, sample_rate, chans-1); snd_stream_start(shnd, sample_rate, chans-1);
loop_thread = thd_create(play_loop, NULL); loop_thread = thd_create(0, play_loop, NULL);
} }
/* Allocate streaming channel(s), set our sampling frequency, and say "GO!" */ /* Allocate streaming channel(s), set our sampling frequency, and say "GO!" */
...@@ -311,7 +311,7 @@ static int oss_close(void *handle) ...@@ -311,7 +311,7 @@ static int oss_close(void *handle)
free(oss_out); free(oss_out);
} }
aud_set = sndptr = 0; aud_set = sndptr = 0;
thd_wait(loop_thread); thd_join(loop_thread, NULL);
fudge_factor = 0.0; fudge_factor = 0.0;
snd_stream_stop(shnd); snd_stream_stop(shnd);
snd_stream_destroy(shnd); snd_stream_destroy(shnd);
......
...@@ -194,7 +194,7 @@ static kthread_t * loop_thread; ...@@ -194,7 +194,7 @@ static kthread_t * loop_thread;
condvar_t *audio_cond = NULL; condvar_t *audio_cond = NULL;
/* This loops as long as the audio driver is open. /* This loops as long as the audio driver is open.
Do we want to poll more frequently? */ Do we want to poll more frequently? */
static void play_loop(void* yarr) static void* play_loop(void* yarr)
{ {
while (aud_set == 1) while (aud_set == 1)
...@@ -212,7 +212,7 @@ static void play_loop(void* yarr) ...@@ -212,7 +212,7 @@ static void play_loop(void* yarr)
if (aud_set == 0) if (aud_set == 0)
{ {
mutex_unlock(audio_mut); mutex_unlock(audio_mut);
return; return NULL;
} }
} }
...@@ -231,7 +231,7 @@ static void start_audio() ...@@ -231,7 +231,7 @@ static void start_audio()
aud_set = 1; aud_set = 1;
//snd_stream_prefill(shnd); //snd_stream_prefill(shnd);
snd_stream_start(shnd, sample_rate, chans-1); snd_stream_start(shnd, sample_rate, chans-1);
loop_thread = thd_create(play_loop, NULL); loop_thread = thd_create(0, play_loop, NULL);
} }
/* Allocate streaming channel(s), set our sampling frequency, and say "GO!" */ /* Allocate streaming channel(s), set our sampling frequency, and say "GO!" */
......
...@@ -60,7 +60,7 @@ OBJS=ghettoplay.o mpeg2play.o mp3junk.o \ ...@@ -60,7 +60,7 @@ OBJS=ghettoplay.o mpeg2play.o mp3junk.o \
-I. -DNOANALYSIS -DHAVE_CONFIG_H -DDEBUGFPS -ffast-math -I. -DNOANALYSIS -DHAVE_CONFIG_H -DDEBUGFPS -ffast-math
#Use these flags for a release build. #Use these flags for a release build.
KOS_CFLAGS += -L../lib -I. -I../include -DOSS -DUSE_LAYER_1 -DUSE_LAYER_2 -DUSE_LAYER_3 \ KOS_CFLAGS += -L../lib -I. -I../include -DOSS -DUSE_LAYER_1 -DUSE_LAYER_2 -DUSE_LAYER_3 \
-I. -DNOANALYSIS -DHAVE_CONFIG_H -ffast-math -I. -DNOANALYSIS -DHAVE_CONFIG_H -ffast-math -DHAVE_INTTYPES_H -DGNU_SOURCE
clean: clean:
-rm -f plaympeg.elf $(OBJS) -rm -f plaympeg.elf $(OBJS)
......
...@@ -1453,7 +1453,7 @@ char *ext; ...@@ -1453,7 +1453,7 @@ char *ext;
// mpeg2_malloc_hooks (malloc_hook, NULL); // mpeg2_malloc_hooks (malloc_hook, NULL);
mpeg_audio_activated = 0; mpeg_audio_activated = 0;
if(!stricmp(ext,"mp1")||(!stricmp(ext,"mp2"))||(!stricmp(ext,"mp3"))) if(!strcasecmp(ext,"mp1")||(!strcasecmp(ext,"mp2"))||(!strcasecmp(ext,"mp3")))
{ {
mp3_loop (file_to_play); mp3_loop (file_to_play);
...@@ -1461,10 +1461,10 @@ char *ext; ...@@ -1461,10 +1461,10 @@ char *ext;
in_file = fs_open (file_to_play, O_RDONLY); in_file = fs_open (file_to_play, O_RDONLY);
bkg_clear(); /* The menu is using PVR memory that we need. */ bkg_clear(); /* The menu is using PVR memory that we need. */
if(!stricmp(ext,"mpg")||(!stricmp(ext,"mpeg"))||(!stricmp(ext,"pss")) if(!strcasecmp(ext,"mpg")||(!strcasecmp(ext,"mpeg"))||(!strcasecmp(ext,"pss"))
||(!stricmp(ext,"sfd"))||(!stricmp(ext,"dat"))) ||(!strcasecmp(ext,"sfd"))||(!strcasecmp(ext,"dat")))
ps_loop (); ps_loop ();
if(!stricmp(ext,"m2v")||(!stricmp(ext,"m1v"))) if(!strcasecmp(ext,"m2v")||(!strcasecmp(ext,"m1v")))
es_loop (); es_loop ();
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
(c)2000 Dan Potter (c)2000 Dan Potter
*/ */
#include <kos.h>
#include <string.h> #include <string.h>
#include "gp.h" #include "gp.h"
#include "mpegav.h" #include "mpegav.h"
...@@ -185,21 +186,22 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */ ...@@ -185,21 +186,22 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100 100, 100, 100, 100, 100, 100, 100, 100
}; };
static uint8 mcont = 0; static maple_device_t * mcont = NULL;
static cont_cond_t cond; static cont_state_t * state = NULL;
if (!mcont) { if (!mcont) mcont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
mcont = maple_first_controller();
if (!mcont) { return; }
}
for (i=0; i< 32; i++) band_value[i] = get_eq_band(i);
for (i=0; i< 32; i++)
band_value[i] = get_eq_band(i); a_pressed = framecnt;
a_pressed = framecnt;
while (in_menu==1) while (in_menu==1)
{ {
if (cont_get_cond(mcont, &cond)) { return; } state = (cont_state_t *)maple_dev_status(mcont);
if (!(cond.buttons & CONT_DPAD_UP)) if (!state) return;
if (!(state->buttons & CONT_DPAD_UP))
{ {
if ((framecnt - up_moved) > 3) if ((framecnt - up_moved) > 3)
{ {
...@@ -209,7 +211,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */ ...@@ -209,7 +211,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
up_moved = framecnt; up_moved = framecnt;
} }
} }
if (!(cond.buttons & CONT_DPAD_DOWN)) if (!(state->buttons & CONT_DPAD_DOWN))
{ {
if ((framecnt - down_moved) > 3) if ((framecnt - down_moved) > 3)
{ {
...@@ -219,7 +221,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */ ...@@ -219,7 +221,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
down_moved = framecnt; down_moved = framecnt;
} }
} }
if (!(cond.buttons & CONT_DPAD_LEFT)) if (!(state->buttons & CONT_DPAD_LEFT))
{ {
if ((framecnt - left_moved) > 10) if ((framecnt - left_moved) > 10)
{ {
...@@ -227,7 +229,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */ ...@@ -227,7 +229,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
left_moved = framecnt; left_moved = framecnt;
} }
} }
if (!(cond.buttons & CONT_DPAD_RIGHT)) if (!(state->buttons & CONT_DPAD_RIGHT))
{ {
if ((framecnt - right_moved) > 10) if ((framecnt - right_moved) > 10)
{ {
...@@ -235,14 +237,14 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */ ...@@ -235,14 +237,14 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
right_moved = framecnt; right_moved = framecnt;
} }
} }
if (!(cond.buttons & CONT_A)) if (!(state->buttons & CONT_A))
{ {
if((framecnt - a_pressed) > 10) if((framecnt - a_pressed) > 10)
{ {
in_menu = 0; in_menu = 0;
} }
} }
if (!(cond.buttons & CONT_X)) if (!(state->buttons & CONT_X))
{ {
for (i=0; i<32; i++) for (i=0; i<32; i++)
{ {
...@@ -304,7 +306,6 @@ static void settings_menu() ...@@ -304,7 +306,6 @@ static void settings_menu()
static int up_moved = 0, down_moved = 0, left_moved = 0, right_moved = 0, static int up_moved = 0, down_moved = 0, left_moved = 0, right_moved = 0,
a_pressed = 0, in_menu = 1, selection = 0, menu_item = 0; a_pressed = 0, in_menu = 1, selection = 0, menu_item = 0;
static int last_selection[TOTAL_MENU_ITEMS]; static int last_selection[TOTAL_MENU_ITEMS];
static cont_cond_t cond; static uint8 mcont = 0;
char *optionlist[TOTAL_MENU_ITEMS][3]= char *optionlist[TOTAL_MENU_ITEMS][3]=
{ {
{"Best audio (default)", "Okay audio", "Worst audio"}, /* Audio Quality */ {"Best audio (default)", "Okay audio", "Worst audio"}, /* Audio Quality */
...@@ -312,20 +313,21 @@ static void settings_menu() ...@@ -312,20 +313,21 @@ static void settings_menu()
{"Off", "On","Set"}, /* EQ on/off */ {"Off", "On","Set"}, /* EQ on/off */
{"On(Default)", "Off"," "} /* PBC on/off */ {"On(Default)", "Off"," "} /* PBC on/off */
}; };
if (!mcont) { static maple_device_t * mcont = NULL;
mcont = maple_first_controller(); static cont_state_t * state = NULL;
if (!mcont) { return; }
} if (!mcont) mcont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
in_menu = 1; in_menu = 1;
a_pressed = framecnt; a_pressed = framecnt;
while (in_menu==1) while (in_menu==1)
{ {
if (cont_get_cond(mcont, &cond)) { return; } state = (cont_state_t *)maple_dev_status(mcont);
if (!(cond.buttons & CONT_DPAD_UP)) { if (!state) return;
if (!(state->buttons & CONT_DPAD_UP)) {
if ((framecnt - up_moved) > 10) { if ((framecnt - up_moved) > 10) {
if (menu_item > 0) { if (menu_item > 0) {
last_selection[menu_item] = selection; last_selection[menu_item] = selection;
...@@ -335,7 +337,7 @@ static void settings_menu() ...@@ -335,7 +337,7 @@ static void settings_menu()
up_moved = framecnt; up_moved = framecnt;
} }
} }
if (!(cond.buttons & CONT_DPAD_DOWN)) { if (!(state->buttons & CONT_DPAD_DOWN)) {
if ((framecnt - down_moved) > 10) { if ((framecnt - down_moved) > 10) {
if (menu_item < TOTAL_MENU_ITEMS-1) { if (menu_item < TOTAL_MENU_ITEMS-1) {
last_selection[menu_item] = selection; last_selection[menu_item] = selection;
...@@ -346,7 +348,7 @@ static void settings_menu() ...@@ -346,7 +348,7 @@ static void settings_menu()
} }
} }
if (!(cond.buttons & CONT_DPAD_LEFT)) { if (!(state->buttons & CONT_DPAD_LEFT)) {
if ((framecnt - left_moved) > 10) { if ((framecnt - left_moved) > 10) {
if (selection >= 0) { if (selection >= 0) {
selection--; selection--;
...@@ -361,7 +363,7 @@ static void settings_menu() ...@@ -361,7 +363,7 @@ static void settings_menu()
if ((menu_item==3) && (selection < 2) )pbc_switch = 1-selection; if ((menu_item==3) && (selection < 2) )pbc_switch = 1-selection;
} }
} }
if (!(cond.buttons & CONT_DPAD_RIGHT)) { if (!(state->buttons & CONT_DPAD_RIGHT)) {
if ((framecnt - right_moved) > 10) { if ((framecnt - right_moved) > 10) {
if (selection <= 2) { if (selection <= 2) {
selection++; selection++;
...@@ -376,7 +378,7 @@ static void settings_menu() ...@@ -376,7 +378,7 @@ static void settings_menu()
if ((menu_item==3) && (selection < 2) )pbc_switch = 1-selection; if ((menu_item==3) && (selection < 2) )pbc_switch = 1-selection;
} }
} }
if (!(cond.buttons & CONT_A)){ if (!(state->buttons & CONT_A)){
if((framecnt - a_pressed) > 10) { if((framecnt - a_pressed) > 10) {
in_menu = 0; in_menu = 0;
...@@ -426,15 +428,15 @@ static void settings_menu() ...@@ -426,15 +428,15 @@ static void settings_menu()
} }
void check_controller() { void check_controller() {
static int up_moved = 0, down_moved = 0, a_pressed = 0, y_pressed = 0, x_pressed = 0; static int up_moved = 0, down_moved = 0, a_pressed = 0, y_pressed = 0, x_pressed = 0;
static cont_cond_t cond; static uint8 mcont = 0; static maple_device_t * mcont = NULL;
static cont_state_t * state = NULL;
if (!mcont) {
mcont = maple_first_controller(); if (!mcont) mcont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
if (!mcont) { return; }
} state = (cont_state_t *)maple_dev_status(mcont);
if (cont_get_cond(mcont, &cond)) { return; } if (!state) return;
if (!(cond.buttons & CONT_DPAD_UP)) { if (!(state->buttons & CONT_DPAD_UP)) {
if ((framecnt - up_moved) > 10) { if ((framecnt - up_moved) > 10) {
if (selected > 0) { if (selected > 0) {
selected--; selected--;
...@@ -445,7 +447,7 @@ void check_controller() { ...@@ -445,7 +447,7 @@ void check_controller() {
up_moved = framecnt; up_moved = framecnt;
} }
} }
if (!(cond.buttons & CONT_DPAD_DOWN)) { if (!(state->buttons & CONT_DPAD_DOWN)) {
if ((framecnt - down_moved) > 10) { if ((framecnt - down_moved) > 10) {
if (selected < (num_entries - 1)) { if (selected < (num_entries - 1)) {
selected++; selected++;
...@@ -457,7 +459,7 @@ void check_controller() { ...@@ -457,7 +459,7 @@ void check_controller() {
down_moved = framecnt; down_moved = framecnt;
} }
} }
if (cond.ltrig > 0) { if (state->ltrig > 0) {
if ((framecnt - up_moved) > 10) { if ((framecnt - up_moved) > 10) {
// selected -= 14; // selected -= 14;
selected -= 10; selected -= 10;
...@@ -467,7 +469,7 @@ void check_controller() { ...@@ -467,7 +469,7 @@ void check_controller() {
up_moved = framecnt; up_moved = framecnt;
} }
} }
if (cond.rtrig > 0) { if (state->rtrig > 0) {
if ((framecnt - down_moved) > 10) { if ((framecnt - down_moved) > 10) {
// selected += 14; // selected += 14;
selected += 10; selected += 10;
...@@ -480,7 +482,7 @@ void check_controller() { ...@@ -480,7 +482,7 @@ void check_controller() {
} }
} }
if (!(cond.buttons & CONT_Y)) { if (!(state->buttons & CONT_Y)) {
if ((framecnt - y_pressed) > 10) if ((framecnt - y_pressed) > 10)
{ {
strcat(workstring,curdir); strcat(workstring,curdir);
...@@ -499,7 +501,7 @@ void check_controller() { ...@@ -499,7 +501,7 @@ void check_controller() {
y_pressed=framecnt; y_pressed=framecnt;
} }
if (!(cond.buttons & CONT_X) ) { if (!(state->buttons & CONT_X) ) {
if ((framecnt - x_pressed) > 10){ if ((framecnt - x_pressed) > 10){
/* End of translucent list */ /* End of translucent list */
pvr_list_finish(); pvr_list_finish();
...@@ -524,7 +526,7 @@ void check_controller() { ...@@ -524,7 +526,7 @@ void check_controller() {
} }
} }
if (!(cond.buttons & CONT_A) && !load_queued) { if (!(state->buttons & CONT_A) && !load_queued) {
if ((framecnt - a_pressed) > 10) if ((framecnt - a_pressed) > 10)
{ {
/* End of translucent list */ /* End of translucent list */
...@@ -562,7 +564,7 @@ void check_controller() { ...@@ -562,7 +564,7 @@ void check_controller() {
strcat(loadme,entries[selected].fn); strcat(loadme,entries[selected].fn);
ext = (char *)(strchr(entries[selected].fn, '.')+1); ext = (char *)(strchr(entries[selected].fn, '.')+1);
if(!stricmp(ext,"bin")) if(!strcasecmp(ext,"bin"))
{ {
vmu_set_icon(vcdcontrols_xpm); vmu_set_icon(vcdcontrols_xpm);
play_vcd_image(loadme); play_vcd_image(loadme);
...@@ -645,7 +647,7 @@ void song_menu_render() { ...@@ -645,7 +647,7 @@ void song_menu_render() {
/* If we don't have a file listing, get it now */ /* If we don't have a file listing, get it now */
if (num_entries == 0 && !load_queued) { if (num_entries == 0 && !load_queued) {
load_queued = 1; load_queued = 1;
//thd_create(load_song_list, NULL); //thd_create(0, load_song_list, NULL);
load_song_list(); load_song_list();
} }
......
...@@ -44,8 +44,6 @@ ISO9660 systems, as these were used as references as well. ...@@ -44,8 +44,6 @@ ISO9660 systems, as these were used as references as well.
#include "vcd_iso.h" #include "vcd_iso.h"
#include "libvcd.h" #include "libvcd.h"
CVSID("$Id: fs_iso9660.c,v 1.2 2003/07/15 07:55:01 bardtx Exp $");
#define MAX_ISO_FILES 8 #define MAX_ISO_FILES 8
static int init_percd(); static int init_percd();
...@@ -232,16 +230,16 @@ static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */ ...@@ -232,16 +230,16 @@ static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */
static cache_block_t *dcache[NUM_CACHE_BLOCKS]; /* data cache */ static cache_block_t *dcache[NUM_CACHE_BLOCKS]; /* data cache */
/* Cache modification mutex */ /* Cache modification mutex */
static mutex_t * cache_mutex; static mutex_t cache_mutex = MUTEX_INITIALIZER;
/* Clears all cache blocks */ /* Clears all cache blocks */
static void bclear_cache(cache_block_t **cache) { static void bclear_cache(cache_block_t **cache) {
int i; int i;
mutex_lock(cache_mutex); mutex_lock(&cache_mutex);
for (i=0; i<NUM_CACHE_BLOCKS; i++) for (i=0; i<NUM_CACHE_BLOCKS; i++)
cache[i]->sector = -1; cache[i]->sector = -1;
mutex_unlock(cache_mutex); mutex_unlock(&cache_mutex);
} }
/* Graduate a block from its current position to the MRU end of the cache */ /* Graduate a block from its current position to the MRU end of the cache */
...@@ -267,7 +265,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) { ...@@ -267,7 +265,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
int i, j, rv; int i, j, rv;
rv = -1; rv = -1;
mutex_lock(cache_mutex); mutex_lock(&cache_mutex);
/* Look for a pre-existing cache block */ /* Look for a pre-existing cache block */
for (i=NUM_CACHE_BLOCKS-1; i>=0; i--) { for (i=NUM_CACHE_BLOCKS-1; i>=0; i--) {
...@@ -305,7 +303,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) { ...@@ -305,7 +303,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
/* Return the new cache block index */ /* Return the new cache block index */
bread_exit: bread_exit:
mutex_unlock(cache_mutex); mutex_unlock(&cache_mutex);
return rv; return rv;
} }
...@@ -493,7 +491,7 @@ static iso_dirent_t *find_object(const char *fn, int dir, ...@@ -493,7 +491,7 @@ static iso_dirent_t *find_object(const char *fn, int dir,
else else
fnlen = strlen(fn); fnlen = strlen(fn);
if (!strnicmp(rrname, fn, fnlen) && ! *(rrname + fnlen)) { if (!strncasecmp(rrname, fn, fnlen) && ! *(rrname + fnlen)) {
if (!((dir << 1) ^ de->flags)) if (!((dir << 1) ^ de->flags))
return de; return de;
} }
...@@ -571,7 +569,7 @@ static struct { ...@@ -571,7 +569,7 @@ static struct {
} fh[MAX_ISO_FILES]; } fh[MAX_ISO_FILES];
/* Mutex for file handles */ /* Mutex for file handles */
static mutex_t * fh_mutex; static mutex_t fh_mutex = MUTEX_INITIALIZER;
/* Break all of our open file descriptor. This is necessary when the disc /* Break all of our open file descriptor. This is necessary when the disc
is changed so that we don't accidentally try to keep on doing stuff is changed so that we don't accidentally try to keep on doing stuff
...@@ -580,10 +578,10 @@ static mutex_t * fh_mutex; ...@@ -580,10 +578,10 @@ static mutex_t * fh_mutex;
static void iso_break_all() { static void iso_break_all() {
int i; int i;
mutex_lock(fh_mutex); mutex_lock(&fh_mutex);
for (i=0; i<MAX_ISO_FILES; i++) for (i=0; i<MAX_ISO_FILES; i++)
fh[i].broken = 1; fh[i].broken = 1;
mutex_unlock(fh_mutex); mutex_unlock(&fh_mutex);
} }
/* Open a file or directory */ /* Open a file or directory */
...@@ -605,13 +603,13 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) { ...@@ -605,13 +603,13 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
if (!de) return 0; if (!de) return 0;
/* Find a free file handle */ /* Find a free file handle */
mutex_lock(fh_mutex); mutex_lock(&fh_mutex);
for (fd=0; fd<MAX_ISO_FILES; fd++) for (fd=0; fd<MAX_ISO_FILES; fd++)
if (fh[fd].first_extent == 0) { if (fh[fd].first_extent == 0) {
fh[fd].first_extent = -1; fh[fd].first_extent = -1;
break; break;
} }
mutex_unlock(fh_mutex); mutex_unlock(&fh_mutex);
if (fd >= MAX_ISO_FILES) if (fd >= MAX_ISO_FILES)
return 0; return 0;
...@@ -627,7 +625,7 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) { ...@@ -627,7 +625,7 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
} }
/* Close a file or directory */ /* Close a file or directory */
static void iso_close(void * h) { static int iso_close(void * h) {
file_t fd = (file_t)h; file_t fd = (file_t)h;
/* Check that the fd is valid */ /* Check that the fd is valid */
...@@ -635,6 +633,8 @@ static void iso_close(void * h) { ...@@ -635,6 +633,8 @@ static void iso_close(void * h) {
/* No need to lock the mutex: this is an atomic op */ /* No need to lock the mutex: this is an atomic op */
fh[fd].first_extent = 0; fh[fd].first_extent = 0;
} }
return 0;
} }
/* Read from a file */ /* Read from a file */
...@@ -851,7 +851,7 @@ int bincue_reset() { ...@@ -851,7 +851,7 @@ int bincue_reset() {
time someone calls in it'll get reset. */ time someone calls in it'll get reset. */
static int iso_last_status; static int iso_last_status;
static int iso_vblank_hnd; static int iso_vblank_hnd;
static void iso_vblank(uint32 evt) { static void iso_vblank(uint32 evt, void*) {
int status, disc_type; int status, disc_type;
/* Get the status. This may fail if a CD operation is in /* Get the status. This may fail if a CD operation is in
...@@ -868,7 +868,7 @@ static void iso_vblank(uint32 evt) { ...@@ -868,7 +868,7 @@ static void iso_vblank(uint32 evt) {
/* There's only one ioctl at the moment (re-initialize caches) but you should /* There's only one ioctl at the moment (re-initialize caches) but you should
always clear data and size. */ always clear data and size. */
static int iso_ioctl(void * hnd, void *data, size_t size) { static int iso_ioctl(void *, int, va_list) {
bincue_reset(); bincue_reset();
return 0; return 0;
...@@ -918,10 +918,6 @@ int fs_bincue_mount(const char *fn) { ...@@ -918,10 +918,6 @@ int fs_bincue_mount(const char *fn) {
/* Mark the first as active so we can have an error FD of zero */ /* Mark the first as active so we can have an error FD of zero */
fh[0].first_extent = -1; fh[0].first_extent = -1;
/* Init thread mutexes */
cache_mutex = mutex_create();
fh_mutex = mutex_create();
/* Allocate cache block space */ /* Allocate cache block space */
for (i=0; i<NUM_CACHE_BLOCKS; i++) { for (i=0; i<NUM_CACHE_BLOCKS; i++) {
icache[i] = malloc(sizeof(cache_block_t)); icache[i] = malloc(sizeof(cache_block_t));
...@@ -936,7 +932,7 @@ int fs_bincue_mount(const char *fn) { ...@@ -936,7 +932,7 @@ int fs_bincue_mount(const char *fn) {
iso_last_status = -1; iso_last_status = -1;
read_sectors = bincue_read_sectors; read_sectors = bincue_read_sectors;
/* Register with the vblank */ /* Register with the vblank */
iso_vblank_hnd = vblank_handler_add(iso_vblank); iso_vblank_hnd = vblank_handler_add(iso_vblank, NULL);
/* Register with VFS */ /* Register with VFS */
return nmmgr_handler_add(&vh.nmmgr); return nmmgr_handler_add(&vh.nmmgr);
...@@ -959,13 +955,6 @@ int fs_bincue_unmount() { ...@@ -959,13 +955,6 @@ int fs_bincue_unmount() {
free(dcache[i]); free(dcache[i]);
} }
/* Free muteces */
if (cache_mutex != NULL)
mutex_destroy(cache_mutex);
if (fh_mutex != NULL)
mutex_destroy(fh_mutex);
cache_mutex = fh_mutex = NULL;
read_sectors = cdrom_read_sectors; read_sectors = cdrom_read_sectors;
mounted = 0; mounted = 0;
return nmmgr_handler_remove(&vh.nmmgr); return nmmgr_handler_remove(&vh.nmmgr);
......
...@@ -43,8 +43,6 @@ ISO9660 systems, as these were used as references as well. ...@@ -43,8 +43,6 @@ ISO9660 systems, as these were used as references as well.
#include "vcd_iso.h" #include "vcd_iso.h"
CVSID("$Id: fs_iso9660.c,v 1.2 2003/07/15 07:55:01 bardtx Exp $");
#define MAX_ISO_FILES 8 #define MAX_ISO_FILES 8
static int init_percd(); static int init_percd();
...@@ -194,16 +192,16 @@ static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */ ...@@ -194,16 +192,16 @@ static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */
static cache_block_t *dcache[NUM_CACHE_BLOCKS]; /* data cache */ static cache_block_t *dcache[NUM_CACHE_BLOCKS]; /* data cache */
/* Cache modification mutex */ /* Cache modification mutex */
static mutex_t * cache_mutex; static mutex_t cache_mutex = MUTEX_INITIALIZER;
/* Clears all cache blocks */ /* Clears all cache blocks */
static void bclear_cache(cache_block_t **cache) { static void bclear_cache(cache_block_t **cache) {
int i; int i;
mutex_lock(cache_mutex); mutex_lock(&cache_mutex);
for (i=0; i<NUM_CACHE_BLOCKS; i++) for (i=0; i<NUM_CACHE_BLOCKS; i++)
cache[i]->sector = -1; cache[i]->sector = -1;
mutex_unlock(cache_mutex); mutex_unlock(&cache_mutex);
} }
/* Graduate a block from its current position to the MRU end of the cache */ /* Graduate a block from its current position to the MRU end of the cache */
...@@ -229,7 +227,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) { ...@@ -229,7 +227,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
int i, j, rv; int i, j, rv;
rv = -1; rv = -1;
mutex_lock(cache_mutex); mutex_lock(&cache_mutex);
/* Look for a pre-existing cache block */ /* Look for a pre-existing cache block */
for (i=NUM_CACHE_BLOCKS-1; i>=0; i--) { for (i=NUM_CACHE_BLOCKS-1; i>=0; i--) {
...@@ -267,7 +265,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) { ...@@ -267,7 +265,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
/* Return the new cache block index */ /* Return the new cache block index */
bread_exit: bread_exit:
mutex_unlock(cache_mutex); mutex_unlock(&cache_mutex);
return rv; return rv;
} }
...@@ -492,7 +490,7 @@ static iso_dirent_t *find_object(const char *fn, int dir, ...@@ -492,7 +490,7 @@ static iso_dirent_t *find_object(const char *fn, int dir,
else else
fnlen = strlen(fn); fnlen = strlen(fn);
if (!strnicmp(rrname, fn, fnlen) && ! *(rrname + fnlen)) { if (!strncasecmp(rrname, fn, fnlen) && ! *(rrname + fnlen)) {
if (!((dir << 1) ^ de->flags)) if (!((dir << 1) ^ de->flags))
return de; return de;
} }
...@@ -570,7 +568,7 @@ static struct { ...@@ -570,7 +568,7 @@ static struct {
} fh[MAX_ISO_FILES]; } fh[MAX_ISO_FILES];
/* Mutex for file handles */ /* Mutex for file handles */
static mutex_t * fh_mutex; static mutex_t fh_mutex = MUTEX_INITIALIZER;
/* Break all of our open file descriptor. This is necessary when the disc /* Break all of our open file descriptor. This is necessary when the disc
is changed so that we don't accidentally try to keep on doing stuff is changed so that we don't accidentally try to keep on doing stuff
...@@ -579,10 +577,10 @@ static mutex_t * fh_mutex; ...@@ -579,10 +577,10 @@ static mutex_t * fh_mutex;
static void iso_break_all() { static void iso_break_all() {
int i; int i;
mutex_lock(fh_mutex); mutex_lock(&fh_mutex);
for (i=0; i<MAX_ISO_FILES; i++) for (i=0; i<MAX_ISO_FILES; i++)
fh[i].broken = 1; fh[i].broken = 1;
mutex_unlock(fh_mutex); mutex_unlock(&fh_mutex);
} }
/* Open a file or directory */ /* Open a file or directory */
...@@ -604,13 +602,13 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) { ...@@ -604,13 +602,13 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
if (!de) return 0; if (!de) return 0;
/* Find a free file handle */ /* Find a free file handle */
mutex_lock(fh_mutex); mutex_lock(&fh_mutex);
for (fd=0; fd<MAX_ISO_FILES; fd++) for (fd=0; fd<MAX_ISO_FILES; fd++)
if (fh[fd].first_extent == 0) { if (fh[fd].first_extent == 0) {
fh[fd].first_extent = -1; fh[fd].first_extent = -1;
break; break;
} }
mutex_unlock(fh_mutex); mutex_unlock(&fh_mutex);
if (fd >= MAX_ISO_FILES) if (fd >= MAX_ISO_FILES)
return 0; return 0;
...@@ -626,14 +624,15 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) { ...@@ -626,14 +624,15 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
} }
/* Close a file or directory */ /* Close a file or directory */
static void iso_close(void * h) { static int iso_close(void * h) {
file_t fd = (file_t)h; file_t fd = (file_t)h;
/* Check that the fd is valid */ /* Check that the fd is valid */
if (fd < MAX_ISO_FILES) { if (fd < MAX_ISO_FILES) {
/* No need to lock the mutex: this is an atomic op */ /* No need to lock the mutex: this is an atomic op */
fh[fd].first_extent = 0; fh[fd].first_extent = 0;
} }
return 0;
} }
/* Read from a file */ /* Read from a file */
...@@ -850,7 +849,7 @@ int iso_bridge_reset() { ...@@ -850,7 +849,7 @@ int iso_bridge_reset() {
time someone calls in it'll get reset. */ time someone calls in it'll get reset. */
static int iso_last_status; static int iso_last_status;
static int iso_vblank_hnd; static int iso_vblank_hnd;
static void iso_vblank(uint32 evt) { static void iso_vblank(uint32 evt, void*) {
int status, disc_type; int status, disc_type;
/* Get the status. This may fail if a CD operation is in /* Get the status. This may fail if a CD operation is in
...@@ -867,7 +866,7 @@ static void iso_vblank(uint32 evt) { ...@@ -867,7 +866,7 @@ static void iso_vblank(uint32 evt) {
/* There's only one ioctl at the moment (re-initialize caches) but you should /* There's only one ioctl at the moment (re-initialize caches) but you should
always clear data and size. */ always clear data and size. */
static int iso_ioctl(void * hnd, void *data, size_t size) { static int iso_ioctl(void *, int, va_list) {
iso_bridge_reset(); iso_bridge_reset();
return 0; return 0;
...@@ -911,10 +910,6 @@ int fs_isobridge_init() { ...@@ -911,10 +910,6 @@ int fs_isobridge_init() {
/* Mark the first as active so we can have an error FD of zero */ /* Mark the first as active so we can have an error FD of zero */
fh[0].first_extent = -1; fh[0].first_extent = -1;
/* Init thread mutexes */
cache_mutex = mutex_create();
fh_mutex = mutex_create();
/* Allocate cache block space */ /* Allocate cache block space */
for (i=0; i<NUM_CACHE_BLOCKS; i++) { for (i=0; i<NUM_CACHE_BLOCKS; i++) {
icache[i] = malloc(sizeof(cache_block_t)); icache[i] = malloc(sizeof(cache_block_t));
...@@ -929,7 +924,7 @@ int fs_isobridge_init() { ...@@ -929,7 +924,7 @@ int fs_isobridge_init() {
iso_last_status = -1; iso_last_status = -1;
/* Register with the vblank */ /* Register with the vblank */
iso_vblank_hnd = vblank_handler_add(iso_vblank); iso_vblank_hnd = vblank_handler_add(iso_vblank, NULL);
/* Register with VFS */ /* Register with VFS */
return nmmgr_handler_add(&vh.nmmgr); return nmmgr_handler_add(&vh.nmmgr);
...@@ -950,12 +945,5 @@ int fs_isobridge_shutdown() { ...@@ -950,12 +945,5 @@ int fs_isobridge_shutdown() {
free(dcache[i]->data); free(dcache[i]->data);
} }
/* Free muteces */
if (cache_mutex != NULL)
mutex_destroy(cache_mutex);
if (fh_mutex != NULL)
mutex_destroy(fh_mutex);
cache_mutex = fh_mutex = NULL;
return nmmgr_handler_remove(&vh.nmmgr); return nmmgr_handler_remove(&vh.nmmgr);
} }
...@@ -924,7 +924,6 @@ static void read_mode_vcd() ...@@ -924,7 +924,6 @@ static void read_mode_vcd()
#endif #endif
static int vcd_is_open = 0; static int vcd_is_open = 0;
void close_vcd();
/* /*
int open_vcd(): int open_vcd():
Here, we allocate memory for the in-memory copies of certain vcd files, read those files into the buffers, Here, we allocate memory for the in-memory copies of certain vcd files, read those files into the buffers,
......
...@@ -46,7 +46,6 @@ static struct vidclock_s{ ...@@ -46,7 +46,6 @@ static struct vidclock_s{
double ptime_inc; /* Useful for supporting ptime in VCD PlayLists as well as a/v synch. */ double ptime_inc; /* Useful for supporting ptime in VCD PlayLists as well as a/v synch. */
double ptime_total; /* How many ptime units have passed since starting playback. */ double ptime_total; /* How many ptime units have passed since starting playback. */
mutex_t * display_mut;
int incoming_reset, decoded_reset; /* Set these to 1 if we just started/skipped/whatever. */ int incoming_reset, decoded_reset; /* Set these to 1 if we just started/skipped/whatever. */
int skipped; /* Useful if debugging--throw some code in somewhere to see how many frames you're skipping. */ int skipped; /* Useful if debugging--throw some code in somewhere to see how many frames you're skipping. */
...@@ -65,6 +64,8 @@ static struct vidclock_s{ ...@@ -65,6 +64,8 @@ static struct vidclock_s{
int max_behind; int max_behind;
} vidclock; } vidclock;
static mutex_t vidclock_mut = MUTEX_INITIALIZER;
void vidclock_init(unsigned int frame_period) void vidclock_init(unsigned int frame_period)
{ {
vidclock.frame_counter = vidclock.last_count = 0; vidclock.frame_counter = vidclock.last_count = 0;
...@@ -79,9 +80,6 @@ void vidclock_init(unsigned int frame_period) ...@@ -79,9 +80,6 @@ void vidclock_init(unsigned int frame_period)
vidclock.ptime_total = 0.0f; vidclock.ptime_total = 0.0f;
vidclock.ptime_inc = (1.0f/vidclock.fps); vidclock.ptime_inc = (1.0f/vidclock.fps);
if (vidclock.display_mut == NULL)
mutex_create(vidclock.display_mut);
vidclock.incoming_reset = vidclock.decoded_reset = 1; vidclock.incoming_reset = vidclock.decoded_reset = 1;
vidclock.audio_rate = 0; /* If we just started, we have no clue what this is. */ vidclock.audio_rate = 0; /* If we just started, we have no clue what this is. */
vidclock.sample_counter = 0; vidclock.sample_counter = 0;
...@@ -275,14 +273,14 @@ void vidclock_skip_frame() ...@@ -275,14 +273,14 @@ void vidclock_skip_frame()
vidclock.start_time = timer_ms_gettime64(); vidclock.start_time = timer_ms_gettime64();
vidclock.decoded_reset = 0; vidclock.decoded_reset = 0;
} }
mutex_lock(vidclock.display_mut); mutex_lock(&vidclock_mut);
vidclock.frame_counter++; vidclock.frame_counter++;
vidclock.ptime_total += vidclock.ptime_inc; vidclock.ptime_total += vidclock.ptime_inc;
vidclock.last_frame_time = timer_ms_gettime64(); vidclock.last_frame_time = timer_ms_gettime64();
if (vidclock.decoded_reset==1) if (vidclock.decoded_reset==1)
vidclock.start_time = timer_ms_gettime64(); vidclock.start_time = timer_ms_gettime64();
mutex_unlock(vidclock.display_mut); mutex_unlock(&vidclock_mut);
} }
/* We should be able to help out our audio synch code here by grabbing the number of samples played at /* We should be able to help out our audio synch code here by grabbing the number of samples played at
display time and store that somewhere. */ display time and store that somewhere. */
...@@ -294,12 +292,12 @@ void vidclock_handle_frame () ...@@ -294,12 +292,12 @@ void vidclock_handle_frame ()
vidclock.start_time = timer_ms_gettime64(); vidclock.start_time = timer_ms_gettime64();
vidclock.decoded_reset = 0; vidclock.decoded_reset = 0;
} }
mutex_lock(vidclock.display_mut); mutex_lock(&vidclock_mut);
vidclock.ptime_total += vidclock.ptime_inc; vidclock.ptime_total += vidclock.ptime_inc;
vidclock.frame_counter++; vidclock.frame_counter++;
vc_wait: vc_wait:
now = timer_ms_gettime64(); now = timer_ms_gettime64();
if ( (now - vidclock.start_time)/1000.0f < vidclock.frame_counter * vidclock.ptime_inc) if ( (now - vidclock.start_time)/1000.0f < vidclock.frame_counter * vidclock.ptime_inc)
{ {
...@@ -307,7 +305,7 @@ void vidclock_handle_frame () ...@@ -307,7 +305,7 @@ void vidclock_handle_frame ()
goto vc_wait; goto vc_wait;
} }
vidclock.cur_fps = vidclock.frame_counter / ((now - vidclock.start_time) / 1000.0f); vidclock.cur_fps = vidclock.frame_counter / ((now - vidclock.start_time) / 1000.0f);
mutex_unlock(vidclock.display_mut); mutex_unlock(&vidclock_mut);
#ifdef DEBUGFPS #ifdef DEBUGFPS
take_notes("simulated framerate display", "Simulated framerate: %.2f /Should be:%.2f", vidclock.cur_fps, vidclock.fps); take_notes("simulated framerate display", "Simulated framerate: %.2f /Should be:%.2f", vidclock.cur_fps, vidclock.fps);
#endif #endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment