From cc82835c2b38b1552fbf631babd46a8d1f39aef7 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sun, 14 Nov 1999 17:20:11 +0000 Subject: [PATCH] Fixed bug in wxSound windows driver (Recording is in progress: don't try it it make Windows crash completely) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/wxMMedia2/lib/makefile.vc | 2 +- utils/wxMMedia2/lib/sndwin.cpp | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/utils/wxMMedia2/lib/makefile.vc b/utils/wxMMedia2/lib/makefile.vc index 12736d67ca..28224c0016 100644 --- a/utils/wxMMedia2/lib/makefile.vc +++ b/utils/wxMMedia2/lib/makefile.vc @@ -18,7 +18,7 @@ THISDIR = $(MMDIR)\lib EXTRALIBS=$(WXDIR)\lib\glcanvas.lib LIBTARGET=$(WXDIR)\lib\mmedia2.lib -OBJECTS = cdbase.obj cdwin.obj g711.obj g721.obj g723_24.obj \ +OBJECTS = cdbase.obj cdwin.obj g711.obj g721.obj g723_24.obj sndg72x.obj \ g723_40.obj g72x.obj sndbase.obj sndcodec.obj sndpcm.obj \ sndcpcm.obj sndulaw.obj sndfile.obj sndwav.obj sndaiff.obj sndwin.obj \ vidbase.obj diff --git a/utils/wxMMedia2/lib/sndwin.cpp b/utils/wxMMedia2/lib/sndwin.cpp index d4b73f2370..3dfb2ec139 100644 --- a/utils/wxMMedia2/lib/sndwin.cpp +++ b/utils/wxMMedia2/lib/sndwin.cpp @@ -65,6 +65,9 @@ wxSoundStreamWin::wxSoundStreamWin() CreateSndWindow(); SetSoundFormat(pcm); + m_internal->m_input_enabled = FALSE; + m_internal->m_output_enabled = FALSE; + if (!OpenDevice(wxSOUND_OUTPUT)) return; @@ -83,12 +86,18 @@ wxSoundStreamWin::~wxSoundStreamWin() LRESULT APIENTRY _EXPORT _wxSoundHandlerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + wxSoundStreamWin *sndwin; + + sndwin = wxFindSoundFromHandle((WXHWND)hWnd); + if (!sndwin) + return (LRESULT)0; + switch (message) { case MM_WOM_DONE: - wxFindSoundFromHandle((WXHWND)hWnd)->NotifyDoneBuffer(wParam, wxSOUND_OUTPUT); + sndwin->NotifyDoneBuffer(wParam, wxSOUND_OUTPUT); break; case MM_WIM_DATA: - wxFindSoundFromHandle((WXHWND)hWnd)->NotifyDoneBuffer(wParam, wxSOUND_INPUT); + sndwin->NotifyDoneBuffer(wParam, wxSOUND_INPUT); break; default: break; @@ -228,16 +237,15 @@ bool wxSoundStreamWin::OpenDevice(int mode) // ------------------------------------------------------------------------- void wxSoundStreamWin::CloseDevice() { - m_internal->m_output_enabled = FALSE; - m_internal->m_input_enabled = FALSE; - if (m_internal->m_output_enabled) { + m_internal->m_output_enabled = FALSE; waveOutReset(m_internal->m_devout); FreeHeaders(wxSOUND_OUTPUT); waveOutClose(m_internal->m_devout); } if (m_internal->m_input_enabled) { + m_internal->m_input_enabled = FALSE; waveInReset(m_internal->m_devin); FreeHeaders(wxSOUND_INPUT); waveInClose(m_internal->m_devin); @@ -549,12 +557,12 @@ wxSoundInfoHeader *wxSoundStreamWin::NextFragmentInput() { wxSoundInfoHeader *header; + m_current_frag_in = (m_current_frag_in + 1) % WXSOUND_MAX_QUEUE; + header = m_headers_rec[m_current_frag_in]; if (header->m_recording) WaitFor(header); - m_current_frag_in = (m_current_frag_in + 1) % WXSOUND_MAX_QUEUE; - if (m_current_frag_in == m_input_frag_in) m_queue_filled = TRUE;