mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
Remove mutexes - should hopefully fix dolphin/reicast threaded
again
This commit is contained in:
parent
4505f0ef51
commit
660d0c8de9
@ -49,10 +49,6 @@
|
|||||||
#include "../file_path_special.h"
|
#include "../file_path_special.h"
|
||||||
#include "../content.h"
|
#include "../content.h"
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
#include <rthreads/rthreads.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
|
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
|
||||||
|
|
||||||
#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac"
|
#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac"
|
||||||
@ -202,10 +198,6 @@ static void *audio_driver_context_audio_data = NULL;
|
|||||||
static bool audio_suspended = false;
|
static bool audio_suspended = false;
|
||||||
static bool audio_is_threaded = false;
|
static bool audio_is_threaded = false;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
static slock_t* s_audio_driver_lock = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void audio_mixer_play_stop_sequential_cb(
|
static void audio_mixer_play_stop_sequential_cb(
|
||||||
audio_mixer_sound_t *sound, unsigned reason);
|
audio_mixer_sound_t *sound, unsigned reason);
|
||||||
static void audio_mixer_play_stop_cb(
|
static void audio_mixer_play_stop_cb(
|
||||||
@ -213,22 +205,6 @@ static void audio_mixer_play_stop_cb(
|
|||||||
static void audio_mixer_menu_stop_cb(
|
static void audio_mixer_menu_stop_cb(
|
||||||
audio_mixer_sound_t *sound, unsigned reason);
|
audio_mixer_sound_t *sound, unsigned reason);
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
#define audio_driver_lock() \
|
|
||||||
if (s_audio_driver_lock) \
|
|
||||||
slock_lock(s_audio_driver_lock)
|
|
||||||
#else
|
|
||||||
#define audio_driver_lock()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
#define audio_driver_unlock() \
|
|
||||||
if (s_audio_driver_lock) \
|
|
||||||
slock_unlock(s_audio_driver_lock)
|
|
||||||
#else
|
|
||||||
#define audio_driver_unlock()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static enum resampler_quality audio_driver_get_resampler_quality(void)
|
static enum resampler_quality audio_driver_get_resampler_quality(void)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
@ -547,15 +523,6 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
|||||||
audio_source_ratio_original = audio_source_ratio_current =
|
audio_source_ratio_original = audio_source_ratio_current =
|
||||||
(double)settings->uints.audio_out_rate / audio_driver_input;
|
(double)settings->uints.audio_out_rate / audio_driver_input;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
if (s_audio_driver_lock)
|
|
||||||
slock_free(s_audio_driver_lock);
|
|
||||||
s_audio_driver_lock = slock_new();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
audio_resampler_lock_init();
|
|
||||||
audio_resampler_lock();
|
|
||||||
|
|
||||||
if (!retro_resampler_realloc(
|
if (!retro_resampler_realloc(
|
||||||
&audio_driver_resampler_data,
|
&audio_driver_resampler_data,
|
||||||
&audio_driver_resampler,
|
&audio_driver_resampler,
|
||||||
@ -568,8 +535,6 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
|||||||
audio_driver_active = false;
|
audio_driver_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_resampler_unlock();
|
|
||||||
|
|
||||||
aud_inp_data = (float*)malloc(max_bufsamples * sizeof(float));
|
aud_inp_data = (float*)malloc(max_bufsamples * sizeof(float));
|
||||||
retro_assert(aud_inp_data != NULL);
|
retro_assert(aud_inp_data != NULL);
|
||||||
|
|
||||||
@ -640,13 +605,9 @@ void audio_driver_set_nonblocking_state(bool enable)
|
|||||||
audio_driver_context_audio_data,
|
audio_driver_context_audio_data,
|
||||||
settings->bools.audio_sync ? enable : true);
|
settings->bools.audio_sync ? enable : true);
|
||||||
|
|
||||||
audio_driver_lock();
|
|
||||||
|
|
||||||
audio_driver_chunk_size = enable ?
|
audio_driver_chunk_size = enable ?
|
||||||
audio_driver_chunk_nonblock_size :
|
audio_driver_chunk_nonblock_size :
|
||||||
audio_driver_chunk_block_size;
|
audio_driver_chunk_block_size;
|
||||||
|
|
||||||
audio_driver_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -689,13 +650,9 @@ static void audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
!audio_driver_output_samples_buf)
|
!audio_driver_output_samples_buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
audio_driver_lock();
|
|
||||||
|
|
||||||
convert_s16_to_float(audio_driver_input_data, data, samples,
|
convert_s16_to_float(audio_driver_input_data, data, samples,
|
||||||
audio_volume_gain);
|
audio_volume_gain);
|
||||||
|
|
||||||
audio_driver_unlock();
|
|
||||||
|
|
||||||
src_data.data_in = audio_driver_input_data;
|
src_data.data_in = audio_driver_input_data;
|
||||||
src_data.input_frames = samples >> 1;
|
src_data.input_frames = samples >> 1;
|
||||||
|
|
||||||
@ -759,11 +716,7 @@ static void audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
src_data.ratio *= settings->floats.slowmotion_ratio;
|
src_data.ratio *= settings->floats.slowmotion_ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_driver_lock();
|
|
||||||
|
|
||||||
audio_resampler_lock();
|
|
||||||
audio_driver_resampler->process(audio_driver_resampler_data, &src_data);
|
audio_driver_resampler->process(audio_driver_resampler_data, &src_data);
|
||||||
audio_resampler_unlock();
|
|
||||||
|
|
||||||
is_active = audio_mixer_active;
|
is_active = audio_mixer_active;
|
||||||
|
|
||||||
@ -777,8 +730,6 @@ static void audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
src_data.output_frames, mixer_gain, override);
|
src_data.output_frames, mixer_gain, override);
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_driver_unlock();
|
|
||||||
|
|
||||||
output_data = audio_driver_output_samples_buf;
|
output_data = audio_driver_output_samples_buf;
|
||||||
output_frames = (unsigned)src_data.output_frames;
|
output_frames = (unsigned)src_data.output_frames;
|
||||||
|
|
||||||
@ -793,13 +744,9 @@ static void audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
output_frames *= sizeof(int16_t);
|
output_frames *= sizeof(int16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_driver_lock();
|
|
||||||
|
|
||||||
if (current_audio->write(audio_driver_context_audio_data,
|
if (current_audio->write(audio_driver_context_audio_data,
|
||||||
output_data, output_frames * 2) < 0)
|
output_data, output_frames * 2) < 0)
|
||||||
audio_driver_active = false;
|
audio_driver_active = false;
|
||||||
|
|
||||||
audio_driver_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -811,24 +758,14 @@ static void audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
**/
|
**/
|
||||||
void audio_driver_sample(int16_t left, int16_t right)
|
void audio_driver_sample(int16_t left, int16_t right)
|
||||||
{
|
{
|
||||||
audio_driver_lock();
|
|
||||||
|
|
||||||
if (audio_suspended)
|
if (audio_suspended)
|
||||||
{
|
|
||||||
audio_driver_unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
audio_driver_output_samples_conv_buf[audio_driver_data_ptr++] = left;
|
audio_driver_output_samples_conv_buf[audio_driver_data_ptr++] = left;
|
||||||
audio_driver_output_samples_conv_buf[audio_driver_data_ptr++] = right;
|
audio_driver_output_samples_conv_buf[audio_driver_data_ptr++] = right;
|
||||||
|
|
||||||
if (audio_driver_data_ptr < audio_driver_chunk_size)
|
if (audio_driver_data_ptr < audio_driver_chunk_size)
|
||||||
{
|
|
||||||
audio_driver_unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
audio_driver_unlock();
|
|
||||||
|
|
||||||
audio_driver_flush(audio_driver_output_samples_conv_buf,
|
audio_driver_flush(audio_driver_output_samples_conv_buf,
|
||||||
audio_driver_data_ptr);
|
audio_driver_data_ptr);
|
||||||
@ -1051,13 +988,10 @@ bool audio_driver_find_driver(void)
|
|||||||
|
|
||||||
void audio_driver_deinit_resampler(void)
|
void audio_driver_deinit_resampler(void)
|
||||||
{
|
{
|
||||||
audio_resampler_lock();
|
|
||||||
if (audio_driver_resampler && audio_driver_resampler_data)
|
if (audio_driver_resampler && audio_driver_resampler_data)
|
||||||
audio_driver_resampler->free(audio_driver_resampler_data);
|
audio_driver_resampler->free(audio_driver_resampler_data);
|
||||||
audio_driver_resampler = NULL;
|
audio_driver_resampler = NULL;
|
||||||
audio_driver_resampler_data = NULL;
|
audio_driver_resampler_data = NULL;
|
||||||
audio_resampler_unlock();
|
|
||||||
audio_resampler_lock_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool audio_driver_free_devices_list(void)
|
bool audio_driver_free_devices_list(void)
|
||||||
@ -1353,8 +1287,6 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_driver_lock();
|
|
||||||
|
|
||||||
audio_mixer_active = true;
|
audio_mixer_active = true;
|
||||||
|
|
||||||
audio_mixer_streams[free_slot].name = !string_is_empty(params->basename) ? strdup(params->basename) : NULL;
|
audio_mixer_streams[free_slot].name = !string_is_empty(params->basename) ? strdup(params->basename) : NULL;
|
||||||
@ -1367,8 +1299,6 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params)
|
|||||||
audio_mixer_streams[free_slot].volume = params->volume;
|
audio_mixer_streams[free_slot].volume = params->volume;
|
||||||
audio_mixer_streams[free_slot].stop_cb = stop_cb;
|
audio_mixer_streams[free_slot].stop_cb = stop_cb;
|
||||||
|
|
||||||
audio_driver_unlock();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,10 +1583,6 @@ bool audio_driver_deinit(void)
|
|||||||
{
|
{
|
||||||
audio_driver_mixer_deinit();
|
audio_driver_mixer_deinit();
|
||||||
audio_driver_free_devices_list();
|
audio_driver_free_devices_list();
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_free(s_audio_driver_lock);
|
|
||||||
s_audio_driver_lock = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!audio_driver_deinit_internal())
|
if (!audio_driver_deinit_internal())
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,10 +26,6 @@
|
|||||||
#include <formats/rwav.h>
|
#include <formats/rwav.h>
|
||||||
#include <memalign.h>
|
#include <memalign.h>
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
#include <rthreads/rthreads.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -191,10 +187,6 @@ struct audio_mixer_voice
|
|||||||
static struct audio_mixer_voice s_voices[AUDIO_MIXER_MAX_VOICES] = {{0}};
|
static struct audio_mixer_voice s_voices[AUDIO_MIXER_MAX_VOICES] = {{0}};
|
||||||
static unsigned s_rate = 0;
|
static unsigned s_rate = 0;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
static slock_t* s_locker = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool wav2float(const rwav_t* wav, float** pcm, size_t samples_out)
|
static bool wav2float(const rwav_t* wav, float** pcm, size_t samples_out)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -316,24 +308,12 @@ void audio_mixer_init(unsigned rate)
|
|||||||
|
|
||||||
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++)
|
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++)
|
||||||
s_voices[i].type = AUDIO_MIXER_TYPE_NONE;
|
s_voices[i].type = AUDIO_MIXER_TYPE_NONE;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
if (s_locker)
|
|
||||||
slock_free(s_locker);
|
|
||||||
s_locker = slock_new();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_mixer_done(void)
|
void audio_mixer_done(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
/* Dont call audio mixer functions after this point */
|
|
||||||
slock_free(s_locker);
|
|
||||||
s_locker = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++)
|
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++)
|
||||||
s_voices[i].type = AUDIO_MIXER_TYPE_NONE;
|
s_voices[i].type = AUDIO_MIXER_TYPE_NONE;
|
||||||
}
|
}
|
||||||
@ -801,12 +781,6 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat,
|
|||||||
if (!sound)
|
if (!sound)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_lock(s_locker);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
audio_resampler_lock();
|
|
||||||
|
|
||||||
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++)
|
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++)
|
||||||
{
|
{
|
||||||
if (voice->type != AUDIO_MIXER_TYPE_NONE)
|
if (voice->type != AUDIO_MIXER_TYPE_NONE)
|
||||||
@ -855,12 +829,6 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat,
|
|||||||
else
|
else
|
||||||
voice = NULL;
|
voice = NULL;
|
||||||
|
|
||||||
audio_resampler_unlock();
|
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_unlock(s_locker);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return voice;
|
return voice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,19 +839,11 @@ void audio_mixer_stop(audio_mixer_voice_t* voice)
|
|||||||
|
|
||||||
if (voice)
|
if (voice)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_lock(s_locker);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
stop_cb = voice->stop_cb;
|
stop_cb = voice->stop_cb;
|
||||||
sound = voice->sound;
|
sound = voice->sound;
|
||||||
|
|
||||||
voice->type = AUDIO_MIXER_TYPE_NONE;
|
voice->type = AUDIO_MIXER_TYPE_NONE;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_unlock(s_locker);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (stop_cb)
|
if (stop_cb)
|
||||||
stop_cb(sound, AUDIO_MIXER_SOUND_STOPPED);
|
stop_cb(sound, AUDIO_MIXER_SOUND_STOPPED);
|
||||||
}
|
}
|
||||||
@ -1239,12 +1199,6 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo
|
|||||||
float* sample = NULL;
|
float* sample = NULL;
|
||||||
audio_mixer_voice_t* voice = s_voices;
|
audio_mixer_voice_t* voice = s_voices;
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_lock(s_locker);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
audio_resampler_lock();
|
|
||||||
|
|
||||||
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++)
|
for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++)
|
||||||
{
|
{
|
||||||
float volume = (override) ? volume_override : voice->volume;
|
float volume = (override) ? volume_override : voice->volume;
|
||||||
@ -1286,12 +1240,6 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo
|
|||||||
else if (*sample > 1.0f)
|
else if (*sample > 1.0f)
|
||||||
*sample = 1.0f;
|
*sample = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
audio_resampler_unlock();
|
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
slock_unlock(s_locker);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float audio_mixer_voice_get_volume(audio_mixer_voice_t *voice)
|
float audio_mixer_voice_get_volume(audio_mixer_voice_t *voice)
|
||||||
|
@ -28,14 +28,6 @@
|
|||||||
|
|
||||||
#include <audio/audio_resampler.h>
|
#include <audio/audio_resampler.h>
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
#include <rthreads/rthreads.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
static slock_t* s_resampler_lock = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const retro_resampler_t *resampler_drivers[] = {
|
static const retro_resampler_t *resampler_drivers[] = {
|
||||||
&sinc_resampler,
|
&sinc_resampler,
|
||||||
#ifdef HAVE_CC_RESAMPLER
|
#ifdef HAVE_CC_RESAMPLER
|
||||||
@ -178,37 +170,3 @@ bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_resampler_lock_init(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
if (s_resampler_lock)
|
|
||||||
slock_free(s_resampler_lock);
|
|
||||||
s_resampler_lock = slock_new();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void audio_resampler_lock_free(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
if (s_resampler_lock)
|
|
||||||
slock_free(s_resampler_lock);
|
|
||||||
s_resampler_lock = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void audio_resampler_lock(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
if (s_resampler_lock)
|
|
||||||
slock_lock(s_resampler_lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void audio_resampler_unlock(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
if (s_resampler_lock)
|
|
||||||
slock_unlock(s_resampler_lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
@ -190,14 +190,6 @@ const char *audio_resampler_driver_find_ident(int index);
|
|||||||
bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
|
bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
|
||||||
const char *ident, enum resampler_quality quality, double bw_ratio);
|
const char *ident, enum resampler_quality quality, double bw_ratio);
|
||||||
|
|
||||||
void audio_resampler_lock_init(void);
|
|
||||||
|
|
||||||
void audio_resampler_lock(void);
|
|
||||||
|
|
||||||
void audio_resampler_unlock(void);
|
|
||||||
|
|
||||||
void audio_resampler_lock_free(void);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user