static HRESULT WINAPI PrimaryBufferImpl_SetPan(IDirectSoundBuffer *iface, LONG pan) { IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); DirectSoundDevice *device = This->device; float fvol; HRESULT hr; int i; TRACE("(%p,%d)\n", iface, pan); if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if ((pan > DSBPAN_RIGHT) || (pan < DSBPAN_LEFT)) { WARN("invalid parameter: pan = %d\n", pan); return DSERR_INVALIDPARAM; } /* **** */ EnterCriticalSection(&device->mixlock); for (i = 0; i < DS_MAX_CHANNELS; i++) { if (device->pwfx->nChannels > i){ hr = IAudioStreamVolume_GetChannelVolume(device->volume, i, &fvol); if (FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("GetChannelVolume failed: %08x\n", hr); return hr; } } else fvol = 1; device->volpan.dwTotalAmpFactor[i] = ((UINT16)(fvol * (DWORD)0xFFFF)); } DSOUND_AmpFactorToVolPan(&device->volpan); if (pan != device->volpan.lPan) { device->volpan.lPan=pan; DSOUND_RecalcVolPan(&device->volpan); for (i = 0; i < DS_MAX_CHANNELS; i++) { if (device->pwfx->nChannels > i) { fvol = (float)((DWORD)(device->volpan.dwTotalAmpFactor[i] & 0xFFFF) / (float)0xFFFF); hr = IAudioStreamVolume_SetChannelVolume(device->volume, i, fvol); if (FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("SetChannelVolume failed: %08x\n", hr); return hr; } } } } LeaveCriticalSection(&device->mixlock); /* **** */ return DS_OK; }
static HRESULT WINAPI PrimaryBufferImpl_GetPan( LPDIRECTSOUNDBUFFER iface,LPLONG pan ) { IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); DirectSoundDevice *device = This->device; DWORD ampfactors; TRACE("(%p,%p)\n", iface, pan); if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if (pan == NULL) { WARN("invalid parameter: pan == NULL\n"); return DSERR_INVALIDPARAM; } waveOutGetVolume(device->hwo, &factors); device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; DSOUND_AmpFactorToVolPan(&device->volpan); *pan = device->volpan.lPan; return DS_OK; }
static HRESULT WINAPI PrimaryBufferImpl_GetPan( LPDIRECTSOUNDBUFFER iface,LPLONG pan ) { IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); DirectSoundDevice *device = This->device; float lvol, rvol; HRESULT hr; TRACE("(%p,%p)\n", iface, pan); if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if (pan == NULL) { WARN("invalid parameter: pan == NULL\n"); return DSERR_INVALIDPARAM; } EnterCriticalSection(&device->mixlock); hr = IAudioStreamVolume_GetChannelVolume(device->volume, 0, &lvol); if(FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("GetChannelVolume failed: %08x\n", hr); return hr; } if(device->pwfx->nChannels > 1){ hr = IAudioStreamVolume_GetChannelVolume(device->volume, 1, &rvol); if(FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("GetChannelVolume failed: %08x\n", hr); return hr; } }else rvol = 1; device->volpan.dwTotalLeftAmpFactor = ((UINT16)(lvol * (DWORD)0xFFFF)); device->volpan.dwTotalRightAmpFactor = ((UINT16)(rvol * (DWORD)0xFFFF)); DSOUND_AmpFactorToVolPan(&device->volpan); *pan = device->volpan.lPan; LeaveCriticalSection(&device->mixlock); return DS_OK; }
static HRESULT WINAPI PrimaryBufferImpl_GetVolume(IDirectSoundBuffer *iface, LONG *vol) { IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); DirectSoundDevice *device = This->device; float fvol; HRESULT hr; int i; TRACE("(%p,%p)\n", iface, vol); if (!(This->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if (vol == NULL) { WARN("invalid parameter: vol = NULL\n"); return DSERR_INVALIDPARAM; } EnterCriticalSection(&device->mixlock); for (i = 0; i < DS_MAX_CHANNELS; i++) { if (device->pwfx->nChannels > i){ hr = IAudioStreamVolume_GetChannelVolume(device->volume, i, &fvol); if (FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("GetChannelVolume failed: %08x\n", hr); return hr; } } else fvol = 1; device->volpan.dwTotalAmpFactor[i] = ((UINT16)(fvol * (DWORD)0xFFFF)); } DSOUND_AmpFactorToVolPan(&device->volpan); *vol = device->volpan.lVolume; LeaveCriticalSection(&device->mixlock); return DS_OK; }
static HRESULT WINAPI PrimaryBufferImpl_SetVolume( LPDIRECTSOUNDBUFFER iface,LONG vol ) { DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device; DWORD ampfactors; HRESULT hres = DS_OK; TRACE("(%p,%d)\n", iface, vol); if (!(device->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if ((vol > DSBVOLUME_MAX) || (vol < DSBVOLUME_MIN)) { WARN("invalid parameter: vol = %d\n", vol); return DSERR_INVALIDPARAM; } /* **** */ EnterCriticalSection(&(device->mixlock)); waveOutGetVolume(device->hwo, &factors); device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; DSOUND_AmpFactorToVolPan(&device->volpan); if (vol != device->volpan.lVolume) { device->volpan.lVolume=vol; DSOUND_RecalcVolPan(&device->volpan); if (device->hwbuf) { hres = IDsDriverBuffer_SetVolumePan(device->hwbuf, &device->volpan); if (hres != DS_OK) WARN("IDsDriverBuffer_SetVolumePan failed\n"); } else { ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFactor << 16); waveOutSetVolume(device->hwo, ampfactors); } } LeaveCriticalSection(&(device->mixlock)); /* **** */ return hres; }
static HRESULT WINAPI PrimaryBufferImpl_SetPan( LPDIRECTSOUNDBUFFER iface,LONG pan ) { IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); DirectSoundDevice *device = This->device; DWORD ampfactors; HRESULT hres = DS_OK; TRACE("(%p,%d)\n", iface, pan); if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if ((pan > DSBPAN_RIGHT) || (pan < DSBPAN_LEFT)) { WARN("invalid parameter: pan = %d\n", pan); return DSERR_INVALIDPARAM; } /* **** */ EnterCriticalSection(&(device->mixlock)); waveOutGetVolume(device->hwo, &factors); device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; DSOUND_AmpFactorToVolPan(&device->volpan); if (pan != device->volpan.lPan) { device->volpan.lPan=pan; DSOUND_RecalcVolPan(&device->volpan); ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFactor << 16); waveOutSetVolume(device->hwo, ampfactors); } LeaveCriticalSection(&(device->mixlock)); /* **** */ return hres; }
static HRESULT WINAPI PrimaryBufferImpl_GetVolume( LPDIRECTSOUNDBUFFER iface,LPLONG vol ) { DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device; DWORD ampfactors; TRACE("(%p,%p)\n", iface, vol); if (!(device->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if (vol == NULL) { WARN("invalid parameter: vol = NULL\n"); return DSERR_INVALIDPARAM; } if (!device->hwbuf) { waveOutGetVolume(device->hwo, &factors); device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; DSOUND_AmpFactorToVolPan(&device->volpan); }
static HRESULT WINAPI PrimaryBufferImpl_SetVolume( LPDIRECTSOUNDBUFFER iface,LONG vol ) { IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); DirectSoundDevice *device = This->device; HRESULT hr; float lvol, rvol; TRACE("(%p,%d)\n", iface, vol); if (!(This->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) { WARN("control unavailable\n"); return DSERR_CONTROLUNAVAIL; } if ((vol > DSBVOLUME_MAX) || (vol < DSBVOLUME_MIN)) { WARN("invalid parameter: vol = %d\n", vol); return DSERR_INVALIDPARAM; } /* **** */ EnterCriticalSection(&device->mixlock); hr = IAudioStreamVolume_GetChannelVolume(device->volume, 0, &lvol); if(FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("GetChannelVolume failed: %08x\n", hr); return hr; } if(device->pwfx->nChannels > 1){ hr = IAudioStreamVolume_GetChannelVolume(device->volume, 1, &rvol); if(FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("GetChannelVolume failed: %08x\n", hr); return hr; } }else rvol = 1; device->volpan.dwTotalLeftAmpFactor = ((UINT16)(lvol * (DWORD)0xFFFF)); device->volpan.dwTotalRightAmpFactor = ((UINT16)(rvol * (DWORD)0xFFFF)); DSOUND_AmpFactorToVolPan(&device->volpan); if (vol != device->volpan.lVolume) { device->volpan.lVolume=vol; DSOUND_RecalcVolPan(&device->volpan); lvol = (float)((DWORD)(device->volpan.dwTotalLeftAmpFactor & 0xFFFF) / (float)0xFFFF); hr = IAudioStreamVolume_SetChannelVolume(device->volume, 0, lvol); if(FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("SetChannelVolume failed: %08x\n", hr); return hr; } if(device->pwfx->nChannels > 1){ rvol = (float)((DWORD)(device->volpan.dwTotalRightAmpFactor & 0xFFFF) / (float)0xFFFF); hr = IAudioStreamVolume_SetChannelVolume(device->volume, 1, rvol); if(FAILED(hr)){ LeaveCriticalSection(&device->mixlock); WARN("SetChannelVolume failed: %08x\n", hr); return hr; } } } LeaveCriticalSection(&(device->mixlock)); /* **** */ return DS_OK; }