mirror of
https://github.com/dborth/snes9xgx.git
synced 2025-02-17 11:56:25 +01:00
fix long-standing menu "random" lockup/crashing bug. caused by Hermes' oggplayer threading. oggplayer rewritten.
This commit is contained in:
parent
96e0fda747
commit
4cd7c28bb4
@ -91,6 +91,11 @@ GCMixSamples ()
|
|||||||
void
|
void
|
||||||
InitAudio ()
|
InitAudio ()
|
||||||
{
|
{
|
||||||
|
#ifdef NO_SOUND
|
||||||
|
AUDIO_Init (NULL);
|
||||||
|
#else
|
||||||
|
ASND_Init();
|
||||||
|
#endif
|
||||||
LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 100);
|
LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,17 +111,16 @@ SwitchAudioMode(int mode)
|
|||||||
{
|
{
|
||||||
#ifndef NO_SOUND
|
#ifndef NO_SOUND
|
||||||
ASND_Pause(1);
|
ASND_Pause(1);
|
||||||
ASND_End();
|
|
||||||
#endif
|
#endif
|
||||||
|
AUDIO_StopDMA();
|
||||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_32KHZ);
|
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_32KHZ);
|
||||||
AUDIO_RegisterDMACallback(GCMixSamples);
|
AUDIO_RegisterDMACallback(GCMixSamples);
|
||||||
}
|
}
|
||||||
else // menu
|
else // menu
|
||||||
{
|
{
|
||||||
AUDIO_StopDMA();
|
AUDIO_StopDMA();
|
||||||
AUDIO_RegisterDMACallback(NULL);
|
|
||||||
#ifndef NO_SOUND
|
#ifndef NO_SOUND
|
||||||
ASND_Init();
|
ASND_SetDMACallback();
|
||||||
ASND_Pause(0);
|
ASND_Pause(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
|
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
Threading modifications/corrections by Tantric, 2009
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are
|
Redistribution and use in source and binary forms, with or without modification, are
|
||||||
permitted provided that the following conditions are met:
|
permitted provided that the following conditions are met:
|
||||||
|
|
||||||
@ -61,8 +63,8 @@ static private_data_ogg private_ogg;
|
|||||||
#define STACKSIZE 8192
|
#define STACKSIZE 8192
|
||||||
|
|
||||||
static u8 oggplayer_stack[STACKSIZE];
|
static u8 oggplayer_stack[STACKSIZE];
|
||||||
static lwpq_t oggplayer_queue;
|
static lwpq_t oggplayer_queue = LWP_TQUEUE_NULL;
|
||||||
static lwp_t h_oggplayer;
|
static lwp_t h_oggplayer = LWP_THREAD_NULL;
|
||||||
static int ogg_thread_running = 0;
|
static int ogg_thread_running = 0;
|
||||||
|
|
||||||
static void ogg_add_callback(int voice)
|
static void ogg_add_callback(int voice)
|
||||||
@ -154,7 +156,6 @@ static void * ogg_player_thread(private_data_ogg * priv)
|
|||||||
ov_time_seek(&priv[0].vf, 0); // repeat
|
ov_time_seek(&priv[0].vf, 0); // repeat
|
||||||
else
|
else
|
||||||
priv[0].eof = 1; // stops
|
priv[0].eof = 1; // stops
|
||||||
//
|
|
||||||
}
|
}
|
||||||
else if (ret < 0)
|
else if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -205,12 +206,8 @@ static void * ogg_player_thread(private_data_ogg * priv)
|
|||||||
priv[0].flag = 0;
|
priv[0].flag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// if(priv[0].pcm_indx==0) priv[0].flag=0; // all samples sended
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
usleep(100);
|
||||||
}
|
}
|
||||||
ov_clear(&priv[0].vf);
|
ov_clear(&priv[0].vf);
|
||||||
priv[0].fd = -1;
|
priv[0].fd = -1;
|
||||||
@ -222,11 +219,19 @@ static void * ogg_player_thread(private_data_ogg * priv)
|
|||||||
void StopOgg()
|
void StopOgg()
|
||||||
{
|
{
|
||||||
ASND_StopVoice(0);
|
ASND_StopVoice(0);
|
||||||
if (ogg_thread_running > 0)
|
ogg_thread_running = 0;
|
||||||
|
|
||||||
|
if(h_oggplayer != LWP_THREAD_NULL)
|
||||||
{
|
{
|
||||||
ogg_thread_running = 0;
|
if(oggplayer_queue != LWP_TQUEUE_NULL)
|
||||||
LWP_ThreadSignal(oggplayer_queue);
|
LWP_ThreadSignal(oggplayer_queue);
|
||||||
LWP_JoinThread(h_oggplayer, NULL);
|
LWP_JoinThread(h_oggplayer, NULL);
|
||||||
|
h_oggplayer = LWP_THREAD_NULL;
|
||||||
|
}
|
||||||
|
if(oggplayer_queue != LWP_TQUEUE_NULL)
|
||||||
|
{
|
||||||
|
LWP_CloseQueue(oggplayer_queue);
|
||||||
|
oggplayer_queue = LWP_TQUEUE_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +290,6 @@ void PauseOgg(int pause)
|
|||||||
LWP_ThreadSignal(oggplayer_queue);
|
LWP_ThreadSignal(oggplayer_queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,9 +407,6 @@ main(int argc, char *argv[])
|
|||||||
// Initialize libFAT for SD and USB
|
// Initialize libFAT for SD and USB
|
||||||
MountAllFAT();
|
MountAllFAT();
|
||||||
|
|
||||||
// Audio
|
|
||||||
AUDIO_Init (NULL);
|
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
DefaultSettings ();
|
DefaultSettings ();
|
||||||
|
|
||||||
|
@ -267,7 +267,6 @@ static GXRModeObj *tvmodes[4] = {
|
|||||||
* VideoThreading
|
* VideoThreading
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#define TSTACK 16384
|
#define TSTACK 16384
|
||||||
static lwpq_t videoblankqueue;
|
|
||||||
static lwp_t vbthread = LWP_THREAD_NULL;
|
static lwp_t vbthread = LWP_THREAD_NULL;
|
||||||
static unsigned char vbstack[TSTACK];
|
static unsigned char vbstack[TSTACK];
|
||||||
|
|
||||||
@ -294,17 +293,10 @@ vbgetback (void *arg)
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* InitVideoThread
|
* InitVideoThread
|
||||||
*
|
|
||||||
* libOGC provides a nice wrapper for LWP access.
|
|
||||||
* This function sets up a new local queue and attaches the thread to it.
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void
|
void
|
||||||
InitVideoThread ()
|
InitVideoThread ()
|
||||||
{
|
{
|
||||||
/*** Initialise a new queue ***/
|
|
||||||
LWP_InitQueue (&videoblankqueue);
|
|
||||||
|
|
||||||
/*** Create the thread on this queue ***/
|
|
||||||
LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 100);
|
LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user