Commit 2ef76cd7 authored by Donald Haase's avatar Donald Haase
Browse files

Fix up more mutexes to use the modern standard

parent 363d8c19
......@@ -80,7 +80,7 @@ struct mp3_audio_out mp3_out;
static int sample_rate;
static int chans;
static mutex_t * audio_mut = NULL;
static mutex_t audio_mut = MUTEX_INITIALIZER;
#define BUFFER_MAX_FILL 65536*4
static char tmpbuf[BUFFER_MAX_FILL]; /* Temporary storage space for PCM data--65534 16-bit
......@@ -154,7 +154,7 @@ static void *mpv_callback(snd_stream_hnd_t hnd, int len, int * actual)
{
int wegots;
mutex_lock(audio_mut);
mutex_lock(&audio_mut);
if (len >= sndptr)
{
......@@ -172,7 +172,7 @@ static void *mpv_callback(snd_stream_hnd_t hnd, int len, int * actual)
start of a video. We could say *actual = 1; or something?
That might eliminate the lag at the beginning of a video? */
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
return NULL;
} else {
snd_ct = wegots;
......@@ -186,7 +186,7 @@ static void *mpv_callback(snd_stream_hnd_t hnd, int len, int * actual)
memcpy(tmpbuf, tmpbuf+snd_ct, sndptr);
last_read = 0; snd_ct = 0;
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
return sndbuf;
}
......@@ -242,12 +242,7 @@ static void *oss_open(char *filename, int freq, int channels, int format, int en
{
fudge_factor = 1.0;
}
if (audio_mut == NULL)
{
audio_mut = mutex_create();
}
memset (tmpbuf, 0, BUFFER_MAX_FILL);
memset (sndbuf, 0, BUFFER_MAX_FILL);
sample_rate = freq;
......@@ -262,7 +257,7 @@ static void *oss_open(char *filename, int freq, int channels, int format, int en
snd_stream_init();
shnd = snd_stream_alloc(mpv_callback, sbsize);
snd_stream_prefill(shnd);
snd_stream_prefill(shnd);
return oss_out;
}
......@@ -275,7 +270,7 @@ static int oss_write(void *handle, char *buffer, int len)
left from the old output system. */
retry:
mutex_lock(audio_mut);
mutex_lock(&audio_mut);
if (sndptr+len > BUFFER_MAX_FILL)
{
/* write what we can before bailing out. */
......@@ -287,7 +282,7 @@ retry:
sndptr+=new_len;
len -= new_len;
} */
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
if(!aud_set)
start_audio();
thd_pass();
......@@ -296,7 +291,7 @@ retry:
memcpy (tmpbuf+sndptr, buffer, len);
sndptr+= len;
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
if(!aud_set)
if (sndptr >= sbsize)
start_audio();
......
......@@ -77,7 +77,7 @@
static int sample_rate;
static int chans;
static mutex_t * audio_mut = NULL;
static mutex_t audio_mut = MUTEX_INITIALIZER;
#define BUFFER_MAX_FILL 65536*4
static char tmpbuf[BUFFER_MAX_FILL]; /* Temporary storage space for PCM data--65534 16-bit
......@@ -153,7 +153,7 @@ static void *mpv_callback(snd_stream_hnd_t hnd, int len, int * actual)
{
int wegots;
//mutex_lock(audio_mut);
//mutex_lock(&audio_mut);
if (len >= sndptr)
{
......@@ -171,7 +171,7 @@ static void *mpv_callback(snd_stream_hnd_t hnd, int len, int * actual)
start of a video. We could say *actual = 1; or something?
That might eliminate the lag at the beginning of a video? */
//mutex_unlock(audio_mut);
//mutex_unlock(&audio_mut);
return NULL;
} else {
snd_ct = wegots;
......@@ -185,7 +185,7 @@ static void *mpv_callback(snd_stream_hnd_t hnd, int len, int * actual)
memcpy(tmpbuf, tmpbuf+snd_ct, sndptr);
last_read = 0; snd_ct = 0;
//mutex_unlock(audio_mut);
//mutex_unlock(&audio_mut);
return sndbuf;
}
......@@ -200,7 +200,7 @@ static void* play_loop(void* yarr)
while (aud_set == 1)
{
mutex_lock(audio_mut);
mutex_lock(&audio_mut);
if (sndptr >= sbsize)
//if (sndptr >= sb_min)
{
......@@ -211,7 +211,7 @@ static void* play_loop(void* yarr)
if (aud_set == 0)
{
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
return NULL;
}
}
......@@ -219,9 +219,9 @@ static void* play_loop(void* yarr)
waiting_for_data = 1;
}else{
if(aud_set) /* Important to check this--if we haven't got here when we set aud_set to 0, we'll get here and be stuck! */
cond_wait(audio_cond, audio_mut);
cond_wait(audio_cond, &audio_mut);
}
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
} /* while (aud_set == 1) */
}
......@@ -246,11 +246,6 @@ static void *oss_open(char *filename, int freq, int channels, int format, int en
fudge_factor = 1.0;
}
if (audio_mut == NULL)
{
audio_mut = mutex_create();
}
memset (tmpbuf, 0, BUFFER_MAX_FILL);
memset (sndbuf, 0, BUFFER_MAX_FILL);
sample_rate = freq;
......@@ -275,20 +270,20 @@ static int oss_write(void *handle, char *buffer, int len)
{
if (len== -1){
mutex_lock(audio_mut);
mutex_lock(&audio_mut);
if (loop_thread->state == STATE_WAIT)
{
cond_broadcast(audio_cond);
thd_schedule_next(loop_thread);
}
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
if(!aud_set)
start_audio();
return 0;
} /*If this stuff works, try to get it to only call this function once per demuxed audio packet?. */
retry:
mutex_lock(audio_mut);
mutex_lock(&audio_mut);
if (sndptr+len > BUFFER_MAX_FILL)
{
/* write what we can before bailing out. */
......@@ -305,7 +300,7 @@ retry:
cond_broadcast(audio_cond);
thd_schedule_next(loop_thread);
}
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
if(!aud_set)
start_audio();
//thd_pass();
......@@ -324,7 +319,7 @@ retry:
}
if(!aud_set) start_audio();
}
mutex_unlock(audio_mut);
mutex_unlock(&audio_mut);
/* if(!aud_set)
if (sndptr >= sbsize)
start_audio(); */
......
......@@ -23,7 +23,7 @@ typedef struct {
} lst_entry;
///////// Mutex protected /////////
static mutex_t * mut = NULL;
static mutex_t mut = MUTEX_INITIALIZER;
char curdir[1024] = "/cd";
char playdir[1024] = "/cd";
......@@ -47,7 +47,6 @@ static int lst_playing = -1;
/* Code to draw a nice o-scope on the background during playback :) */
static mutex_t * hookmut = NULL;
static void load_song_list(/*void * p*/) {
file_t d;
......@@ -57,11 +56,11 @@ static void load_song_list(/*void * p*/) {
strcpy(curdir, "/");
d = fs_open(curdir, O_RDONLY | O_DIR);
if (!d) {
mutex_lock(mut);
mutex_lock(&mut);
num_entries = 1;
strcpy(entries[0].fn,"Error!");
entries[0].size = 0;
mutex_unlock(mut);
mutex_unlock(&mut);
return;
}
}
......@@ -69,17 +68,17 @@ static void load_song_list(/*void * p*/) {
dirent_t *de;
num_entries = 0;
if (strcmp(curdir, "/")) {
mutex_lock(mut);
mutex_lock(&mut);
strcpy(entries[0].fn, "<..>"); entries[0].size = -1;
num_entries++;
mutex_unlock(mut);
mutex_unlock(&mut);
}
while ( (de = fs_readdir(d)) && num_entries < 200) {
char *ext;
ext = (char *)(strchr(de->name, '.')+1);
printf("read entry '%s'\n", de->name);
if (de->name[0] != '.') {
mutex_lock(mut);
mutex_lock(&mut);
/*if( (!stricmp(ext,"mpg"))||(!stricmp(ext,"mpeg"))||(!stricmp(ext,"pss"))
||(!stricmp(ext,"sfd"))||(!stricmp(ext,"m2v"))||(!stricmp(ext,"m1v"))
||(!stricmp(ext,"mp1"))||(!stricmp(ext,"mp2"))||(!stricmp(ext,"mp3")) )
......@@ -88,7 +87,7 @@ static void load_song_list(/*void * p*/) {
entries[num_entries].size = de->size;
num_entries++;
/*}*/
mutex_unlock(mut);
mutex_unlock(&mut);
}
}
}
......@@ -410,7 +409,7 @@ static void settings_menu()
draw_poly_box(60.0f, 110.0f+menu_item*24.0f - 1.0f,
580.0f, 110.0f+menu_item*24.0f + 25.0f, 95.0f,
throb, 0.2f, 0.2f, throb, throb, 0.2f, 0.2f, throb);
throb, 0.2f, 0.2f, throb, throb, 0.2f, 0.2f, throb);
pvr_list_finish();
pvr_scene_finish();
......@@ -600,9 +599,9 @@ void check_controller() {
strcat(curdir, "/");
strcat(curdir, entries[selected].fn);
}
mutex_lock(mut);
mutex_lock(&mut);
selected = top = num_entries = 0;
mutex_unlock(mut);
mutex_unlock(&mut);
printf("current directory is now '%s'\n", curdir);
}
pvr_wait_ready();
......@@ -633,10 +632,6 @@ void check_inputs() {
/* Main rendering of the song menu */
void song_menu_render() {
if (mut == NULL) {
mut = mutex_create();
hookmut = mutex_create();
}
/* Draw a background box */
/*draw_poly_box(30.0f, 80.0f, 610.0f, 440.0f-96.0f, 90.0f,
......@@ -656,9 +651,9 @@ void song_menu_render() {
"Scanning Directory..."); */
/* Draw the song listing */
mutex_lock(mut);
mutex_lock(&mut);
draw_listing();
mutex_unlock(mut);
mutex_unlock(&mut);
/* Adjust the throbber */
throb += dthrob;
......
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