diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2019-08-21 15:18:50 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2019-08-21 15:18:50 +0100 |
| commit | 33f18cf7dca7741d3647d514040904ce83edd73d (patch) | |
| tree | 6b4d7d07672dac3fd63a0846a59468adee9f504a /audio/sdlaudio.c | |
| parent | e65472c7bc413d79faa61eb1d05c540b03945894 (diff) | |
| parent | e76ba19a1f1377314573a6df7e2d82b597aa3d0a (diff) | |
| download | focaccia-qemu-33f18cf7dca7741d3647d514040904ce83edd73d.tar.gz focaccia-qemu-33f18cf7dca7741d3647d514040904ce83edd73d.zip | |
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20190821-pull-request' into staging
audio: second batch of -audiodev support, adding support for multiple backends. # gpg: Signature made Wed 21 Aug 2019 09:40:37 BST # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/audio-20190821-pull-request: audio: fix memory leak reported by ASAN audio: use size_t where makes sense audio: remove read and write pcm_ops paaudio: fix playback glitches audio: do not run each backend in audio_run audio: remove audio_MIN, audio_MAX paaudio: properly disconnect streams in fini_* paaudio: do not move stream when sink/source name is specified audio: audiodev= parameters no longer optional when -audiodev present paaudio: prepare for multiple audiodev audio: add audiodev properties to frontends audio: add audiodev property to vnc and wav_capture audio: basic support for multi backend audio audio: reduce glob_audio_state usage audio: Add missing fall through comments Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'audio/sdlaudio.c')
| -rw-r--r-- | audio/sdlaudio.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index e7179ff1d4..14b11f0335 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -41,8 +41,8 @@ typedef struct SDLVoiceOut { HWVoiceOut hw; - int live; - int decr; + size_t live; + size_t decr; } SDLVoiceOut; static struct SDLAudioState { @@ -184,22 +184,22 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len) SDLVoiceOut *sdl = opaque; SDLAudioState *s = &glob_sdl; HWVoiceOut *hw = &sdl->hw; - int samples = len >> hw->info.shift; - int to_mix, decr; + size_t samples = len >> hw->info.shift; + size_t to_mix, decr; if (s->exit || !sdl->live) { return; } - /* dolog ("in callback samples=%d live=%d\n", samples, sdl->live); */ + /* dolog ("in callback samples=%zu live=%zu\n", samples, sdl->live); */ - to_mix = audio_MIN(samples, sdl->live); + to_mix = MIN(samples, sdl->live); decr = to_mix; while (to_mix) { - int chunk = audio_MIN(to_mix, hw->samples - hw->rpos); + size_t chunk = MIN(to_mix, hw->samples - hw->rpos); struct st_sample *src = hw->mix_buf + hw->rpos; - /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */ + /* dolog ("in callback to_mix %zu, chunk %zu\n", to_mix, chunk); */ hw->clip(buf, src, chunk); hw->rpos = (hw->rpos + chunk) % hw->samples; to_mix -= chunk; @@ -209,7 +209,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len) sdl->live -= decr; sdl->decr += decr; - /* dolog ("done len=%d\n", len); */ + /* dolog ("done len=%zu\n", len); */ /* SDL2 does not clear the remaining buffer for us, so do it on our own */ if (samples) { @@ -217,14 +217,9 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len) } } -static int sdl_write_out (SWVoiceOut *sw, void *buf, int len) +static size_t sdl_run_out(HWVoiceOut *hw, size_t live) { - return audio_pcm_sw_write (sw, buf, len); -} - -static int sdl_run_out (HWVoiceOut *hw, int live) -{ - int decr; + size_t decr; SDLVoiceOut *sdl = (SDLVoiceOut *) hw; SDL_LockAudio(); @@ -236,7 +231,7 @@ static int sdl_run_out (HWVoiceOut *hw, int live) sdl->live); } - decr = audio_MIN (sdl->decr, live); + decr = MIN (sdl->decr, live); sdl->decr -= decr; sdl->live = live; @@ -342,7 +337,6 @@ static struct audio_pcm_ops sdl_pcm_ops = { .init_out = sdl_init_out, .fini_out = sdl_fini_out, .run_out = sdl_run_out, - .write = sdl_write_out, .ctl_out = sdl_ctl_out, }; |