Received: from eggs.gnu.org ([2001:4830:134:3::10]:49214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TV1-0006or-UX for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4TUy-00063Y-N3 for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUy-00062I-72 for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:20 -0400 From: Gerd Hoffmann Date: Mon, 15 Jun 2015 14:28:08 +0200 Message-Id: <1434371291-6994-18-git-send-email-kraxel@redhat.com> In-Reply-To: <1434371291-6994-1-git-send-email-kraxel@redhat.com> References: <1434371291-6994-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 17/20] dsoundaudio: remove *_retries kludges List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n According to MSDN this may happen when the window is not in the foregroun= d, 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 w= as probably only the case with some old Windows versions. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: Gerd Hoffmann --- 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 =3D NULL, p2 =3D NULL; DWORD blen1 =3D 0, blen2 =3D 0; DWORD flag; - DSoundConf *conf =3D &s->conf; =20 #ifdef DSBTYPE_IN flag =3D entire ? DSCBLOCK_ENTIREBUFFER : 0; #else flag =3D entire ? DSBLOCK_ENTIREBUFFER : 0; #endif - for (i =3D 0; i < conf->lock_retries; ++i) { - hr =3D glue (IFACE, _Lock) ( - buf, - pos, - len, - &p1, - &blen1, - &p2, - &blen2, - flag - ); + hr =3D glue(IFACE, _Lock)(buf, pos, len, &p1, &blen1, &p2, &blen2, f= lag); =20 - if (FAILED (hr)) { + if (FAILED (hr)) { #ifndef DSBTYPE_IN - if (hr =3D=3D DSERR_BUFFERLOST) { - if (glue (dsound_restore_, TYPE) (buf, s)) { - dsound_logerr (hr, "Could not lock " NAME "\n"); - goto fail; - } - continue; + if (hr =3D=3D 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 =3D=3D conf->lock_retries) { - dolog ("%d attempts to lock " NAME " failed\n", i); +#endif + dsound_logerr (hr, "Could not lock " NAME "\n"); goto fail; } =20 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 */ =20 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; =20 - for (i =3D 0; i < s->conf.restore_retries; ++i) { - hr =3D IDirectSoundBuffer_Restore (dsb); + hr =3D IDirectSoundBuffer_Restore (dsb); =20 - 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 !=3D 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; } =20 #include "dsound_template.h" @@ -305,22 +290,16 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFF= ER dsb, DWORD *statusp, dsound *s) { HRESULT hr; - int i; =20 - for (i =3D 0; i < s->conf.getstatus_retries; ++i) { - hr =3D IDirectSoundBuffer_GetStatus (dsb, statusp); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not get playback buffer status\n")= ; - return -1; - } + hr =3D IDirectSoundBuffer_GetStatus (dsb, statusp); + if (FAILED (hr)) { + dsound_logerr (hr, "Could not get playback buffer status\n"); + return -1; + } =20 - 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; } =20 return 0; @@ -844,9 +823,6 @@ static int dsound_run_in (HWVoiceIn *hw) } =20 static DSoundConf glob_conf =3D { - .lock_retries =3D 1, - .restore_retries =3D 1, - .getstatus_retries =3D 1, .set_primary =3D 0, .bufsize_in =3D 16384, .bufsize_out =3D 16384, @@ -959,24 +935,6 @@ static void *dsound_audio_init (void) =20 static struct audio_option dsound_options[] =3D { { - .name =3D "LOCK_RETRIES", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.lock_retries, - .descr =3D "Number of times to attempt locking the buffer" - }, - { - .name =3D "RESTOURE_RETRIES", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.restore_retries, - .descr =3D "Number of times to attempt restoring the buffer" - }, - { - .name =3D "GETSTATUS_RETRIES", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.getstatus_retries, - .descr =3D "Number of times to attempt getting status of the buf= fer" - }, - { .name =3D "SET_PRIMARY", .tag =3D AUD_OPT_BOOL, .valp =3D &glob_conf.set_primary, --=20 1.8.3.1