[WINEALSA] handle cleanup
Robert Reif
reif at earthlink.net
Sat Mar 19 08:58:38 CST 2005
Clean up handle usage.
-------------- next part --------------
Index: dlls/winmm/winealsa/audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/winealsa/audio.c,v
retrieving revision 1.66
diff -u -p -r1.66 audio.c
--- dlls/winmm/winealsa/audio.c 18 Mar 2005 10:26:05 -0000 1.66
+++ dlls/winmm/winealsa/audio.c 19 Mar 2005 14:40:26 -0000
@@ -156,8 +156,7 @@ typedef struct {
/* ALSA information (ALSA 0.9/1.x uses two different devices for playback/capture) */
char* device;
char interface_name[64];
- snd_pcm_t* p_handle; /* handle to ALSA playback device */
- snd_pcm_t* c_handle; /* handle to ALSA capture device */
+ snd_pcm_t* handle; /* handle to ALSA playback device */
snd_pcm_hw_params_t * hw_params; /* ALSA Hw params */
snd_ctl_t * ctl; /* control handle for the playback volume */
@@ -203,8 +202,7 @@ typedef struct {
/* ALSA information (ALSA 0.9/1.x uses two different devices for playback/capture) */
char* device;
char interface_name[64];
- snd_pcm_t* p_handle; /* handle to ALSA playback device */
- snd_pcm_t* c_handle; /* handle to ALSA capture device */
+ snd_pcm_t* handle; /* handle to ALSA capture device */
snd_pcm_hw_params_t * hw_params; /* ALSA Hw params */
snd_pcm_sframes_t (*read)(snd_pcm_t *, void *, snd_pcm_uframes_t );
@@ -479,15 +477,15 @@ static int ALSA_InitializeVolumeCtl(WINE
static int ALSA_XRUNRecovery(WINE_WAVEOUT * wwo, int err)
{
if (err == -EPIPE) { /* under-run */
- err = snd_pcm_prepare(wwo->p_handle);
+ err = snd_pcm_prepare(wwo->handle);
if (err < 0)
ERR( "underrun recovery failed. prepare failed: %s\n", snd_strerror(err));
return 0;
} else if (err == -ESTRPIPE) {
- while ((err = snd_pcm_resume(wwo->p_handle)) == -EAGAIN)
+ while ((err = snd_pcm_resume(wwo->handle)) == -EAGAIN)
sleep(1); /* wait until the suspend flag is released */
if (err < 0) {
- err = snd_pcm_prepare(wwo->p_handle);
+ err = snd_pcm_prepare(wwo->handle);
if (err < 0)
ERR("recovery from suspend failed, prepare failed: %s\n", snd_strerror(err));
}
@@ -1136,10 +1134,10 @@ static DWORD wodNotifyClient(WINE_WAVEOU
static BOOL wodUpdatePlayedTotal(WINE_WAVEOUT* wwo, snd_pcm_status_t* ps)
{
snd_pcm_sframes_t delay = 0;
- snd_pcm_delay(wwo->p_handle, &delay);
- if (snd_pcm_state(wwo->p_handle) != SND_PCM_STATE_RUNNING)
+ snd_pcm_delay(wwo->handle, &delay);
+ if (snd_pcm_state(wwo->handle) != SND_PCM_STATE_RUNNING)
delay=0;
- wwo->dwPlayedTotal = wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->p_handle, delay);
+ wwo->dwPlayedTotal = wwo->dwWrittenTotal - snd_pcm_frames_to_bytes(wwo->handle, delay);
return TRUE;
}
@@ -1252,18 +1250,18 @@ static int wodPlayer_WriteMaxFrags(WINE_
{
/* Only attempt to write to free frames */
LPWAVEHDR lpWaveHdr = wwo->lpPlayPtr;
- DWORD dwLength = snd_pcm_bytes_to_frames(wwo->p_handle, lpWaveHdr->dwBufferLength - wwo->dwPartialOffset);
+ DWORD dwLength = snd_pcm_bytes_to_frames(wwo->handle, lpWaveHdr->dwBufferLength - wwo->dwPartialOffset);
int toWrite = min(dwLength, *frames);
int written;
TRACE("Writing wavehdr %p.%lu[%lu]\n", lpWaveHdr, wwo->dwPartialOffset, lpWaveHdr->dwBufferLength);
if (toWrite > 0) {
- written = (wwo->write)(wwo->p_handle, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
+ written = (wwo->write)(wwo->handle, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
if ( written < 0) {
/* XRUN occurred. let's try to recover */
ALSA_XRUNRecovery(wwo, written);
- written = (wwo->write)(wwo->p_handle, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
+ written = (wwo->write)(wwo->handle, lpWaveHdr->lpData + wwo->dwPartialOffset, toWrite);
}
if (written <= 0) {
/* still in error */
@@ -1273,7 +1271,7 @@ static int wodPlayer_WriteMaxFrags(WINE_
} else
written = 0;
- wwo->dwPartialOffset += snd_pcm_frames_to_bytes(wwo->p_handle, written);
+ wwo->dwPartialOffset += snd_pcm_frames_to_bytes(wwo->handle, written);
if ( wwo->dwPartialOffset >= lpWaveHdr->dwBufferLength) {
/* this will be used to check if the given wave header has been fully played or not... */
wwo->dwPartialOffset = lpWaveHdr->dwBufferLength;
@@ -1281,7 +1279,7 @@ static int wodPlayer_WriteMaxFrags(WINE_
wodPlayer_PlayPtrNext(wwo);
}
*frames -= written;
- wwo->dwWrittenTotal += snd_pcm_frames_to_bytes(wwo->p_handle, written);
+ wwo->dwWrittenTotal += snd_pcm_frames_to_bytes(wwo->handle, written);
TRACE("dwWrittenTotal=%lu\n", wwo->dwWrittenTotal);
return written;
@@ -1376,19 +1374,19 @@ static void wodPlayer_Reset(WINE_WAVEOUT
int err;
/* flush all possible output */
- wait_for_poll(wwo->p_handle, wwo->ufds, wwo->count);
+ wait_for_poll(wwo->handle, wwo->ufds, wwo->count);
wodUpdatePlayedTotal(wwo, NULL);
/* updates current notify list */
wodPlayer_NotifyCompletions(wwo, FALSE);
- if ( (err = snd_pcm_drop(wwo->p_handle)) < 0) {
+ if ( (err = snd_pcm_drop(wwo->handle)) < 0) {
FIXME("flush: %s\n", snd_strerror(err));
wwo->hThread = 0;
wwo->state = WINE_WS_STOPPED;
ExitThread(-1);
}
- if ( (err = snd_pcm_prepare(wwo->p_handle)) < 0 )
+ if ( (err = snd_pcm_prepare(wwo->handle)) < 0 )
ERR("pcm prepare failed: %s\n", snd_strerror(err));
/* remove any buffer */
@@ -1436,9 +1434,9 @@ static void wodPlayer_ProcessMessages(WI
switch (msg) {
case WINE_WM_PAUSING:
- if ( snd_pcm_state(wwo->p_handle) == SND_PCM_STATE_RUNNING )
+ if ( snd_pcm_state(wwo->handle) == SND_PCM_STATE_RUNNING )
{
- err = snd_pcm_pause(wwo->p_handle, 1);
+ err = snd_pcm_pause(wwo->handle, 1);
if ( err < 0 )
ERR("pcm_pause failed: %s\n", snd_strerror(err));
}
@@ -1448,9 +1446,9 @@ static void wodPlayer_ProcessMessages(WI
case WINE_WM_RESTARTING:
if (wwo->state == WINE_WS_PAUSED)
{
- if ( snd_pcm_state(wwo->p_handle) == SND_PCM_STATE_PAUSED )
+ if ( snd_pcm_state(wwo->handle) == SND_PCM_STATE_PAUSED )
{
- err = snd_pcm_pause(wwo->p_handle, 0);
+ err = snd_pcm_pause(wwo->handle, 0);
if ( err < 0 )
ERR("pcm_pause failed: %s\n", snd_strerror(err));
}
@@ -1512,7 +1510,7 @@ static DWORD wodPlayer_FeedDSP(WINE_WAVE
DWORD availInQ;
wodUpdatePlayedTotal(wwo, NULL);
- availInQ = snd_pcm_avail_update(wwo->p_handle);
+ availInQ = snd_pcm_avail_update(wwo->handle);
#if 0
/* input queue empty and output buffer with less than one fragment to play */
@@ -1655,7 +1653,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVE
/* not supported, ignore it */
dwFlags &= ~WAVE_DIRECTSOUND;
- wwo->p_handle = 0;
+ wwo->handle = 0;
flags = SND_PCM_NONBLOCK;
#if 0
if ( dwFlags & WAVE_DIRECTSOUND )
@@ -1781,13 +1779,13 @@ static DWORD wodOpen(WORD wDevID, LPWAVE
wwo->dwBufferSize = buffer_size;
wwo->lpQueuePtr = wwo->lpPlayPtr = wwo->lpLoopPtr = NULL;
- wwo->p_handle = pcm;
+ wwo->handle = pcm;
wwo->dwPlayedTotal = wwo->dwWrittenTotal = 0;
wwo->dwPartialOffset = 0;
ALSA_InitRingMessage(&wwo->msgRing);
- wwo->count = snd_pcm_poll_descriptors_count (wwo->p_handle);
+ wwo->count = snd_pcm_poll_descriptors_count (wwo->handle);
if (wwo->count <= 0) {
ERR("Invalid poll descriptors count\n");
return MMSYSERR_ERROR;
@@ -1798,7 +1796,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVE
ERR("No enough memory\n");
return MMSYSERR_NOMEM;
}
- if ((err = snd_pcm_poll_descriptors(wwo->p_handle, wwo->ufds, wwo->count)) < 0) {
+ if ((err = snd_pcm_poll_descriptors(wwo->handle, wwo->ufds, wwo->count)) < 0) {
ERR("Unable to obtain poll descriptors for playback: %s\n", snd_strerror(err));
return MMSYSERR_ERROR;
}
@@ -1814,7 +1812,7 @@ static DWORD wodOpen(WORD wDevID, LPWAVE
}
wwo->hStartUpEvent = INVALID_HANDLE_VALUE;
- TRACE("handle=%08lx \n", (DWORD)wwo->p_handle);
+ TRACE("handle=%08lx \n", (DWORD)wwo->handle);
/* if (wwo->dwFragmentSize % wwo->format.Format.nBlockAlign)
ERR("Fragment doesn't contain an integral number of data blocks\n");
*/
@@ -1837,7 +1835,7 @@ static DWORD wodClose(WORD wDevID)
TRACE("(%u);\n", wDevID);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -1855,8 +1853,8 @@ static DWORD wodClose(WORD wDevID)
snd_pcm_hw_params_free(wwo->hw_params);
wwo->hw_params = NULL;
- snd_pcm_close(wwo->p_handle);
- wwo->p_handle = NULL;
+ snd_pcm_close(wwo->handle);
+ wwo->handle = NULL;
ret = wodNotifyClient(wwo, WOM_CLOSE, 0L, 0L);
}
@@ -1875,7 +1873,7 @@ static DWORD wodWrite(WORD wDevID, LPWAV
TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
/* first, do the sanity checks... */
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad dev ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -1943,7 +1941,7 @@ static DWORD wodPause(WORD wDevID)
{
TRACE("(%u);!\n", wDevID);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -1960,7 +1958,7 @@ static DWORD wodRestart(WORD wDevID)
{
TRACE("(%u);\n", wDevID);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -1984,7 +1982,7 @@ static DWORD wodReset(WORD wDevID)
{
TRACE("(%u);\n", wDevID);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -2003,7 +2001,7 @@ static DWORD wodGetPosition(WORD wDevID,
TRACE("(%u, %p, %lu);\n", wDevID, lpTime, uSize);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -2023,7 +2021,7 @@ static DWORD wodBreakLoop(WORD wDevID)
{
TRACE("(%u);\n", wDevID);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -2042,7 +2040,7 @@ static DWORD wodGetVolume(WORD wDevID, L
long min, max;
TRACE("(%u, %p);\n", wDevID, lpdwVol);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -2092,7 +2090,7 @@ static DWORD wodSetVolume(WORD wDevID, D
long min, max;
TRACE("(%u, %08lX);\n", wDevID, dwParam);
- if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEOUTDRV || WOutDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -2244,21 +2242,21 @@ struct IDsDriverBufferImpl
static void DSDB_CheckXRUN(IDsDriverBufferImpl* pdbi)
{
WINE_WAVEOUT * wwo = &(WOutDev[pdbi->drv->wDevID]);
- snd_pcm_state_t state = snd_pcm_state(wwo->p_handle);
+ snd_pcm_state_t state = snd_pcm_state(wwo->handle);
if ( state == SND_PCM_STATE_XRUN )
{
- int err = snd_pcm_prepare(wwo->p_handle);
+ int err = snd_pcm_prepare(wwo->handle);
TRACE("xrun occurred\n");
if ( err < 0 )
ERR("recovery from xrun failed, prepare failed: %s\n", snd_strerror(err));
}
else if ( state == SND_PCM_STATE_SUSPENDED )
{
- int err = snd_pcm_resume(wwo->p_handle);
+ int err = snd_pcm_resume(wwo->handle);
TRACE("recovery from suspension occurred\n");
if (err < 0 && err != -EAGAIN){
- err = snd_pcm_prepare(wwo->p_handle);
+ err = snd_pcm_prepare(wwo->handle);
if (err < 0)
ERR("recovery from suspend failed, prepare failed: %s\n", snd_strerror(err));
}
@@ -2275,14 +2273,14 @@ static void DSDB_MMAPCopy(IDsDriverBuffe
int err;
int dir=0;
- if ( !pdbi->mmap_buffer || !wwo->hw_params || !wwo->p_handle)
+ if ( !pdbi->mmap_buffer || !wwo->hw_params || !wwo->handle)
return;
err = snd_pcm_hw_params_get_channels(wwo->hw_params, &channels);
err = snd_pcm_hw_params_get_format(wwo->hw_params, &format);
dir=0;
err = snd_pcm_hw_params_get_period_size(wwo->hw_params, &period_size, &dir);
- avail = snd_pcm_avail_update(wwo->p_handle);
+ avail = snd_pcm_avail_update(wwo->handle);
DSDB_CheckXRUN(pdbi);
@@ -2299,16 +2297,16 @@ static void DSDB_MMAPCopy(IDsDriverBuffe
EnterCriticalSection(&pdbi->mmap_crst);
- snd_pcm_mmap_begin(wwo->p_handle, &areas, &ofs, &frames);
+ snd_pcm_mmap_begin(wwo->handle, &areas, &ofs, &frames);
snd_pcm_areas_copy(areas, ofs, pdbi->mmap_areas, ofs, channels, frames, format);
- err = snd_pcm_mmap_commit(wwo->p_handle, ofs, frames);
+ err = snd_pcm_mmap_commit(wwo->handle, ofs, frames);
LeaveCriticalSection(&pdbi->mmap_crst);
if ( err != (snd_pcm_sframes_t) frames)
ERR("mmap partially failed.\n");
- avail = snd_pcm_avail_update(wwo->p_handle);
+ avail = snd_pcm_avail_update(wwo->handle);
}
}
@@ -2346,7 +2344,7 @@ static int DSDB_CreateMMAP(IDsDriverBuff
snd_pcm_format_name(format), frames, channels, bits_per_sample, bits_per_frame);
pdbi->mmap_buflen_frames = frames;
- pdbi->mmap_buflen_bytes = snd_pcm_frames_to_bytes( wwo->p_handle, frames );
+ pdbi->mmap_buflen_bytes = snd_pcm_frames_to_bytes( wwo->handle, frames );
pdbi->mmap_buffer = HeapAlloc(GetProcessHeap(),0,pdbi->mmap_buflen_bytes);
if (!pdbi->mmap_buffer)
return DSERR_OUTOFMEMORY;
@@ -2371,7 +2369,7 @@ static int DSDB_CreateMMAP(IDsDriverBuff
InitializeCriticalSection(&pdbi->mmap_crst);
- err = snd_async_add_pcm_handler(&pdbi->mmap_async_handler, wwo->p_handle, DSDB_PCMCallback, pdbi);
+ err = snd_async_add_pcm_handler(&pdbi->mmap_async_handler, wwo->handle, DSDB_PCMCallback, pdbi);
if ( err < 0 )
{
ERR("add_pcm_handler failed. reason: %s\n", snd_strerror(err));
@@ -2497,18 +2495,18 @@ static HRESULT WINAPI IDsDriverBufferImp
dir=0;
err = snd_pcm_hw_params_get_period_size(wwo->hw_params, &period_size, &dir);
- if (wwo->p_handle == NULL) return DSERR_GENERIC;
+ if (wwo->handle == NULL) return DSERR_GENERIC;
/** we need to track down buffer underruns */
DSDB_CheckXRUN(This);
EnterCriticalSection(&This->mmap_crst);
/* FIXME: snd_pcm_mmap_hw_ptr() should not be accessed by a user app. */
/* It will NOT return what why want anyway. */
- hw_ptr = _snd_pcm_mmap_hw_ptr(wwo->p_handle);
+ hw_ptr = _snd_pcm_mmap_hw_ptr(wwo->handle);
if (lpdwPlay)
- *lpdwPlay = snd_pcm_frames_to_bytes(wwo->p_handle, hw_ptr/ period_size * period_size) % This->mmap_buflen_bytes;
+ *lpdwPlay = snd_pcm_frames_to_bytes(wwo->handle, hw_ptr/ period_size * period_size) % This->mmap_buflen_bytes;
if (lpdwWrite)
- *lpdwWrite = snd_pcm_frames_to_bytes(wwo->p_handle, (hw_ptr / period_size + 1) * period_size ) % This->mmap_buflen_bytes;
+ *lpdwWrite = snd_pcm_frames_to_bytes(wwo->handle, (hw_ptr / period_size + 1) * period_size ) % This->mmap_buflen_bytes;
LeaveCriticalSection(&This->mmap_crst);
TRACE("hw_ptr=0x%08x, playpos=%ld, writepos=%ld\n", (unsigned int)hw_ptr, lpdwPlay?*lpdwPlay:-1, lpdwWrite?*lpdwWrite:-1);
@@ -2524,18 +2522,18 @@ static HRESULT WINAPI IDsDriverBufferImp
TRACE("(%p,%lx,%lx,%lx)\n",iface,dwRes1,dwRes2,dwFlags);
- if (wwo->p_handle == NULL) return DSERR_GENERIC;
+ if (wwo->handle == NULL) return DSERR_GENERIC;
- state = snd_pcm_state(wwo->p_handle);
+ state = snd_pcm_state(wwo->handle);
if ( state == SND_PCM_STATE_SETUP )
{
- err = snd_pcm_prepare(wwo->p_handle);
- state = snd_pcm_state(wwo->p_handle);
+ err = snd_pcm_prepare(wwo->handle);
+ state = snd_pcm_state(wwo->handle);
}
if ( state == SND_PCM_STATE_PREPARED )
{
DSDB_MMAPCopy(This);
- err = snd_pcm_start(wwo->p_handle);
+ err = snd_pcm_start(wwo->handle);
}
return DS_OK;
}
@@ -2550,7 +2548,7 @@ static HRESULT WINAPI IDsDriverBufferImp
TRACE("(%p)\n",iface);
- if (wwo->p_handle == NULL) return DSERR_GENERIC;
+ if (wwo->handle == NULL) return DSERR_GENERIC;
/* ring buffer wrap up detection */
IDsDriverBufferImpl_GetPosition(iface, &play, &write);
@@ -2560,7 +2558,7 @@ static HRESULT WINAPI IDsDriverBufferImp
return DS_OK;
}
- if ( ( err = snd_pcm_drop(wwo->p_handle)) < 0 )
+ if ( ( err = snd_pcm_drop(wwo->handle)) < 0 )
{
ERR("error while stopping pcm: %s\n", snd_strerror(err));
return DSERR_GENERIC;
@@ -2872,7 +2870,7 @@ static DWORD CALLBACK widRecorder(LPVOID
/* make sleep time to be # of ms to output a period */
dwSleepTime = (1024/*wwi-dwPeriodSize => overrun!*/ * 1000) / wwi->format.Format.nAvgBytesPerSec;
- frames_per_period = snd_pcm_bytes_to_frames(wwi->p_handle, wwi->dwPeriodSize);
+ frames_per_period = snd_pcm_bytes_to_frames(wwi->handle, wwi->dwPeriodSize);
TRACE("sleeptime=%ld ms\n", dwSleepTime);
for (;;) {
@@ -2889,8 +2887,8 @@ static DWORD CALLBACK widRecorder(LPVOID
lpWaveHdr = wwi->lpQueuePtr;
/* read all the fragments accumulated so far */
- frames = snd_pcm_avail_update(wwi->p_handle);
- bytes = snd_pcm_frames_to_bytes(wwi->p_handle, frames);
+ frames = snd_pcm_avail_update(wwi->handle);
+ bytes = snd_pcm_frames_to_bytes(wwi->handle, frames);
TRACE("frames = %ld bytes = %ld\n", frames, bytes);
periods = bytes / wwi->dwPeriodSize;
while ((periods > 0) && (wwi->lpQueuePtr))
@@ -2901,8 +2899,8 @@ static DWORD CALLBACK widRecorder(LPVOID
if (lpWaveHdr->dwBufferLength - lpWaveHdr->dwBytesRecorded >= wwi->dwPeriodSize)
{
/* directly read fragment in wavehdr */
- read = wwi->read(wwi->p_handle, lpWaveHdr->lpData + lpWaveHdr->dwBytesRecorded, frames_per_period);
- bytesRead = snd_pcm_frames_to_bytes(wwi->p_handle, read);
+ read = wwi->read(wwi->handle, lpWaveHdr->lpData + lpWaveHdr->dwBytesRecorded, frames_per_period);
+ bytesRead = snd_pcm_frames_to_bytes(wwi->handle, read);
TRACE("bytesRead=%ld (direct)\n", bytesRead);
if (bytesRead != (DWORD) -1)
@@ -2935,8 +2933,8 @@ static DWORD CALLBACK widRecorder(LPVOID
else
{
/* read the fragment in a local buffer */
- read = wwi->read(wwi->p_handle, buffer, frames_per_period);
- bytesRead = snd_pcm_frames_to_bytes(wwi->p_handle, read);
+ read = wwi->read(wwi->handle, buffer, frames_per_period);
+ bytesRead = snd_pcm_frames_to_bytes(wwi->handle, read);
pOffset = buffer;
TRACE("bytesRead=%ld (local)\n", bytesRead);
@@ -3029,7 +3027,7 @@ static DWORD CALLBACK widRecorder(LPVOID
break;
case WINE_WM_STARTING:
wwi->state = WINE_WS_PLAYING;
- snd_pcm_start(wwi->p_handle);
+ snd_pcm_start(wwi->handle);
SetEvent(ev);
break;
case WINE_WM_HEADER:
@@ -3046,7 +3044,7 @@ static DWORD CALLBACK widRecorder(LPVOID
case WINE_WM_STOPPING:
if (wwi->state != WINE_WS_STOPPED)
{
- snd_pcm_drain(wwi->p_handle);
+ snd_pcm_drain(wwi->handle);
/* read any headers in queue */
widRecorder_ReadHeaders(wwi);
@@ -3069,7 +3067,7 @@ static DWORD CALLBACK widRecorder(LPVOID
case WINE_WM_RESETTING:
if (wwi->state != WINE_WS_STOPPED)
{
- snd_pcm_drain(wwi->p_handle);
+ snd_pcm_drain(wwi->handle);
}
wwi->state = WINE_WS_STOPPED;
wwi->dwTotalRecorded = 0;
@@ -3165,7 +3163,7 @@ static DWORD widOpen(WORD wDevID, LPWAVE
/* not supported, ignore it */
dwFlags &= ~WAVE_DIRECTSOUND;
- wwi->p_handle = 0;
+ wwi->handle = 0;
flags = SND_PCM_NONBLOCK;
#if 0
if ( dwFlags & WAVE_DIRECTSOUND )
@@ -3293,11 +3291,11 @@ static DWORD widOpen(WORD wDevID, LPWAVE
wwi->dwBufferSize = buffer_size;
wwi->lpQueuePtr = wwi->lpPlayPtr = wwi->lpLoopPtr = NULL;
- wwi->p_handle = pcm;
+ wwi->handle = pcm;
ALSA_InitRingMessage(&wwi->msgRing);
- wwi->count = snd_pcm_poll_descriptors_count (wwi->p_handle);
+ wwi->count = snd_pcm_poll_descriptors_count (wwi->handle);
if (wwi->count <= 0) {
ERR("Invalid poll descriptors count\n");
return MMSYSERR_ERROR;
@@ -3308,7 +3306,7 @@ static DWORD widOpen(WORD wDevID, LPWAVE
ERR("No enough memory\n");
return MMSYSERR_NOMEM;
}
- if ((err = snd_pcm_poll_descriptors(wwi->p_handle, wwi->ufds, wwi->count)) < 0) {
+ if ((err = snd_pcm_poll_descriptors(wwi->handle, wwi->ufds, wwi->count)) < 0) {
ERR("Unable to obtain poll descriptors for playback: %s\n", snd_strerror(err));
return MMSYSERR_ERROR;
}
@@ -3348,7 +3346,7 @@ static DWORD widClose(WORD wDevID)
TRACE("(%u);\n", wDevID);
- if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].handle == NULL) {
WARN("bad device ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -3366,8 +3364,8 @@ static DWORD widClose(WORD wDevID)
snd_pcm_hw_params_free(wwi->hw_params);
wwi->hw_params = NULL;
- snd_pcm_close(wwi->p_handle);
- wwi->p_handle = NULL;
+ snd_pcm_close(wwi->handle);
+ wwi->handle = NULL;
ret = widNotifyClient(wwi, WIM_CLOSE, 0L, 0L);
}
@@ -3385,7 +3383,7 @@ static DWORD widAddBuffer(WORD wDevID, L
TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
/* first, do the sanity checks... */
- if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].handle == NULL) {
WARN("bad dev ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -3455,7 +3453,7 @@ static DWORD widStart(WORD wDevID, LPWAV
TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
/* first, do the sanity checks... */
- if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].handle == NULL) {
WARN("bad dev ID !\n");
return MMSYSERR_BADDEVICEID;
}
@@ -3476,7 +3474,7 @@ static DWORD widStop(WORD wDevID, LPWAVE
TRACE("(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
/* first, do the sanity checks... */
- if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].p_handle == NULL) {
+ if (wDevID >= MAX_WAVEINDRV || WInDev[wDevID].handle == NULL) {
WARN("bad dev ID !\n");
return MMSYSERR_BADDEVICEID;
}
More information about the wine-patches
mailing list