Received: from eggs.gnu.org ([2001:4830:134:3::10]:49222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TV2-0006pG-2Q 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 1Z4TUz-00064H-54 for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUy-00063X-Rr for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:21 -0400 From: Gerd Hoffmann Date: Mon, 15 Jun 2015 14:28:09 +0200 Message-Id: <1434371291-6994-19-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 18/20] dsoundaudio: remove primary buffer 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 Enabling this option just creates a playback buffer with the specified se= ttings, and then ignores it. It's probably some outdated hack to set audio format= s on windows. (The first created stream dictates all other streams settings, a= t least on some Windows versions). Setting DAC_FIXED_SETTINGS should have the sam= e effect as setting (the now removed) primary buffer. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: Gerd Hoffmann --- audio/dsoundaudio.c | 104 ----------------------------------------------= ------ 1 file changed, 104 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 28b98bf..e9472c1 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -42,17 +42,14 @@ /* #define DEBUG_DSOUND */ =20 typedef struct { - int set_primary; int bufsize_in; int bufsize_out; - struct audsettings settings; int latency_millis; } DSoundConf; =20 typedef struct { LPDIRECTSOUND dsound; LPDIRECTSOUNDCAPTURE dsound_capture; - LPDIRECTSOUNDBUFFER dsound_primary_buffer; struct audsettings settings; DSoundConf conf; } dsound; @@ -387,27 +384,10 @@ static void dsound_clear_sample (HWVoiceOut *hw, LP= DIRECTSOUNDBUFFER dsb, dsound_unlock_out (dsb, p1, p2, blen1, blen2); } =20 -static void dsound_close (dsound *s) -{ - HRESULT hr; - - if (s->dsound_primary_buffer) { - hr =3D IDirectSoundBuffer_Release (s->dsound_primary_buffer); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not release primary buffer\n"); - } - s->dsound_primary_buffer =3D NULL; - } -} - static int dsound_open (dsound *s) { - int err; HRESULT hr; - WAVEFORMATEX wfx; - DSBUFFERDESC dsbd; HWND hwnd; - DSoundConf *conf =3D &s->conf; =20 hwnd =3D GetForegroundWindow (); hr =3D IDirectSound_SetCooperativeLevel ( @@ -422,63 +402,7 @@ static int dsound_open (dsound *s) return -1; } =20 - if (!conf->set_primary) { - return 0; - } - - err =3D waveformat_from_audio_settings (&wfx, &conf->settings); - if (err) { - return -1; - } - - memset (&dsbd, 0, sizeof (dsbd)); - dsbd.dwSize =3D sizeof (dsbd); - dsbd.dwFlags =3D DSBCAPS_PRIMARYBUFFER; - dsbd.dwBufferBytes =3D 0; - dsbd.lpwfxFormat =3D NULL; - - hr =3D IDirectSound_CreateSoundBuffer ( - s->dsound, - &dsbd, - &s->dsound_primary_buffer, - NULL - ); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not create primary playback buffer\n")= ; - return -1; - } - - hr =3D IDirectSoundBuffer_SetFormat (s->dsound_primary_buffer, &wfx)= ; - if (FAILED (hr)) { - dsound_logerr (hr, "Could not set primary playback buffer format= \n"); - } - - hr =3D IDirectSoundBuffer_GetFormat ( - s->dsound_primary_buffer, - &wfx, - sizeof (wfx), - NULL - ); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not get primary playback buffer format= \n"); - goto fail0; - } - -#ifdef DEBUG_DSOUND - dolog ("Primary\n"); - print_wave_format (&wfx); -#endif - - err =3D waveformat_to_audio_settings (&wfx, &s->settings); - if (err) { - goto fail0; - } - return 0; - - fail0: - dsound_close (s); - return -1; } =20 static int dsound_ctl_out (HWVoiceOut *hw, int cmd, ...) @@ -823,12 +747,8 @@ static int dsound_run_in (HWVoiceIn *hw) } =20 static DSoundConf glob_conf =3D { - .set_primary =3D 0, .bufsize_in =3D 16384, .bufsize_out =3D 16384, - .settings.freq =3D 44100, - .settings.nchannels =3D 2, - .settings.fmt =3D AUD_FMT_S16, .latency_millis =3D 10 }; =20 @@ -935,36 +855,12 @@ static void *dsound_audio_init (void) =20 static struct audio_option dsound_options[] =3D { { - .name =3D "SET_PRIMARY", - .tag =3D AUD_OPT_BOOL, - .valp =3D &glob_conf.set_primary, - .descr =3D "Set the parameters of primary buffer" - }, - { .name =3D "LATENCY_MILLIS", .tag =3D AUD_OPT_INT, .valp =3D &glob_conf.latency_millis, .descr =3D "(undocumented)" }, { - .name =3D "PRIMARY_FREQ", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.settings.freq, - .descr =3D "Primary buffer frequency" - }, - { - .name =3D "PRIMARY_CHANNELS", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.settings.nchannels, - .descr =3D "Primary buffer number of channels (1 - mono, 2 - ste= reo)" - }, - { - .name =3D "PRIMARY_FMT", - .tag =3D AUD_OPT_FMT, - .valp =3D &glob_conf.settings.fmt, - .descr =3D "Primary buffer format" - }, - { .name =3D "BUFSIZE_OUT", .tag =3D AUD_OPT_INT, .valp =3D &glob_conf.bufsize_out, --=20 1.8.3.1