From 8bc3d3ac5cab924f07dfea74d8e5d89b52fd2dc0 Mon Sep 17 00:00:00 2001 From: Themaister Date: Mon, 23 May 2011 14:04:31 +0200 Subject: [PATCH] Add possibility for audio driver to override sample rate. --- audio/ext.c | 3 +++ audio/ext/ssnes_audio.h | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/audio/ext.c b/audio/ext.c index 4e2b0081e6..931778643b 100644 --- a/audio/ext.c +++ b/audio/ext.c @@ -100,6 +100,9 @@ static void* audio_ext_init(const char *device, unsigned rate, unsigned latency) goto error; } + if (ext->driver->sample_rate) + g_settings.audio.out_rate = ext->driver->sample_rate(ext->handle); + return ext; error: diff --git a/audio/ext/ssnes_audio.h b/audio/ext/ssnes_audio.h index dc56808d4d..b9c32f1d47 100644 --- a/audio/ext/ssnes_audio.h +++ b/audio/ext/ssnes_audio.h @@ -38,7 +38,7 @@ extern "C" { #define SSNES_ERROR 0 #endif -#define SSNES_AUDIO_API_VERSION 1 +#define SSNES_AUDIO_API_VERSION 2 typedef struct ssnes_audio_driver_info { @@ -103,6 +103,13 @@ typedef struct ssnes_audio_driver // [-1.0, 1.0]. int (*use_float)(void *data); + // The driver might be forced to use a certain output frequency + // (i.e. Jack), and thus to avoid double resampling, the driver + // can request SSNES to resample to a different sample rate. + // This function can be set to NULL if the driver does not + // desire to override the sample rate. + unsigned (*sample_rate)(void *data); + // Human readable identification string for the driver. const char *ident;