mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 00:32:49 +00:00
Better audio quality when fast forwarding.
This commit is contained in:
parent
bfb84984f8
commit
9cebdc51cc
22
ssnes.c
22
ssnes.c
@ -72,6 +72,10 @@ static void save_file(const char* path, int type);
|
||||
|
||||
|
||||
// To avoid continous switching if we hold the button down, we require that the button must go from pressed, unpressed back to pressed to be able to toggle between then.
|
||||
|
||||
#define AUDIO_CHUNK_SIZE_BLOCKING 64
|
||||
#define AUDIO_CHUNK_SIZE_NONBLOCKING 1024 // So we don't get complete line-noise when fast-forwarding audio.
|
||||
static size_t audio_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING;
|
||||
void set_fast_forward_button(bool new_button_state)
|
||||
{
|
||||
static bool old_button_state = false;
|
||||
@ -81,6 +85,10 @@ void set_fast_forward_button(bool new_button_state)
|
||||
syncing_state = !syncing_state;
|
||||
driver.video->set_nonblock_state(driver.video_data, syncing_state);
|
||||
driver.audio->set_nonblock_state(driver.audio_data, syncing_state);
|
||||
if (syncing_state)
|
||||
audio_chunk_size = AUDIO_CHUNK_SIZE_NONBLOCKING;
|
||||
else
|
||||
audio_chunk_size = AUDIO_CHUNK_SIZE_BLOCKING;
|
||||
}
|
||||
old_button_state = new_button_state;
|
||||
}
|
||||
@ -212,30 +220,28 @@ static void video_frame(const uint16_t *data, unsigned width, unsigned height)
|
||||
|
||||
}
|
||||
|
||||
#define SRC_SAMPLES 64
|
||||
|
||||
static void audio_sample(uint16_t left, uint16_t right)
|
||||
{
|
||||
if ( !audio_active )
|
||||
return;
|
||||
|
||||
static float data[SRC_SAMPLES];
|
||||
static float data[AUDIO_CHUNK_SIZE_NONBLOCKING];
|
||||
static int data_ptr = 0;
|
||||
|
||||
data[data_ptr++] = (float)(*(int16_t*)&left)/0x7FFF;
|
||||
data[data_ptr++] = (float)(*(int16_t*)&right)/0x7FFF;
|
||||
|
||||
if ( data_ptr == SRC_SAMPLES )
|
||||
if ( data_ptr >= audio_chunk_size )
|
||||
{
|
||||
float outsamples[SRC_SAMPLES * 16];
|
||||
int16_t temp_outsamples[SRC_SAMPLES * 16];
|
||||
float outsamples[audio_chunk_size * 16];
|
||||
int16_t temp_outsamples[audio_chunk_size * 16];
|
||||
|
||||
SRC_DATA src_data;
|
||||
|
||||
src_data.data_in = data;
|
||||
src_data.data_out = outsamples;
|
||||
src_data.input_frames = SRC_SAMPLES / 2;
|
||||
src_data.output_frames = SRC_SAMPLES * 8;
|
||||
src_data.input_frames = audio_chunk_size / 2;
|
||||
src_data.output_frames = audio_chunk_size * 8;
|
||||
src_data.end_of_input = 0;
|
||||
src_data.src_ratio = (double)out_rate / (double)in_rate;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user