@@ -100,6 +100,11 @@ SimpleEnvMap pa_map[] = {
{ /* End of list */ }
};
+SimpleEnvMap sdl_map[] = {
+ { "QEMU_SDL_SAMPLES", "buffer-len", ENV_TRANSFORM_SAMPLES_TO_USECS_OUT },
+ { /* End of list */ }
+};
+
static unsigned long long toull(const char *str)
{
unsigned long long ret;
@@ -278,6 +283,8 @@ static void legacy_opt(const char *drv)
handle_env_opts(opts, oss_map);
} else if (strcmp(drv, "pa") == 0) {
handle_env_opts(opts, pa_map);
+ } else if (strcmp(drv, "sdl") == 0) {
+ handle_env_opts(opts, sdl_map);
}
}
@@ -44,18 +44,13 @@ typedef struct SDLVoiceOut {
int decr;
} SDLVoiceOut;
-static struct {
- int nb_samples;
-} conf = {
- .nb_samples = 1024
-};
-
static struct SDLAudioState {
int exit;
SDL_mutex *mutex;
SDL_sem *sem;
int initialized;
bool driver_created;
+ Audiodev *dev;
} glob_sdl;
typedef struct SDLAudioState SDLAudioState;
@@ -347,7 +342,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,
req.freq = as->freq;
req.format = aud_to_sdlfmt (as->fmt);
req.channels = as->nchannels;
- req.samples = conf.nb_samples;
+ req.samples = audio_buffer_samples(s->dev->out, as, 11610);
req.callback = sdl_callback;
req.userdata = sdl;
@@ -420,6 +415,7 @@ static void *sdl_audio_init(Audiodev *dev)
}
s->driver_created = true;
+ s->dev = dev;
return s;
}
@@ -431,18 +427,9 @@ static void sdl_audio_fini (void *opaque)
SDL_DestroyMutex (s->mutex);
SDL_QuitSubSystem (SDL_INIT_AUDIO);
s->driver_created = false;
+ s->dev = NULL;
}
-static struct audio_option sdl_options[] = {
- {
- .name = "SAMPLES",
- .tag = AUD_OPT_INT,
- .valp = &conf.nb_samples,
- .descr = "Size of SDL buffer in samples"
- },
- { /* End of list */ }
-};
-
static struct audio_pcm_ops sdl_pcm_ops = {
.init_out = sdl_init_out,
.fini_out = sdl_fini_out,
@@ -454,7 +441,6 @@ static struct audio_pcm_ops sdl_pcm_ops = {
struct audio_driver sdl_audio_driver = {
.name = "sdl",
.descr = "SDL http://www.libsdl.org",
- .options = sdl_options,
.init = sdl_audio_init,
.fini = sdl_audio_fini,
.pcm_ops = &sdl_pcm_ops,
Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com> --- audio/audio_legacy.c | 7 +++++++ audio/sdlaudio.c | 22 ++++------------------ 2 files changed, 11 insertions(+), 18 deletions(-)