Commit eba8cee5 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Handle errors for IDsDriver_GetPosition.

Report DSERR_UNINITIALIZED on non-opened WineOSS audio device.
parent 247a94f6
......@@ -1295,10 +1295,14 @@ static DWORD WINAPI IDirectSoundBufferImpl_Release(LPDIRECTSOUNDBUFFER iface) {
static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(
LPDIRECTSOUNDBUFFER iface,LPDWORD playpos,LPDWORD writepos
) {
HRESULT hres;
ICOM_THIS(IDirectSoundBufferImpl,iface);
TRACE("(%p,%p,%p)\n",This,playpos,writepos);
if (This->hwbuf) {
IDsDriverBuffer_GetPosition(This->hwbuf, playpos, writepos);
hres=IDsDriverBuffer_GetPosition(This->hwbuf,playpos,writepos);
if (hres)
return hres;
}
else if (This->dsbd.dwFlags & DSBCAPS_PRIMARYBUFFER) {
if (playpos && (This->dsbd.dwFlags & DSBCAPS_GETCURRENTPOSITION2)) {
......@@ -2690,6 +2694,7 @@ static void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw
DWORD len;
int nfiller;
BOOL forced;
HRESULT hres;
if (!dsound || !primarybuf) {
ERR("dsound died without killing us?\n");
......@@ -2716,7 +2721,11 @@ static void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw
if (dsound->priolevel != DSSCL_WRITEPRIMARY) {
BOOL paused = ((primarybuf->state == STATE_STOPPED) || (primarybuf->state == STATE_STARTING));
DWORD playpos, writepos, inq, maxq, mixq, frag;
IDsDriverBuffer_GetPosition(primarybuf->hwbuf, &playpos, &writepos);
hres = IDsDriverBuffer_GetPosition(primarybuf->hwbuf, &playpos, &writepos);
if (hres) {
LeaveCriticalSection(&(dsound->lock));
return;
}
/* Well, we *could* do Just-In-Time mixing using the writepos,
* but that's a little bit ambitious and unnecessary... */
/* rather add our safety margin to the writepos, if we're playing */
......@@ -2776,7 +2785,12 @@ static void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD dwUser, DWORD dw
}
/* the Stop is supposed to reset play position to beginning of buffer */
/* unfortunately, OSS is not able to do so, so get current pointer */
IDsDriverBuffer_GetPosition(primarybuf->hwbuf, &playpos, NULL);
hres = IDsDriverBuffer_GetPosition(primarybuf->hwbuf, &playpos, NULL);
if (hres) {
LeaveCriticalSection(&(dsound->lock));
LeaveCriticalSection(&(primarybuf->lock));
return;
}
writepos = playpos;
primarybuf->playpos = playpos;
primarybuf->mixpos = playpos;
......
......@@ -1412,6 +1412,10 @@ static HRESULT WINAPI IDsDriverBufferImpl_GetPosition(PIDSDRIVERBUFFER iface,
DWORD ptr;
TRACE("(%p)\n",iface);
if (WOutDev[This->drv->wDevID].unixdev == -1) {
ERR("device not open, but accessing?\n");
return DSERR_UNINITIALIZED;
}
if (ioctl(WOutDev[This->drv->wDevID].unixdev, SNDCTL_DSP_GETOPTR, &info) < 0) {
ERR("ioctl failed (%d)\n", errno);
return DSERR_GENERIC;
......
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