Commit e52f5773 authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

winealsa: Favour HeapAlloc() over malloc().

parent 8df87253
...@@ -369,7 +369,6 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -369,7 +369,6 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
return MMSYSERR_ALLOCATED; return MMSYSERR_ALLOCATED;
} }
wwi->pcm = 0;
flags = SND_PCM_NONBLOCK; flags = SND_PCM_NONBLOCK;
if ( (err=snd_pcm_open(&pcm, wwi->pcmname, SND_PCM_STREAM_CAPTURE, flags)) < 0 ) if ( (err=snd_pcm_open(&pcm, wwi->pcmname, SND_PCM_STREAM_CAPTURE, flags)) < 0 )
...@@ -393,7 +392,11 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -393,7 +392,11 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() ); hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() );
sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() ); sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() );
if (!hw_params || !sw_params)
{
ret = MMSYSERR_NOMEM;
goto error;
}
snd_pcm_hw_params_any(pcm, hw_params); snd_pcm_hw_params_any(pcm, hw_params);
#define EXIT_ON_ERROR(f,e,txt) do \ #define EXIT_ON_ERROR(f,e,txt) do \
...@@ -488,14 +491,9 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -488,14 +491,9 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
ALSA_TraceParameters(hw_params, sw_params, FALSE); ALSA_TraceParameters(hw_params, sw_params, FALSE);
/* now, we can save all required data for later use... */ /* now, we can save all required data for later use... */
if ( wwi->hw_params )
snd_pcm_hw_params_free(wwi->hw_params);
snd_pcm_hw_params_malloc(&(wwi->hw_params));
snd_pcm_hw_params_copy(wwi->hw_params, hw_params);
wwi->dwBufferSize = snd_pcm_frames_to_bytes(pcm, buffer_size); wwi->dwBufferSize = snd_pcm_frames_to_bytes(pcm, buffer_size);
wwi->lpQueuePtr = wwi->lpPlayPtr = wwi->lpLoopPtr = NULL; wwi->lpQueuePtr = wwi->lpPlayPtr = wwi->lpLoopPtr = NULL;
wwi->pcm = pcm;
ALSA_InitRingMessage(&wwi->msgRing); ALSA_InitRingMessage(&wwi->msgRing);
...@@ -519,8 +517,10 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -519,8 +517,10 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
CloseHandle(wwi->hStartUpEvent); CloseHandle(wwi->hStartUpEvent);
wwi->hStartUpEvent = NULL; wwi->hStartUpEvent = NULL;
HeapFree( GetProcessHeap(), 0, hw_params );
HeapFree( GetProcessHeap(), 0, sw_params ); HeapFree( GetProcessHeap(), 0, sw_params );
wwi->hw_params = hw_params;
wwi->pcm = pcm;
widNotifyClient(wwi, WIM_OPEN, 0L, 0L); widNotifyClient(wwi, WIM_OPEN, 0L, 0L);
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
...@@ -548,12 +548,12 @@ static DWORD widClose(WORD wDevID) ...@@ -548,12 +548,12 @@ static DWORD widClose(WORD wDevID)
return MMSYSERR_BADDEVICEID; return MMSYSERR_BADDEVICEID;
} }
if (WInDev[wDevID].pcm == NULL) { wwi = &WInDev[wDevID];
if (wwi->pcm == NULL) {
WARN("Requested to close already closed device %d!\n", wDevID); WARN("Requested to close already closed device %d!\n", wDevID);
return MMSYSERR_BADDEVICEID; return MMSYSERR_BADDEVICEID;
} }
wwi = &WInDev[wDevID];
if (wwi->lpQueuePtr) { if (wwi->lpQueuePtr) {
WARN("buffers still playing !\n"); WARN("buffers still playing !\n");
return WAVERR_STILLPLAYING; return WAVERR_STILLPLAYING;
...@@ -563,7 +563,7 @@ static DWORD widClose(WORD wDevID) ...@@ -563,7 +563,7 @@ static DWORD widClose(WORD wDevID)
} }
ALSA_DestroyRingMessage(&wwi->msgRing); ALSA_DestroyRingMessage(&wwi->msgRing);
snd_pcm_hw_params_free(wwi->hw_params); HeapFree( GetProcessHeap(), 0, wwi->hw_params );
wwi->hw_params = NULL; wwi->hw_params = NULL;
snd_pcm_close(wwi->pcm); snd_pcm_close(wwi->pcm);
......
...@@ -576,7 +576,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -576,7 +576,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
WINE_WAVEDEV* wwo; WINE_WAVEDEV* wwo;
snd_pcm_t * pcm = NULL; snd_pcm_t * pcm = NULL;
snd_hctl_t * hctl = NULL; snd_hctl_t * hctl = NULL;
snd_pcm_hw_params_t * hw_params = NULL; snd_pcm_hw_params_t * hw_params;
snd_pcm_sw_params_t * sw_params; snd_pcm_sw_params_t * sw_params;
snd_pcm_access_t access; snd_pcm_access_t access;
snd_pcm_format_t format = -1; snd_pcm_format_t format = -1;
...@@ -680,8 +680,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -680,8 +680,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
} while(0) } while(0)
sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() ); sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() );
snd_pcm_hw_params_malloc(&hw_params); hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() );
if (! hw_params) if (!hw_params || !sw_params)
{ {
retcode = MMSYSERR_NOMEM; retcode = MMSYSERR_NOMEM;
goto errexit; goto errexit;
...@@ -797,11 +797,9 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -797,11 +797,9 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwo->format.Format.nBlockAlign); wwo->format.Format.nBlockAlign);
HeapFree( GetProcessHeap(), 0, sw_params ); HeapFree( GetProcessHeap(), 0, sw_params );
wwo->pcm = pcm;
wwo->hctl = hctl;
if ( wwo->hw_params )
snd_pcm_hw_params_free(wwo->hw_params);
wwo->hw_params = hw_params; wwo->hw_params = hw_params;
wwo->hctl = hctl;
wwo->pcm = pcm;
wodNotifyClient(wwo, WOM_OPEN, 0L, 0L); wodNotifyClient(wwo, WOM_OPEN, 0L, 0L);
return MMSYSERR_NOERROR; return MMSYSERR_NOERROR;
...@@ -816,9 +814,7 @@ errexit: ...@@ -816,9 +814,7 @@ errexit:
snd_hctl_close(hctl); snd_hctl_close(hctl);
} }
if ( hw_params ) HeapFree( GetProcessHeap(), 0, hw_params );
snd_pcm_hw_params_free(hw_params);
HeapFree( GetProcessHeap(), 0, sw_params ); HeapFree( GetProcessHeap(), 0, sw_params );
if (wwo->msgRing.ring_buffer_size > 0) if (wwo->msgRing.ring_buffer_size > 0)
ALSA_DestroyRingMessage(&wwo->msgRing); ALSA_DestroyRingMessage(&wwo->msgRing);
...@@ -841,12 +837,12 @@ static DWORD wodClose(WORD wDevID) ...@@ -841,12 +837,12 @@ static DWORD wodClose(WORD wDevID)
return MMSYSERR_BADDEVICEID; return MMSYSERR_BADDEVICEID;
} }
if (WOutDev[wDevID].pcm == NULL) { wwo = &WOutDev[wDevID];
if (wwo->pcm == NULL) {
WARN("Requested to close already closed device %d!\n", wDevID); WARN("Requested to close already closed device %d!\n", wDevID);
return MMSYSERR_BADDEVICEID; return MMSYSERR_BADDEVICEID;
} }
wwo = &WOutDev[wDevID];
if (wwo->lpQueuePtr) { if (wwo->lpQueuePtr) {
WARN("buffers still playing !\n"); WARN("buffers still playing !\n");
return WAVERR_STILLPLAYING; return WAVERR_STILLPLAYING;
...@@ -856,20 +852,18 @@ static DWORD wodClose(WORD wDevID) ...@@ -856,20 +852,18 @@ static DWORD wodClose(WORD wDevID)
} }
ALSA_DestroyRingMessage(&wwo->msgRing); ALSA_DestroyRingMessage(&wwo->msgRing);
if (wwo->hw_params) HeapFree( GetProcessHeap(), 0, wwo->hw_params );
snd_pcm_hw_params_free(wwo->hw_params);
wwo->hw_params = NULL; wwo->hw_params = NULL;
if (wwo->pcm)
snd_pcm_close(wwo->pcm);
wwo->pcm = NULL;
if (wwo->hctl) if (wwo->hctl)
{ {
snd_hctl_free(wwo->hctl); snd_hctl_free(wwo->hctl);
snd_hctl_close(wwo->hctl); snd_hctl_close(wwo->hctl);
wwo->hctl = NULL;
} }
wwo->hctl = NULL;
snd_pcm_close(wwo->pcm);
wwo->pcm = NULL;
wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L); wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment