Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dreamcast
vcdc
Commits
f34fa60d
Commit
f34fa60d
authored
May 26, 2024
by
Donald Haase
Browse files
First pass of upporting, compiles but doesn't link.
parent
997c32ef
Changes
11
Hide whitespace changes
Inline
Side-by-side
include/libvcd.h
View file @
f34fa60d
...
...
@@ -85,11 +85,6 @@
/* Maximum index of optional LOT.VCD (the List ID Offset Table.) */
#define LOT_VCD_OFFSETS ((1 << 15)-1)
typedef
enum
{
false
,
true
}
bool
;
/* I actually have to declare this? Ugh... */
#if defined(__GNUC__)
/* this is strict ISO C99 which allows only 'unsigned int', 'signed
int' and '_Bool' explicitly as bit-field type */
...
...
@@ -613,7 +608,9 @@ typedef struct _EntriesVcd_simple {
PRAGMA_END_PACKED
int
open_vcd
();
int
open_vcd
(
void
);
void
close_vcd
(
void
);
int
play_vcd_image
(
const
char
*
fn
);
void
Start_Pbc
();
#endif
libvo/video_out_dc.c
View file @
f34fa60d
...
...
@@ -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,
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
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
(c)2001 Andrew Kieschnick */
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
;
uint32
count
;
unsigned
int
*
d
,
*
s
;
...
...
@@ -197,7 +206,7 @@ unsigned int *d, *s;
/* Wait for both store queues to complete */
d
=
(
unsigned
int
*
)
0xe0000000
;
d
[
0
]
=
d
[
8
]
=
0
;
#endif
}
extern
void
vidclock_handle_frame
();
...
...
@@ -205,7 +214,7 @@ extern void vidclock_handle_frame();
static
void
draw_texture
(
int
which
)
{
/* Display the picture--ripped from the kos png example. */
//mutex_lock(video_mut);
//mutex_lock(
&
video_mut);
pvr_vertex_t
vert
;
// vidclock_handle_frame();
...
...
@@ -300,29 +309,30 @@ pvr_vertex_t vert;
pvr_scene_finish
();
/* tx_cur = 1-tx_cur; */
// mutex_unlock(video_mut);
// mutex_unlock(
&
video_mut);
}
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. */
{
while
(
vid_set
==
1
)
{
if
(
got_new_video
>
0
)
{
mutex_lock
(
video_mut
);
if
(
redraw_flag
)
goto
no_handle_frame
;
vidclock_handle_frame
();
no_handle_frame:
redraw_flag
=
0
;
draw_texture
(
got_new_video
-
1
);
/* Draw our texture. */
got_new_video
=
0
;
mutex_unlock
(
video_mut
);
}
thd_pass
();
/* We're done here for a bit. */
}
while
(
vid_set
==
1
)
{
if
(
got_new_video
>
0
)
{
mutex_lock
(
&
video_mut
);
if
(
redraw_flag
)
goto
no_handle_frame
;
vidclock_handle_frame
();
no_handle_frame:
redraw_flag
=
0
;
draw_texture
(
got_new_video
-
1
);
/* Draw our texture. */
got_new_video
=
0
;
mutex_unlock
(
&
video_mut
);
}
thd_pass
();
/* We're done here for a bit. */
}
return
NULL
;
}
/* IMPORTANT! DON'T FORGET TO PUT CHECKS IN HERE!
...
...
@@ -340,8 +350,7 @@ void redraw_frame() /* This is really a hack, but oh well. */
{
vid_set = 1;
got_new_video = 0;
if (video_mut == NULL) mutex_create(video_mut); /* Create our mutex if it doesn't exist. */
txr_thd = thd_create(video_loop, NULL); /* Start our display thread. */
txr_thd = thd_create(0, video_loop, NULL); /* Start our display thread. */
}
#else
if
(
!
vid_set
)
...
...
@@ -357,14 +366,14 @@ 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. */
vo_txr_load
(
last_buf
);
redraw_flag
=
1
;
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.*/
tx_cur
=
1
-
tx_cur
;
}
...
...
@@ -377,22 +386,21 @@ static void dc_draw_frame (vo_instance_t * instance,
{
vid_set
=
1
;
got_new_video
=
0
;
if
(
video_mut
==
NULL
)
mutex_create
(
video_mut
);
/* Create our mutex if it doesn't exist. */
txr_thd
=
thd_create
(
video_loop
,
NULL
);
/* Start our display thread. */
txr_thd
=
thd_create
(
0
,
video_loop
,
NULL
);
/* Start our display thread. */
}
retry:
if
(
got_new_video
>
0
)
{
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. */
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. */
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.*/
tx_cur
=
1
-
tx_cur
;
}
...
...
@@ -402,7 +410,7 @@ static void dc_close (vo_instance_t * _instance)
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
)
{
...
...
@@ -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. */
{
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! */
}
...
...
@@ -489,8 +497,7 @@ static int dc_setup (vo_instance_t * instance, unsigned int width,
got_new_video
=
0
;
}
if
(
video_mut
==
NULL
)
mutex_create
(
video_mut
);
/* Create our mutex if it doesn't exist. */
txr_thd
=
thd_create
(
video_loop
,
NULL
);
/* Start our display thread. */
txr_thd
=
thd_create
(
0
,
video_loop
,
NULL
);
/* Start our display thread. */
return
0
;
}
...
...
mpglib/output.c
View file @
f34fa60d
...
...
@@ -191,7 +191,7 @@ static kthread_t * loop_thread;
/* This loops as long as the audio driver is open.
Do we want to poll more frequently? */
static
void
play_loop
(
void
*
yarr
)
static
void
*
play_loop
(
void
*
yarr
)
{
while
(
aud_set
==
1
)
...
...
@@ -207,7 +207,7 @@ static void play_loop(void* yarr)
thd_pass
();
if
(
aud_set
==
0
)
{
return
;
return
NULL
;
}
}
...
...
@@ -225,7 +225,7 @@ static void start_audio()
aud_set
=
1
;
//snd_stream_prefill(shnd);
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!" */
...
...
@@ -311,7 +311,7 @@ static int oss_close(void *handle)
free
(
oss_out
);
}
aud_set
=
sndptr
=
0
;
thd_
wait
(
loop_thread
);
thd_
join
(
loop_thread
,
NULL
);
fudge_factor
=
0
.
0
;
snd_stream_stop
(
shnd
);
snd_stream_destroy
(
shnd
);
...
...
mpglib/output_wip.c
View file @
f34fa60d
...
...
@@ -194,7 +194,7 @@ static kthread_t * loop_thread;
condvar_t
*
audio_cond
=
NULL
;
/* This loops as long as the audio driver is open.
Do we want to poll more frequently? */
static
void
play_loop
(
void
*
yarr
)
static
void
*
play_loop
(
void
*
yarr
)
{
while
(
aud_set
==
1
)
...
...
@@ -212,7 +212,7 @@ static void play_loop(void* yarr)
if
(
aud_set
==
0
)
{
mutex_unlock
(
audio_mut
);
return
;
return
NULL
;
}
}
...
...
@@ -231,7 +231,7 @@ static void start_audio()
aud_set
=
1
;
//snd_stream_prefill(shnd);
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!" */
...
...
src/Makefile
View file @
f34fa60d
...
...
@@ -60,7 +60,7 @@ OBJS=ghettoplay.o mpeg2play.o mp3junk.o \
-I.
-DNOANALYSIS
-DHAVE_CONFIG_H
-DDEBUGFPS
-ffast-math
#Use these flags for a release build.
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
:
-
rm
-f
plaympeg.elf
$(OBJS)
...
...
src/mpeg2play.c
View file @
f34fa60d
...
...
@@ -1453,7 +1453,7 @@ char *ext;
// mpeg2_malloc_hooks (malloc_hook, NULL);
mpeg_audio_activated
=
0
;
if
(
!
str
i
cmp
(
ext
,
"mp1"
)
||
(
!
str
i
cmp
(
ext
,
"mp2"
))
||
(
!
str
i
cmp
(
ext
,
"mp3"
)))
if
(
!
str
case
cmp
(
ext
,
"mp1"
)
||
(
!
str
case
cmp
(
ext
,
"mp2"
))
||
(
!
str
case
cmp
(
ext
,
"mp3"
)))
{
mp3_loop
(
file_to_play
);
...
...
@@ -1461,10 +1461,10 @@ char *ext;
in_file
=
fs_open
(
file_to_play
,
O_RDONLY
);
bkg_clear
();
/* The menu is using PVR memory that we need. */
if
(
!
str
i
cmp
(
ext
,
"mpg"
)
||
(
!
str
i
cmp
(
ext
,
"mpeg"
))
||
(
!
str
i
cmp
(
ext
,
"pss"
))
||
(
!
str
i
cmp
(
ext
,
"sfd"
))
||
(
!
str
i
cmp
(
ext
,
"dat"
)))
if
(
!
str
case
cmp
(
ext
,
"mpg"
)
||
(
!
str
case
cmp
(
ext
,
"mpeg"
))
||
(
!
str
case
cmp
(
ext
,
"pss"
))
||
(
!
str
case
cmp
(
ext
,
"sfd"
))
||
(
!
str
case
cmp
(
ext
,
"dat"
)))
ps_loop
();
if
(
!
str
i
cmp
(
ext
,
"m2v"
)
||
(
!
str
i
cmp
(
ext
,
"m1v"
)))
if
(
!
str
case
cmp
(
ext
,
"m2v"
)
||
(
!
str
case
cmp
(
ext
,
"m1v"
)))
es_loop
();
...
...
src/songmenu.c
View file @
f34fa60d
...
...
@@ -2,6 +2,7 @@
(c)2000 Dan Potter
*/
#include
<kos.h>
#include
<string.h>
#include
"gp.h"
#include
"mpegav.h"
...
...
@@ -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
};
static
uint8
mcont
=
0
;
static
cont_cond_t
cond
;
if
(
!
mcont
)
{
mcont
=
maple_first_controller
();
if
(
!
mcont
)
{
return
;
}
}
for
(
i
=
0
;
i
<
32
;
i
++
)
band_value
[
i
]
=
get_eq_band
(
i
);
a_pressed
=
framecnt
;
static
maple_device_t
*
mcont
=
NULL
;
static
cont_state_t
*
state
=
NULL
;
if
(
!
mcont
)
mcont
=
maple_enum_type
(
0
,
MAPLE_FUNC_CONTROLLER
);
for
(
i
=
0
;
i
<
32
;
i
++
)
band_value
[
i
]
=
get_eq_band
(
i
);
a_pressed
=
framecnt
;
while
(
in_menu
==
1
)
{
if
(
cont_get_cond
(
mcont
,
&
cond
))
{
return
;
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_UP
))
state
=
(
cont_state_t
*
)
maple_dev_status
(
mcont
);
if
(
!
state
)
return
;
if
(
!
(
state
->
buttons
&
CONT_DPAD_UP
))
{
if
((
framecnt
-
up_moved
)
>
3
)
{
...
...
@@ -209,7 +211,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
up_moved
=
framecnt
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_DOWN
))
if
(
!
(
state
->
buttons
&
CONT_DPAD_DOWN
))
{
if
((
framecnt
-
down_moved
)
>
3
)
{
...
...
@@ -219,7 +221,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
down_moved
=
framecnt
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_LEFT
))
if
(
!
(
state
->
buttons
&
CONT_DPAD_LEFT
))
{
if
((
framecnt
-
left_moved
)
>
10
)
{
...
...
@@ -227,7 +229,7 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
left_moved
=
framecnt
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_RIGHT
))
if
(
!
(
state
->
buttons
&
CONT_DPAD_RIGHT
))
{
if
((
framecnt
-
right_moved
)
>
10
)
{
...
...
@@ -235,14 +237,14 @@ static void set_eq_menu() /* Set our 32-band graphic equalizer */
right_moved
=
framecnt
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_A
))
if
(
!
(
state
->
buttons
&
CONT_A
))
{
if
((
framecnt
-
a_pressed
)
>
10
)
{
in_menu
=
0
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_X
))
if
(
!
(
state
->
buttons
&
CONT_X
))
{
for
(
i
=
0
;
i
<
32
;
i
++
)
{
...
...
@@ -304,7 +306,6 @@ static void settings_menu()
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
;
static
int
last_selection
[
TOTAL_MENU_ITEMS
];
static
cont_cond_t
cond
;
static
uint8
mcont
=
0
;
char
*
optionlist
[
TOTAL_MENU_ITEMS
][
3
]
=
{
{
"Best audio (default)"
,
"Okay audio"
,
"Worst audio"
},
/* Audio Quality */
...
...
@@ -312,20 +313,21 @@ static void settings_menu()
{
"Off"
,
"On"
,
"Set"
},
/* EQ on/off */
{
"On(Default)"
,
"Off"
,
" "
}
/* PBC on/off */
};
if
(
!
mcont
)
{
mcont
=
maple_first_controller
()
;
if
(
!
mcont
)
{
return
;
}
}
static
maple_device_t
*
mcont
=
NULL
;
static
cont_state_t
*
state
=
NULL
;
if
(
!
mcont
)
mcont
=
maple_enum_type
(
0
,
MAPLE_FUNC_CONTROLLER
);
in_menu
=
1
;
a_pressed
=
framecnt
;
while
(
in_menu
==
1
)
{
if
(
cont_get_cond
(
mcont
,
&
cond
))
{
return
;
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_UP
))
{
state
=
(
cont_state_t
*
)
maple_dev_status
(
mcont
);
if
(
!
state
)
return
;
if
(
!
(
state
->
buttons
&
CONT_DPAD_UP
))
{
if
((
framecnt
-
up_moved
)
>
10
)
{
if
(
menu_item
>
0
)
{
last_selection
[
menu_item
]
=
selection
;
...
...
@@ -335,7 +337,7 @@ static void settings_menu()
up_moved
=
framecnt
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_DOWN
))
{
if
(
!
(
state
->
buttons
&
CONT_DPAD_DOWN
))
{
if
((
framecnt
-
down_moved
)
>
10
)
{
if
(
menu_item
<
TOTAL_MENU_ITEMS
-
1
)
{
last_selection
[
menu_item
]
=
selection
;
...
...
@@ -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
(
selection
>=
0
)
{
selection
--
;
...
...
@@ -361,7 +363,7 @@ static void settings_menu()
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
(
selection
<=
2
)
{
selection
++
;
...
...
@@ -376,7 +378,7 @@ static void settings_menu()
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
)
{
in_menu
=
0
;
...
...
@@ -426,15 +428,15 @@ static void settings_menu()
}
void
check_controller
()
{
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
;
if
(
!
mcont
)
{
mcont
=
maple_first_controller
(
);
if
(
!
mcont
)
{
return
;
}
}
if
(
cont_get_cond
(
mcont
,
&
cond
))
{
return
;
}
static
maple_device_t
*
mcont
=
NULL
;
static
cont_state_t
*
state
=
NULL
;
if
(
!
mcont
)
mcont
=
maple_enum_type
(
0
,
MAPLE_FUNC_CONTROLLER
);
state
=
(
cont_state_t
*
)
maple_dev_status
(
mcont
);
if
(
!
state
)
return
;
if
(
!
(
cond
.
buttons
&
CONT_DPAD_UP
))
{
if
(
!
(
state
->
buttons
&
CONT_DPAD_UP
))
{
if
((
framecnt
-
up_moved
)
>
10
)
{
if
(
selected
>
0
)
{
selected
--
;
...
...
@@ -445,7 +447,7 @@ void check_controller() {
up_moved
=
framecnt
;
}
}
if
(
!
(
cond
.
buttons
&
CONT_DPAD_DOWN
))
{
if
(
!
(
state
->
buttons
&
CONT_DPAD_DOWN
))
{
if
((
framecnt
-
down_moved
)
>
10
)
{
if
(
selected
<
(
num_entries
-
1
))
{
selected
++
;
...
...
@@ -457,7 +459,7 @@ void check_controller() {
down_moved
=
framecnt
;
}
}
if
(
cond
.
ltrig
>
0
)
{
if
(
state
->
ltrig
>
0
)
{
if
((
framecnt
-
up_moved
)
>
10
)
{
// selected -= 14;
selected
-=
10
;
...
...
@@ -467,7 +469,7 @@ void check_controller() {
up_moved
=
framecnt
;
}
}
if
(
cond
.
rtrig
>
0
)
{
if
(
state
->
rtrig
>
0
)
{
if
((
framecnt
-
down_moved
)
>
10
)
{
// selected += 14;
selected
+=
10
;
...
...
@@ -480,7 +482,7 @@ void check_controller() {
}
}
if
(
!
(
cond
.
buttons
&
CONT_Y
))
{
if
(
!
(
state
->
buttons
&
CONT_Y
))
{
if
((
framecnt
-
y_pressed
)
>
10
)
{
strcat
(
workstring
,
curdir
);
...
...
@@ -499,7 +501,7 @@ void check_controller() {
y_pressed
=
framecnt
;
}
if
(
!
(
cond
.
buttons
&
CONT_X
)
)
{
if
(
!
(
state
->
buttons
&
CONT_X
)
)
{
if
((
framecnt
-
x_pressed
)
>
10
){
/* End of translucent list */
pvr_list_finish
();
...
...
@@ -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
)
{
/* End of translucent list */
...
...
@@ -562,7 +564,7 @@ void check_controller() {
strcat
(
loadme
,
entries
[
selected
].
fn
);
ext
=
(
char
*
)(
strchr
(
entries
[
selected
].
fn
,
'.'
)
+
1
);
if
(
!
str
i
cmp
(
ext
,
"bin"
))
if
(
!
str
case
cmp
(
ext
,
"bin"
))
{
vmu_set_icon
(
vcdcontrols_xpm
);
play_vcd_image
(
loadme
);
...
...
@@ -645,7 +647,7 @@ void song_menu_render() {
/* If we don't have a file listing, get it now */
if
(
num_entries
==
0
&&
!
load_queued
)
{
load_queued
=
1
;
//thd_create(load_song_list, NULL);
//thd_create(
0,
load_song_list, NULL);
load_song_list
();
}
...
...
vcdlib/fs_bincue.c
View file @
f34fa60d
...
...
@@ -44,8 +44,6 @@ ISO9660 systems, as these were used as references as well.
#include
"vcd_iso.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
static
int
init_percd
();
...
...
@@ -232,16 +230,16 @@ static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */
static
cache_block_t
*
dcache
[
NUM_CACHE_BLOCKS
];
/* data cache */
/* Cache modification mutex */
static
mutex_t
*
cache_mutex
;
static
mutex_t
cache_mutex
=
MUTEX_INITIALIZER
;
/* Clears all cache blocks */
static
void
bclear_cache
(
cache_block_t
**
cache
)
{
int
i
;
mutex_lock
(
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
for
(
i
=
0
;
i
<
NUM_CACHE_BLOCKS
;
i
++
)
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 */
...
...
@@ -267,7 +265,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
int
i
,
j
,
rv
;
rv
=
-
1
;
mutex_lock
(
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
/* Look for a pre-existing cache block */
for
(
i
=
NUM_CACHE_BLOCKS
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -305,7 +303,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
/* Return the new cache block index */
bread_exit:
mutex_unlock
(
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
return
rv
;
}
...
...
@@ -493,7 +491,7 @@ static iso_dirent_t *find_object(const char *fn, int dir,
else
fnlen
=
strlen
(
fn
);
if
(
!
strn
i
cmp
(
rrname
,
fn
,
fnlen
)
&&
!
*
(
rrname
+
fnlen
))
{
if
(
!
strn
case
cmp
(
rrname
,
fn
,
fnlen
)
&&
!
*
(
rrname
+
fnlen
))
{
if
(
!
((
dir
<<
1
)
^
de
->
flags
))
return
de
;
}
...
...
@@ -571,7 +569,7 @@ static struct {
}
fh
[
MAX_ISO_FILES
];
/* 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
is changed so that we don't accidentally try to keep on doing stuff
...
...
@@ -580,10 +578,10 @@ static mutex_t * fh_mutex;
static
void
iso_break_all
()
{
int
i
;
mutex_lock
(
fh_mutex
);
mutex_lock
(
&
fh_mutex
);
for
(
i
=
0
;
i
<
MAX_ISO_FILES
;
i
++
)
fh
[
i
].
broken
=
1
;
mutex_unlock
(
fh_mutex
);
mutex_unlock
(
&
fh_mutex
);
}
/* Open a file or directory */
...
...
@@ -605,13 +603,13 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
if
(
!
de
)
return
0
;
/* Find a free file handle */
mutex_lock
(
fh_mutex
);
mutex_lock
(
&
fh_mutex
);
for
(
fd
=
0
;
fd
<
MAX_ISO_FILES
;
fd
++
)
if
(
fh
[
fd
].
first_extent
==
0
)
{
fh
[
fd
].
first_extent
=
-
1
;
break
;
}
mutex_unlock
(
fh_mutex
);
mutex_unlock
(
&
fh_mutex
);
if
(
fd
>=
MAX_ISO_FILES
)
return
0
;
...
...
@@ -627,7 +625,7 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
}
/* Close a file or directory */
static
void
iso_close
(
void
*
h
)
{
static
int
iso_close
(
void
*
h
)
{
file_t
fd
=
(
file_t
)
h
;
/* Check that the fd is valid */
...
...
@@ -635,6 +633,8 @@ static void iso_close(void * h) {
/* No need to lock the mutex: this is an atomic op */
fh
[
fd
].
first_extent
=
0
;
}
return
0
;
}
/* Read from a file */
...
...
@@ -851,7 +851,7 @@ int bincue_reset() {
time someone calls in it'll get reset. */
static
int
iso_last_status
;
static
int
iso_vblank_hnd
;
static
void
iso_vblank
(
uint32
evt
)
{
static
void
iso_vblank
(
uint32
evt
,
void
*
)
{
int
status
,
disc_type
;
/* Get the status. This may fail if a CD operation is in
...
...
@@ -868,7 +868,7 @@ static void iso_vblank(uint32 evt) {
/* There's only one ioctl at the moment (re-initialize caches) but you should
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
();
return
0
;
...
...
@@ -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 */
fh
[
0
].
first_extent
=
-
1
;
/* Init thread mutexes */
cache_mutex
=
mutex_create
();
fh_mutex
=
mutex_create
();
/* Allocate cache block space */
for
(
i
=
0
;
i
<
NUM_CACHE_BLOCKS
;
i
++
)
{
icache
[
i
]
=
malloc
(
sizeof
(
cache_block_t
));
...
...
@@ -936,7 +932,7 @@ int fs_bincue_mount(const char *fn) {
iso_last_status
=
-
1
;
read_sectors
=
bincue_read_sectors
;
/* Register with the vblank */
iso_vblank_hnd
=
vblank_handler_add
(
iso_vblank
);
iso_vblank_hnd
=
vblank_handler_add
(
iso_vblank
,
NULL
);
/* Register with VFS */
return
nmmgr_handler_add
(
&
vh
.
nmmgr
);
...
...
@@ -959,13 +955,6 @@ int fs_bincue_unmount() {
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
;
mounted
=
0
;
return
nmmgr_handler_remove
(
&
vh
.
nmmgr
);
...
...
vcdlib/fs_isobridge.c
View file @
f34fa60d
...
...
@@ -43,8 +43,6 @@ ISO9660 systems, as these were used as references as well.
#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
static
int
init_percd
();
...
...
@@ -194,16 +192,16 @@ static cache_block_t *icache[NUM_CACHE_BLOCKS]; /* inode cache */
static
cache_block_t
*
dcache
[
NUM_CACHE_BLOCKS
];
/* data cache */
/* Cache modification mutex */
static
mutex_t
*
cache_mutex
;
static
mutex_t
cache_mutex
=
MUTEX_INITIALIZER
;
/* Clears all cache blocks */
static
void
bclear_cache
(
cache_block_t
**
cache
)
{
int
i
;
mutex_lock
(
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
for
(
i
=
0
;
i
<
NUM_CACHE_BLOCKS
;
i
++
)
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 */
...
...
@@ -229,7 +227,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
int
i
,
j
,
rv
;
rv
=
-
1
;
mutex_lock
(
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
/* Look for a pre-existing cache block */
for
(
i
=
NUM_CACHE_BLOCKS
-
1
;
i
>=
0
;
i
--
)
{
...
...
@@ -267,7 +265,7 @@ static int bread_cache(cache_block_t **cache, uint32 sector) {
/* Return the new cache block index */
bread_exit:
mutex_unlock
(
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
return
rv
;
}
...
...
@@ -492,7 +490,7 @@ static iso_dirent_t *find_object(const char *fn, int dir,
else
fnlen
=
strlen
(
fn
);
if
(
!
strn
i
cmp
(
rrname
,
fn
,
fnlen
)
&&
!
*
(
rrname
+
fnlen
))
{
if
(
!
strn
case
cmp
(
rrname
,
fn
,
fnlen
)
&&
!
*
(
rrname
+
fnlen
))
{
if
(
!
((
dir
<<
1
)
^
de
->
flags
))
return
de
;
}
...
...
@@ -570,7 +568,7 @@ static struct {
}
fh
[
MAX_ISO_FILES
];
/* 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
is changed so that we don't accidentally try to keep on doing stuff
...
...
@@ -579,10 +577,10 @@ static mutex_t * fh_mutex;
static
void
iso_break_all
()
{
int
i
;
mutex_lock
(
fh_mutex
);
mutex_lock
(
&
fh_mutex
);
for
(
i
=
0
;
i
<
MAX_ISO_FILES
;
i
++
)
fh
[
i
].
broken
=
1
;
mutex_unlock
(
fh_mutex
);
mutex_unlock
(
&
fh_mutex
);
}
/* Open a file or directory */
...
...
@@ -604,13 +602,13 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
if
(
!
de
)
return
0
;
/* Find a free file handle */
mutex_lock
(
fh_mutex
);
mutex_lock
(
&
fh_mutex
);
for
(
fd
=
0
;
fd
<
MAX_ISO_FILES
;
fd
++
)
if
(
fh
[
fd
].
first_extent
==
0
)
{
fh
[
fd
].
first_extent
=
-
1
;
break
;
}
mutex_unlock
(
fh_mutex
);
mutex_unlock
(
&
fh_mutex
);
if
(
fd
>=
MAX_ISO_FILES
)
return
0
;
...
...
@@ -626,14 +624,15 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
}
/* Close a file or directory */
static
void
iso_close
(
void
*
h
)
{
static
int
iso_close
(
void
*
h
)
{
file_t
fd
=
(
file_t
)
h
;
/* Check that the fd is valid */
if
(
fd
<
MAX_ISO_FILES
)
{
/* No need to lock the mutex: this is an atomic op */
fh
[
fd
].
first_extent
=
0
;
}
}
return
0
;
}
/* Read from a file */
...
...
@@ -850,7 +849,7 @@ int iso_bridge_reset() {
time someone calls in it'll get reset. */
static
int
iso_last_status
;
static
int
iso_vblank_hnd
;
static
void
iso_vblank
(
uint32
evt
)
{
static
void
iso_vblank
(
uint32
evt
,
void
*
)
{
int
status
,
disc_type
;
/* Get the status. This may fail if a CD operation is in
...
...
@@ -867,7 +866,7 @@ static void iso_vblank(uint32 evt) {
/* There's only one ioctl at the moment (re-initialize caches) but you should
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
();
return
0
;
...
...
@@ -911,10 +910,6 @@ int fs_isobridge_init() {
/* Mark the first as active so we can have an error FD of zero */
fh
[
0
].
first_extent
=
-
1
;
/* Init thread mutexes */
cache_mutex
=
mutex_create
();
fh_mutex
=
mutex_create
();
/* Allocate cache block space */
for
(
i
=
0
;
i
<
NUM_CACHE_BLOCKS
;
i
++
)
{
icache
[
i
]
=
malloc
(
sizeof
(
cache_block_t
));
...
...
@@ -929,7 +924,7 @@ int fs_isobridge_init() {
iso_last_status
=
-
1
;
/* Register with the vblank */
iso_vblank_hnd
=
vblank_handler_add
(
iso_vblank
);
iso_vblank_hnd
=
vblank_handler_add
(
iso_vblank
,
NULL
);
/* Register with VFS */
return
nmmgr_handler_add
(
&
vh
.
nmmgr
);
...
...
@@ -950,12 +945,5 @@ int fs_isobridge_shutdown() {
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
);
}
vcdlib/libvcd.c
View file @
f34fa60d
...
...
@@ -924,7 +924,6 @@ static void read_mode_vcd()
#endif
static
int
vcd_is_open
=
0
;
void
close_vcd
();
/*
int open_vcd():
Here, we allocate memory for the in-memory copies of certain vcd files, read those files into the buffers,
...
...
vidclock/vidclock.c
View file @
f34fa60d
...
...
@@ -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_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
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{
int
max_behind
;
}
vidclock
;
static
mutex_t
vidclock_mut
=
MUTEX_INITIALIZER
;
void
vidclock_init
(
unsigned
int
frame_period
)
{
vidclock
.
frame_counter
=
vidclock
.
last_count
=
0
;
...
...
@@ -79,9 +80,6 @@ void vidclock_init(unsigned int frame_period)
vidclock
.
ptime_total
=
0
.
0
f
;
vidclock
.
ptime_inc
=
(
1
.
0
f
/
vidclock
.
fps
);
if
(
vidclock
.
display_mut
==
NULL
)
mutex_create
(
vidclock
.
display_mut
);
vidclock
.
incoming_reset
=
vidclock
.
decoded_reset
=
1
;
vidclock
.
audio_rate
=
0
;
/* If we just started, we have no clue what this is. */
vidclock
.
sample_counter
=
0
;
...
...
@@ -275,14 +273,14 @@ void vidclock_skip_frame()
vidclock
.
start_time
=
timer_ms_gettime64
();
vidclock
.
decoded_reset
=
0
;
}
mutex_lock
(
vidclock
.
display
_mut
);
mutex_lock
(
&
vidclock_mut
);
vidclock
.
frame_counter
++
;
vidclock
.
ptime_total
+=
vidclock
.
ptime_inc
;
vidclock
.
last_frame_time
=
timer_ms_gettime64
();
if
(
vidclock
.
decoded_reset
==
1
)
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
display time and store that somewhere. */
...
...
@@ -294,12 +292,12 @@ void vidclock_handle_frame ()
vidclock
.
start_time
=
timer_ms_gettime64
();
vidclock
.
decoded_reset
=
0
;
}
mutex_lock
(
vidclock
.
display
_mut
);
mutex_lock
(
&
vidclock_mut
);
vidclock
.
ptime_total
+=
vidclock
.
ptime_inc
;
vidclock
.
frame_counter
++
;
vc_wait:
vc_wait:
now
=
timer_ms_gettime64
();
if
(
(
now
-
vidclock
.
start_time
)
/
1000
.
0
f
<
vidclock
.
frame_counter
*
vidclock
.
ptime_inc
)
{
...
...
@@ -307,7 +305,7 @@ void vidclock_handle_frame ()
goto
vc_wait
;
}
vidclock
.
cur_fps
=
vidclock
.
frame_counter
/
((
now
-
vidclock
.
start_time
)
/
1000
.
0
f
);
mutex_unlock
(
vidclock
.
display
_mut
);
mutex_unlock
(
&
vidclock_mut
);
#ifdef DEBUGFPS
take_notes
(
"simulated framerate display"
,
"Simulated framerate: %.2f /Should be:%.2f"
,
vidclock
.
cur_fps
,
vidclock
.
fps
);
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment