Commit 9fce052c authored by Alexandre Julliard's avatar Alexandre Julliard

winealsa.drv: Avoid the alsa alloca macros that cause compiler warnings.

parent cbf06f4d
......@@ -645,11 +645,13 @@ void ALSA_TraceParameters(snd_pcm_hw_params_t * hw_params, snd_pcm_sw_params_t *
else
{
snd_pcm_access_mask_t * acmask;
snd_pcm_access_mask_alloca(&acmask);
acmask = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_access_mask_sizeof());
snd_pcm_hw_params_get_access_mask(hw_params, acmask);
for ( access = SND_PCM_ACCESS_MMAP_INTERLEAVED; access <= SND_PCM_ACCESS_LAST; access++)
if (snd_pcm_access_mask_test(acmask, access))
TRACE("access=%s\n", snd_pcm_access_name(access));
HeapFree( GetProcessHeap(), 0, acmask );
}
if (format >= 0)
......@@ -661,11 +663,12 @@ void ALSA_TraceParameters(snd_pcm_hw_params_t * hw_params, snd_pcm_sw_params_t *
{
snd_pcm_format_mask_t * fmask;
snd_pcm_format_mask_alloca(&fmask);
fmask = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_format_mask_sizeof());
snd_pcm_hw_params_get_format_mask(hw_params, fmask);
for ( format = SND_PCM_FORMAT_S8; format <= SND_PCM_FORMAT_LAST ; format++)
if ( snd_pcm_format_mask_test(fmask, format) )
TRACE("format=%s\n", snd_pcm_format_name(format));
HeapFree( GetProcessHeap(), 0, fmask );
}
do {
......
......@@ -1249,9 +1249,8 @@ LONG ALSA_MidiInit(void)
#if 0 /* Debug purpose */
snd_lib_error_set_handler(error_handler);
#endif
snd_seq_client_info_alloca(&cinfo);
snd_seq_port_info_alloca(&pinfo);
cinfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_seq_client_info_sizeof() );
pinfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_seq_port_info_sizeof() );
/* First, search for all internal midi devices */
snd_seq_client_info_set_client(cinfo, -1);
......@@ -1281,6 +1280,8 @@ LONG ALSA_MidiInit(void)
/* close file and exit */
midiCloseSeq();
HeapFree( GetProcessHeap(), 0, cinfo );
HeapFree( GetProcessHeap(), 0, pinfo );
TRACE("End\n");
#endif
......
......@@ -405,7 +405,9 @@ static void filllines(mixer *mmixer, snd_mixer_elem_t *mastelem, snd_mixer_elem_
static void ALSA_MixerInit(void)
{
int x, mixnum = 0;
snd_ctl_card_info_t *info;
info = HeapAlloc( GetProcessHeap(), 0, snd_ctl_card_info_sizeof());
for (x = 0; x < MAX_MIXERS; ++x)
{
int card, err, capcontrols = 0;
......@@ -413,9 +415,8 @@ static void ALSA_MixerInit(void)
snd_ctl_t *ctl;
snd_mixer_elem_t *elem, *mastelem = NULL, *headelem = NULL, *captelem = NULL, *pcmelem = NULL;
snd_ctl_card_info_t *info = NULL;
snd_ctl_card_info_alloca(&info);
memset(info, 0, snd_ctl_card_info_sizeof());
memset(&mixdev[mixnum], 0, sizeof(*mixdev));
snprintf(cardind, sizeof(cardind), "%d", x);
card = snd_card_get_index(cardind);
......@@ -553,6 +554,7 @@ static void ALSA_MixerInit(void)
snd_mixer_close(mixdev[mixnum].mix);
}
cards = mixnum;
HeapFree( GetProcessHeap(), 0, info );
/* There is no trouble with already assigning callbacks without initialising critsect:
* Callbacks only occur when snd_mixer_handle_events is called (only happens in thread)
......
......@@ -415,9 +415,7 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
snd_pcm_t * pcm;
int err;
int dir;
snd_pcm_hw_params_alloca(&hw_params);
snd_pcm_sw_params_alloca(&sw_params);
DWORD ret;
/* JPW TODO - review this code */
TRACE("(%u, %p, %08X);\n", wDevID, lpDesc, dwFlags);
......@@ -474,6 +472,9 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwi->format.Format.nChannels;
}
hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() );
sw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_sw_params_sizeof() );
snd_pcm_hw_params_any(pcm, hw_params);
#define EXIT_ON_ERROR(f,e,txt) do \
......@@ -482,8 +483,8 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
if ( (err = (f) ) < 0) \
{ \
WARN(txt ": %s\n", snd_strerror(err)); \
snd_pcm_close(pcm); \
return e; \
ret = (e); \
goto error; \
} \
} while(0)
......@@ -511,20 +512,20 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
format = (wwi->format.Format.wBitsPerSample == 32) ? SND_PCM_FORMAT_FLOAT_LE : -1;
} else if (wwi->format.Format.wFormatTag == WAVE_FORMAT_MULAW) {
FIXME("unimplemented format: WAVE_FORMAT_MULAW\n");
snd_pcm_close(pcm);
return WAVERR_BADFORMAT;
ret = WAVERR_BADFORMAT;
goto error;
} else if (wwi->format.Format.wFormatTag == WAVE_FORMAT_ALAW) {
FIXME("unimplemented format: WAVE_FORMAT_ALAW\n");
snd_pcm_close(pcm);
return WAVERR_BADFORMAT;
ret = WAVERR_BADFORMAT;
goto error;
} else if (wwi->format.Format.wFormatTag == WAVE_FORMAT_ADPCM) {
FIXME("unimplemented format: WAVE_FORMAT_ADPCM\n");
snd_pcm_close(pcm);
return WAVERR_BADFORMAT;
ret = WAVERR_BADFORMAT;
goto error;
} else {
ERR("invalid format: %0x04x\n", wwi->format.Format.wFormatTag);
snd_pcm_close(pcm);
return WAVERR_BADFORMAT;
ret = WAVERR_BADFORMAT;
goto error;
}
EXIT_ON_ERROR( snd_pcm_hw_params_set_format(pcm, hw_params, format), WAVERR_BADFORMAT, "unable to set required format");
......@@ -534,13 +535,13 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
err = snd_pcm_hw_params_set_rate_near(pcm, hw_params, &rate, &dir);
if (err < 0) {
WARN("Rate %d Hz not available for playback: %s\n", wwi->format.Format.nSamplesPerSec, snd_strerror(rate));
snd_pcm_close(pcm);
return WAVERR_BADFORMAT;
ret = WAVERR_BADFORMAT;
goto error;
}
if (!ALSA_NearMatch(rate, wwi->format.Format.nSamplesPerSec)) {
WARN("Rate doesn't match (requested %d Hz, got %d Hz)\n", wwi->format.Format.nSamplesPerSec, rate);
snd_pcm_close(pcm);
return WAVERR_BADFORMAT;
ret = WAVERR_BADFORMAT;
goto error;
}
dir=0;
......@@ -598,7 +599,15 @@ static DWORD widOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
CloseHandle(wwi->hStartUpEvent);
wwi->hStartUpEvent = INVALID_HANDLE_VALUE;
HeapFree( GetProcessHeap(), 0, hw_params );
HeapFree( GetProcessHeap(), 0, sw_params );
return widNotifyClient(wwi, WIM_OPEN, 0L, 0L);
error:
snd_pcm_close(pcm);
HeapFree( GetProcessHeap(), 0, hw_params );
HeapFree( GetProcessHeap(), 0, sw_params );
return ret;
}
......
......@@ -81,6 +81,8 @@ static int ALSA_TestDeviceForWine(int card, int device, snd_pcm_stream_t stream
const char *reason = NULL;
unsigned int rrate;
hwparams = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() );
/* Note that the plug: device masks out a lot of info, we want to avoid that */
sprintf(pcmname, "hw:%d,%d", card, device);
retcode = snd_pcm_open(&pcm, pcmname, streamtype, SND_PCM_NONBLOCK);
......@@ -92,8 +94,6 @@ static int ALSA_TestDeviceForWine(int card, int device, snd_pcm_stream_t stream
goto exit;
}
snd_pcm_hw_params_alloca(&hwparams);
retcode = snd_pcm_hw_params_any(pcm, hwparams);
if (retcode < 0)
{
......@@ -136,6 +136,7 @@ static int ALSA_TestDeviceForWine(int card, int device, snd_pcm_stream_t stream
exit:
if (pcm)
snd_pcm_close(pcm);
HeapFree( GetProcessHeap(), 0, hwparams );
if (retcode != 0 && retcode != (-1 * ENOENT))
TRACE("Discarding card %d/device %d: %s [%d(%s)]\n", card, device, reason, retcode, snd_strerror(retcode));
......@@ -252,21 +253,22 @@ static int ALSA_ComputeCaps(snd_ctl_t *ctl, snd_pcm_t *pcm,
unsigned int ratemax = 0;
unsigned int chmin = 0;
unsigned int chmax = 0;
int dir = 0;
int rc, dir = 0;
hw_params = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_hw_params_sizeof() );
fmask = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_format_mask_sizeof() );
acmask = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_access_mask_sizeof() );
snd_pcm_hw_params_alloca(&hw_params);
ALSA_RETURN_ONFAIL(snd_pcm_hw_params_any(pcm, hw_params));
if ((rc = snd_pcm_hw_params_any(pcm, hw_params)) < 0) goto done;
snd_pcm_format_mask_alloca(&fmask);
snd_pcm_hw_params_get_format_mask(hw_params, fmask);
snd_pcm_access_mask_alloca(&acmask);
ALSA_RETURN_ONFAIL(snd_pcm_hw_params_get_access_mask(hw_params, acmask));
if ((rc = snd_pcm_hw_params_get_access_mask(hw_params, acmask)) < 0) goto done;
ALSA_RETURN_ONFAIL(snd_pcm_hw_params_get_rate_min(hw_params, &ratemin, &dir));
ALSA_RETURN_ONFAIL(snd_pcm_hw_params_get_rate_max(hw_params, &ratemax, &dir));
ALSA_RETURN_ONFAIL(snd_pcm_hw_params_get_channels_min(hw_params, &chmin));
ALSA_RETURN_ONFAIL(snd_pcm_hw_params_get_channels_max(hw_params, &chmax));
if ((rc = snd_pcm_hw_params_get_rate_min(hw_params, &ratemin, &dir)) < 0) goto done;
if ((rc = snd_pcm_hw_params_get_rate_max(hw_params, &ratemax, &dir)) < 0) goto done;
if ((rc = snd_pcm_hw_params_get_channels_min(hw_params, &chmin)) < 0) goto done;
if ((rc = snd_pcm_hw_params_get_channels_max(hw_params, &chmax)) < 0) goto done;
#define X(r,v) \
if ( (r) >= ratemin && ( (r) <= ratemax || ratemax == -1) ) \
......@@ -357,7 +359,14 @@ static int ALSA_ComputeCaps(snd_ctl_t *ctl, snd_pcm_t *pcm,
WAVE_FORMAT_48S16 | WAVE_FORMAT_96S16) )
*flags |= DSCAPS_PRIMARY16BIT;
return(0);
rc = 0;
done:
if (rc < 0) ERR("failed: %s(%d)\n", snd_strerror(rc), rc);
HeapFree( GetProcessHeap(), 0, hw_params );
HeapFree( GetProcessHeap(), 0, fmask );
HeapFree( GetProcessHeap(), 0, acmask );
return rc;
}
/*----------------------------------------------------------------------------
......@@ -375,14 +384,22 @@ static int ALSA_ComputeCaps(snd_ctl_t *ctl, snd_pcm_t *pcm,
static int ALSA_AddCommonDevice(snd_ctl_t *ctl, snd_pcm_t *pcm, const char *pcmname, WINE_WAVEDEV *ww)
{
snd_pcm_info_t *infop;
int rc;
snd_pcm_info_alloca(&infop);
ALSA_RETURN_ONFAIL(snd_pcm_info(pcm, infop));
infop = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, snd_pcm_info_sizeof() );
if ((rc = snd_pcm_info(pcm, infop)) < 0)
{
HeapFree( GetProcessHeap(), 0, infop );
return rc;
}
if (pcm && pcmname)
ww->pcmname = ALSA_strdup(pcmname);
else
{
HeapFree( GetProcessHeap(), 0, infop );
return -1;
}
if (ctl && snd_ctl_name(ctl))
ww->ctlname = ALSA_strdup(snd_ctl_name(ctl));
......@@ -401,6 +418,7 @@ static int ALSA_AddCommonDevice(snd_ctl_t *ctl, snd_pcm_t *pcm, const char *pcmn
ww->ds_caps.dwMaxSecondarySampleRate = DSBFREQUENCY_MAX;
ww->ds_caps.dwPrimaryBuffers = 1;
HeapFree( GetProcessHeap(), 0, infop );
return 0;
}
......
......@@ -579,8 +579,6 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
int dir=0;
DWORD retcode = 0;
snd_pcm_sw_params_alloca(&sw_params);
TRACE("(%u, %p, %08X);\n", wDevID, lpDesc, dwFlags);
if (lpDesc == NULL) {
WARN("Invalid Parameter !\n");
......@@ -670,6 +668,7 @@ 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)
{
......@@ -801,6 +800,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
wwo->format.Format.nSamplesPerSec, wwo->format.Format.nChannels,
wwo->format.Format.nBlockAlign);
HeapFree( GetProcessHeap(), 0, sw_params );
wwo->pcm = pcm;
wwo->hctl = hctl;
if ( wwo->hw_params )
......@@ -822,6 +822,7 @@ errexit:
if ( hw_params )
snd_pcm_hw_params_free(hw_params);
HeapFree( GetProcessHeap(), 0, sw_params );
if (wwo->msgRing.ring_buffer_size > 0)
ALSA_DestroyRingMessage(&wwo->msgRing);
......
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