winealsa: Favour HeapAlloc() over malloc().
This commit is contained in:
parent
8df872535e
commit
e52f5773e1
|
@ -369,7 +369,6 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
return MMSYSERR_ALLOCATED;
|
||||
}
|
||||
|
||||
wwi->pcm = 0;
|
||||
flags = SND_PCM_NONBLOCK;
|
||||
|
||||
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)
|
|||
|
||||
hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_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);
|
||||
|
||||
#define EXIT_ON_ERROR(f,e,txt) do \
|
||||
|
@ -488,14 +491,9 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
ALSA_TraceParameters(hw_params, sw_params, FALSE);
|
||||
|
||||
/* 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->lpQueuePtr = wwi->lpPlayPtr = wwi->lpLoopPtr = NULL;
|
||||
wwi->pcm = pcm;
|
||||
|
||||
ALSA_InitRingMessage(&wwi->msgRing);
|
||||
|
||||
|
@ -519,8 +517,10 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
CloseHandle(wwi->hStartUpEvent);
|
||||
wwi->hStartUpEvent = NULL;
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, hw_params );
|
||||
HeapFree( GetProcessHeap(), 0, sw_params );
|
||||
wwi->hw_params = hw_params;
|
||||
wwi->pcm = pcm;
|
||||
|
||||
widNotifyClient(wwi, WIM_OPEN, 0L, 0L);
|
||||
return MMSYSERR_NOERROR;
|
||||
|
||||
|
@ -548,12 +548,12 @@ static DWORD widClose(WORD wDevID)
|
|||
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);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
|
||||
wwi = &WInDev[wDevID];
|
||||
if (wwi->lpQueuePtr) {
|
||||
WARN("buffers still playing !\n");
|
||||
return WAVERR_STILLPLAYING;
|
||||
|
@ -563,7 +563,7 @@ static DWORD widClose(WORD wDevID)
|
|||
}
|
||||
ALSA_DestroyRingMessage(&wwi->msgRing);
|
||||
|
||||
snd_pcm_hw_params_free(wwi->hw_params);
|
||||
HeapFree( GetProcessHeap(), 0, wwi->hw_params );
|
||||
wwi->hw_params = NULL;
|
||||
|
||||
snd_pcm_close(wwi->pcm);
|
||||
|
|
|
@ -576,7 +576,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
WINE_WAVEDEV* wwo;
|
||||
snd_pcm_t * pcm = 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_access_t access;
|
||||
snd_pcm_format_t format = -1;
|
||||
|
@ -680,8 +680,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
} while(0)
|
||||
|
||||
sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() );
|
||||
snd_pcm_hw_params_malloc(&hw_params);
|
||||
if (! hw_params)
|
||||
hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() );
|
||||
if (!hw_params || !sw_params)
|
||||
{
|
||||
retcode = MMSYSERR_NOMEM;
|
||||
goto errexit;
|
||||
|
@ -797,11 +797,9 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
wwo->format.Format.nBlockAlign);
|
||||
|
||||
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->hctl = hctl;
|
||||
wwo->pcm = pcm;
|
||||
|
||||
wodNotifyClient(wwo, WOM_OPEN, 0L, 0L);
|
||||
return MMSYSERR_NOERROR;
|
||||
|
@ -816,9 +814,7 @@ errexit:
|
|||
snd_hctl_close(hctl);
|
||||
}
|
||||
|
||||
if ( hw_params )
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, hw_params );
|
||||
HeapFree( GetProcessHeap(), 0, sw_params );
|
||||
if (wwo->msgRing.ring_buffer_size > 0)
|
||||
ALSA_DestroyRingMessage(&wwo->msgRing);
|
||||
|
@ -841,12 +837,12 @@ static DWORD wodClose(WORD wDevID)
|
|||
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);
|
||||
return MMSYSERR_BADDEVICEID;
|
||||
}
|
||||
|
||||
wwo = &WOutDev[wDevID];
|
||||
if (wwo->lpQueuePtr) {
|
||||
WARN("buffers still playing !\n");
|
||||
return WAVERR_STILLPLAYING;
|
||||
|
@ -856,20 +852,18 @@ static DWORD wodClose(WORD wDevID)
|
|||
}
|
||||
ALSA_DestroyRingMessage(&wwo->msgRing);
|
||||
|
||||
if (wwo->hw_params)
|
||||
snd_pcm_hw_params_free(wwo->hw_params);
|
||||
HeapFree( GetProcessHeap(), 0, wwo->hw_params );
|
||||
wwo->hw_params = NULL;
|
||||
|
||||
if (wwo->pcm)
|
||||
snd_pcm_close(wwo->pcm);
|
||||
wwo->pcm = NULL;
|
||||
|
||||
if (wwo->hctl)
|
||||
{
|
||||
snd_hctl_free(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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue