30 TRACE(
"(%p)\n",volpan);
49 TRACE(
"(%p)\n",volpan);
73 if (volpan->
lPan < -10000)
87 if (
device->pwfx->wBitsPerSample == 32)
105 if (secpos < secmixpos)
112 DWORD64 oshot = acc * freqAdjust + freqAcc;
115 *overshot = (
DWORD)oshot;
116 assert(*overshot < dsb->freqAdjust);
131 framelen = bufpos/oAdv;
231 TRACE(
"(%p) buflen = %d, playpos = %d, len = %d\n",
236 TRACE(
"checking %d, position %d, event = %p\n",
248 TRACE(
"signalled event %p (%d)\n",
event->hEventNotify,
i);
255 TRACE(
"signalled event %p (%d)\n",
event->hEventNotify,
i);
260 TRACE(
"signalled event %p (%d)\n",
event->hEventNotify,
i);
300 WARN(
"Unable to remap channels: device=%u, buffer=%u\n",
device->pwfx->nChannels,
316 return buflen + ptr1 - ptr2;
335 BYTE *ibp, *obp, *obp_begin;
338 DWORD freqAcc, target_writepos = 0, overshot, maxlen;
344 assert(writepos + len <= dsb->buflen);
345 if (inmixer && writepos + len < dsb->buflen)
365 TRACE(
"(%p, %p)\n", dsb, ibp);
370 TRACE(
"(%p) Same sample rate %d = primary %d\n", dsb,
374 obp += writepos/iAdvance*oAdvance;
387 if (overshot >=
size)
390 writepos += overshot * iAdvance;
391 if (writepos >= dsb->
buflen)
395 TRACE(
"Overshot: %d, freqAcc: %04x\n", overshot, freqAcc);
399 obp = obp_begin + target_writepos;
400 else obp = obp_begin;
466 for (
i = 0;
i <
len-1;
i+=2) {
467 *(bpc++) = (((*(
mem++) - 128) * vLeft) >> 16) + 128;
468 *(bpc++) = (((*(
mem++) - 128) * vRight) >> 16) + 128;
471 *(bpc++) = (((*(
mem++) - 128) * vLeft) >> 16) + 128;
475 for (
i = 0;
i <
len-3;
i += 4) {
476 *(bps++) = (*(mems++) * vLeft) >> 16;
477 *(bps++) = (*(mems++) * vRight) >> 16;
480 *(bps++) = ((
INT)*(mems++) * vLeft) >> 16;
503 DWORD oldpos, mixbufpos;
506 TRACE(
"(%p,%d,%d)\n",dsb,writepos,fraglen);
512 ERR(
"length not a multiple of block size, len = %d, block size = %d\n",
len, nBlockAlign);
585 TRACE(
"(%p,%d,%d)\n",dsb,writepos,mixlen);
604 if(mixlen < primary_done)
607 ERR(
"Fatal error. Under/Overflow? primary_done=%d, mixpos=%d/%d (%d/%d), primary_mixpos=%d, writepos=%d, mixlen=%d\n", primary_done,dsb->
buf_mixpos,dsb->
tmp_buffer_len,dsb->
sec_mixpos, dsb->
buflen, dsb->
primary_mixpos, writepos, mixlen);
614 mixlen -= primary_done;
616 TRACE(
"primary_done=%d, mixlen (primary) = %i\n", primary_done, mixlen);
631 while (newmixed && mixlen)
672 TRACE(
"(%d,%d,%d)\n", writepos, mixlen, recover);
673 for (
i = 0;
i <
device->nrofbuffers;
i++) {
676 TRACE(
"MixToPrimary for %p, state=%d\n", dsb, dsb->
state);
679 TRACE(
"Checking %p, mixlen=%d\n", dsb, mixlen);
699 if (!minlen) minlen =
len;
703 else if (
len) minlen = (
len < minlen) ?
len : minlen;
705 *all_stopped =
FALSE;
711 TRACE(
"Mixed at least %d from all buffers\n", minlen);
727 DWORD prebuf_frags, wave_writepos, wave_fragpos,
i;
734 wave_writepos = wave_fragpos *
device->fraglen;
736 TRACE(
"wave_fragpos = %i, wave_writepos = %i, pwqueue = %i, prebuf = %i\n",
737 wave_fragpos, wave_writepos,
device->pwqueue,
device->prebuf);
743 if (prebuf_frags ==
device->helfrags)
745 TRACE(
"wave_fragpos = %d, mixpos_frags = %d\n", wave_fragpos, prebuf_frags);
746 if (prebuf_frags < wave_fragpos)
747 prebuf_frags +=
device->helfrags;
748 prebuf_frags -= wave_fragpos;
749 TRACE(
"wanted prebuf_frags = %d\n", prebuf_frags);
753 prebuf_frags =
device->prebuf;
759 TRACE(
"prebuf_frags = %i\n", prebuf_frags);
762 device->pwqueue += prebuf_frags;
769 for(
i=0;
i<prebuf_frags;
i++){
770 TRACE(
"queueing wave buffer %i\n", wave_fragpos);
773 wave_fragpos %=
device->helfrags;
796 DWORD playpos, writepos, writelead, maxq, frag, prebuff_max, prebuff_left, size1, size2, mixplaypos, mixplaypos2;
802 nfiller =
device->pwfx->wBitsPerSample == 8 ? 128 : 0;
810 TRACE(
"primary playpos=%d, writepos=%d, clrpos=%d, mixpos=%d, buflen=%d\n",
830 WARN(
"Probable buffer underrun\n");
831 else TRACE(
"Buffer starting or buffer underrun\n");
837 device->mixpos = writepos;
841 }
else if (playpos < device->playpos) {
851 if (playpos && (!buf2 || !size2))
852 FIXME(
"%d: (%d, %d)=>(%d, %d) There should be an additional buffer here!!\n", __LINE__,
device->playpos,
device->mixpos, playpos, writepos);
859 size1 = playpos -
device->playpos;
867 FIXME(
"%d: There should be no additional buffer here!!\n", __LINE__);
873 device->playpos = playpos;
876 maxq = (writelead < prebuff_max) ? (prebuff_max - writelead) : 0;
878 TRACE(
"prebuff_left = %d, prebuff_max = %dx%d=%d, writelead=%d\n",
879 prebuff_left,
device->prebuf,
device->fraglen, prebuff_max, writelead);
887 if (frag + writepos >
device->buflen)
897 device->mixpos = writepos + frag;
902 DWORD frag2 = (frag > size1 ? frag - size1 : 0);
906 FIXME(
"Buffering too much! (%d, %d, %d, %d)\n", maxq, frag, size2, frag2 - size2);
916 if (prebuff_left >=
device->fraglen){
924 TRACE(
"started primary buffer\n");
926 WARN(
"DSOUND_PrimaryPlay failed\n");
936 TRACE(
"restarting primary buffer\n");
938 WARN(
"DSOUND_PrimaryPlay failed\n");
949 TRACE(
"All buffers have stopped. Stopping primary buffer\n");
968 WARN(
"DSOUND_PrimaryPlay failed\n");
974 WARN(
"DSOUND_PrimaryStop failed\n");
990 TRACE(
"(%d,%d,0x%lx,0x%lx,0x%lx)\n",timerID,
msg,dwUser,dw1,dw2);
991 TRACE(
"entering at %d\n", start_time);
994 ERR(
"dsound died without killing us?\n");
1008 TRACE(
"completed processing at %d, duration = %d\n", end_time, end_time - start_time);
1014 TRACE(
"(%p,%x,%lx,%lx,%lx)\n",hwo,
msg,dwUser,dw1,dw2);
1032 if(
device->pwqueue == 0){
1033 ERR(
"Wave queue corrupted!\n");
1042 TRACE(
"completed\n");
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb)
void DSOUND_AmpFactorToVolPan(PDSVOLUMEPAN volpan)
static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen)
void DSOUND_CheckEvent(const IDirectSoundBufferImpl *dsb, DWORD playpos, int len)
static DWORD DSOUND_BufPtrDiff(DWORD buflen, DWORD ptr1, DWORD ptr2)
static void DSOUND_RecalcFreqAcc(IDirectSoundBufferImpl *dsb)
void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan)
void DSOUND_MixToTemporary(const IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD len, BOOL inmixer)
static void DSOUND_PerformMix(DirectSoundDevice *device)
DWORD DSOUND_secpos_to_bufpos(const IDirectSoundBufferImpl *dsb, DWORD secpos, DWORD secmixpos, DWORD *overshot)
void CALLBACK DSOUND_timer(UINT timerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
static DWORD DSOUND_bufpos_to_secpos(const IDirectSoundBufferImpl *dsb, DWORD bufpos)
static DWORD DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos, DWORD mixlen, BOOL recover, BOOL *all_stopped)
static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
DWORD DSOUND_bufpos_to_mixpos(const DirectSoundDevice *device, DWORD pos)
static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD fraglen)
void CALLBACK DSOUND_callback(HWAVEOUT hwo, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
static void cp_fields(const IDirectSoundBufferImpl *dsb, const BYTE *ibuf, BYTE *obuf, UINT istride, UINT ostride, UINT count, UINT freqAcc, UINT adj)
static LPBYTE DSOUND_MixerVol(const IDirectSoundBufferImpl *dsb, INT len)
#define HeapFree(x, y, z)
DWORD WINAPI GetTickCount(VOID)
MMRESULT WINAPI timeKillEvent(UINT wID)
MMRESULT WINAPI timeEndPeriod(UINT wPeriod)
#define IDsDriverBuffer_Unlock(p, a, b, c, d)
#define DSDDESC_DONTNEEDPRIMARYLOCK
#define IDsDriverBuffer_GetPosition(p, a, b)
#define IDsDriverBuffer_Lock(p, a, b, c, d, e, f, g)
#define DSBCAPS_CTRLVOLUME
#define DSSCL_WRITEPRIMARY
#define DSBCAPS_CTRLPOSITIONNOTIFY
const bitsconvertfunc convertbpp[5][4]
int ds_snd_shadow_maxsize
DirectSoundDevice * DSOUND_renderer[MAXWAVEDRIVERS]
HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN
HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN
#define FillMemory(BUF, SIZ, MASK)
double pow(double x, double y)
GLuint GLuint GLsizei count
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define WAVE_FORMAT_IEEE_FLOAT
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
#define IsEqualGUID(rguid1, rguid2)
DirectSoundDevice * device
LPDSBPOSITIONNOTIFY notifies
DWORD dwTotalRightAmpFactor
DWORD dwTotalLeftAmpFactor
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
UINT WINAPI waveOutWrite(HWAVEOUT hWaveOut, LPWAVEHDR lpWaveOutHdr, UINT uSize)