[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/20] dsoundaudio: remove *_retries kludges
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 17/20] dsoundaudio: remove *_retries kludges |
Date: |
Mon, 15 Jun 2015 14:28:08 +0200 |
From: Kővágó, Zoltán <address@hidden>
According to MSDN this may happen when the window is not in the foreground, but
the default is 1 since a long time (which means no retries), so it should be ok.
I've found no problems during testing it on Windows 7 and wine, so this was
probably only the case with some old Windows versions.
Signed-off-by: Kővágó, Zoltán <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
audio/dsound_template.h | 35 +++++--------------------
audio/dsoundaudio.c | 68 ++++++++++---------------------------------------
2 files changed, 20 insertions(+), 83 deletions(-)
diff --git a/audio/dsound_template.h b/audio/dsound_template.h
index 85ba858..b439f33 100644
--- a/audio/dsound_template.h
+++ b/audio/dsound_template.h
@@ -72,48 +72,27 @@ static int glue (dsound_lock_, TYPE) (
)
{
HRESULT hr;
- int i;
LPVOID p1 = NULL, p2 = NULL;
DWORD blen1 = 0, blen2 = 0;
DWORD flag;
- DSoundConf *conf = &s->conf;
#ifdef DSBTYPE_IN
flag = entire ? DSCBLOCK_ENTIREBUFFER : 0;
#else
flag = entire ? DSBLOCK_ENTIREBUFFER : 0;
#endif
- for (i = 0; i < conf->lock_retries; ++i) {
- hr = glue (IFACE, _Lock) (
- buf,
- pos,
- len,
- &p1,
- &blen1,
- &p2,
- &blen2,
- flag
- );
+ hr = glue(IFACE, _Lock)(buf, pos, len, &p1, &blen1, &p2, &blen2, flag);
- if (FAILED (hr)) {
+ if (FAILED (hr)) {
#ifndef DSBTYPE_IN
- if (hr == DSERR_BUFFERLOST) {
- if (glue (dsound_restore_, TYPE) (buf, s)) {
- dsound_logerr (hr, "Could not lock " NAME "\n");
- goto fail;
- }
- continue;
+ if (hr == DSERR_BUFFERLOST) {
+ if (glue (dsound_restore_, TYPE) (buf, s)) {
+ dsound_logerr (hr, "Could not lock " NAME "\n");
}
-#endif
- dsound_logerr (hr, "Could not lock " NAME "\n");
goto fail;
}
-
- break;
- }
-
- if (i == conf->lock_retries) {
- dolog ("%d attempts to lock " NAME " failed\n", i);
+#endif
+ dsound_logerr (hr, "Could not lock " NAME "\n");
goto fail;
}
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index c8b09e2..28b98bf 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -42,9 +42,6 @@
/* #define DEBUG_DSOUND */
typedef struct {
- int lock_retries;
- int restore_retries;
- int getstatus_retries;
int set_primary;
int bufsize_in;
int bufsize_out;
@@ -274,26 +271,14 @@ static void print_wave_format (WAVEFORMATEX *wfx)
static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, dsound *s)
{
HRESULT hr;
- int i;
- for (i = 0; i < s->conf.restore_retries; ++i) {
- hr = IDirectSoundBuffer_Restore (dsb);
+ hr = IDirectSoundBuffer_Restore (dsb);
- switch (hr) {
- case DS_OK:
- return 0;
-
- case DSERR_BUFFERLOST:
- continue;
-
- default:
- dsound_logerr (hr, "Could not restore playback buffer\n");
- return -1;
- }
+ if (hr != DS_OK) {
+ dsound_logerr (hr, "Could not restore playback buffer\n");
+ return -1;
}
-
- dolog ("%d attempts to restore playback buffer failed\n", i);
- return -1;
+ return 0;
}
#include "dsound_template.h"
@@ -305,22 +290,16 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER
dsb, DWORD *statusp,
dsound *s)
{
HRESULT hr;
- int i;
- for (i = 0; i < s->conf.getstatus_retries; ++i) {
- hr = IDirectSoundBuffer_GetStatus (dsb, statusp);
- if (FAILED (hr)) {
- dsound_logerr (hr, "Could not get playback buffer status\n");
- return -1;
- }
+ hr = IDirectSoundBuffer_GetStatus (dsb, statusp);
+ if (FAILED (hr)) {
+ dsound_logerr (hr, "Could not get playback buffer status\n");
+ return -1;
+ }
- if (*statusp & DSERR_BUFFERLOST) {
- if (dsound_restore_out (dsb, s)) {
- return -1;
- }
- continue;
- }
- break;
+ if (*statusp & DSERR_BUFFERLOST) {
+ dsound_restore_out(dsb, s);
+ return -1;
}
return 0;
@@ -844,9 +823,6 @@ static int dsound_run_in (HWVoiceIn *hw)
}
static DSoundConf glob_conf = {
- .lock_retries = 1,
- .restore_retries = 1,
- .getstatus_retries = 1,
.set_primary = 0,
.bufsize_in = 16384,
.bufsize_out = 16384,
@@ -959,24 +935,6 @@ static void *dsound_audio_init (void)
static struct audio_option dsound_options[] = {
{
- .name = "LOCK_RETRIES",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.lock_retries,
- .descr = "Number of times to attempt locking the buffer"
- },
- {
- .name = "RESTOURE_RETRIES",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.restore_retries,
- .descr = "Number of times to attempt restoring the buffer"
- },
- {
- .name = "GETSTATUS_RETRIES",
- .tag = AUD_OPT_INT,
- .valp = &glob_conf.getstatus_retries,
- .descr = "Number of times to attempt getting status of the buffer"
- },
- {
.name = "SET_PRIMARY",
.tag = AUD_OPT_BOOL,
.valp = &glob_conf.set_primary,
--
1.8.3.1
- [Qemu-devel] [PULL 15/20] audio: remove LOG_TO_MONITOR along with default_mon, (continued)
- [Qemu-devel] [PULL 15/20] audio: remove LOG_TO_MONITOR along with default_mon, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 03/20] audio: remove winwave audio driver, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 08/20] ossaudio: do not use global variables, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 16/20] audio: remove plive, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 06/20] paaudio: do not use global variables, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 02/20] audio: remove fmod backend, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 01/20] audio: remove esd backend, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 05/20] audio: expose drv_opaque to init_out and init_in, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 19/20] alsaaudio: use trace events instead of verbose, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 07/20] alsaaudio: do not use global variables, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 17/20] dsoundaudio: remove *_retries kludges,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 20/20] ossaudio: use trace events instead of debug config flag, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 18/20] dsoundaudio: remove primary buffer, Gerd Hoffmann, 2015/06/15
- [Qemu-devel] [PULL 11/20] dsoundaudio: do not use global variables, Gerd Hoffmann, 2015/06/15
- Re: [Qemu-devel] [PULL 00/20] audio patch queue, Peter Maydell, 2015/06/15