Home Computer Audio Asylum

Music servers and other computer based digital audio technologies.

RE: Linux Build?

comparison of the original render loop to the optimised one showing assembly code, would say the original is fairly typical of your average player. Note the last thing it does is release the buffer to the audio device. Normal players would also be checking for pause, stop, fwd, rew, feeding back bytes played etc as well as checking for end of track to queue the next one.

No wonder there is a digital sound to most players.

I guess my program is just following the ground rules set out by CICS and others except this time it is inside the program and there seems to be a corollary between a faster render loop and lower noise.

new loop

loop2496:


WaitForSingleObject(hNeedDataEvent, INFINITE);
000000013F8F31E2 or edx,0FFFFFFFFh
000000013F8F31E5 mov rcx,rbx
000000013F8F31E8 call qword ptr [imp_WaitForSingleObject (13F8B4070h)]

// need data
hr = pAudioRenderClient->GetBuffer(nFramesInBuffer, &pData);
000000013F8B17BC mov rcx,qword ptr [rbp-1]
000000013F8B17C0 mov edx,dword ptr [rbp+6Fh]
000000013F8B17C3 mov rax,qword ptr [rcx]
000000013F8B17C6 lea r8,[rbp+0Fh]
000000013F8B17CA call qword ptr [rax+18h]
000000013F8B17CD mov edi,eax
if (FAILED(hr)) {
000000013F8B17CF test eax,eax
000000013F8B17D1 js 000000013F8B19CC
}

// is there a full buffer's worth of data left in the file?
if (nFramesPlayed + nFramesInBuffer > nFramesInFile) {
000000013F8B17D7 mov eax,dword ptr [rbp+6Fh]
000000013F8B17DA lea ecx,[rsi+rax]
000000013F8B17DD cmp ecx,r12d
000000013F8B17E0 jbe 000000013F8B17E7
// nope - this is the last buffer
nFramesThisPass = nFramesInFile - nFramesPlayed;
000000013F8B17E2 mov ebx,r12d
000000013F8B17E5 sub ebx,esi
}
UINT32 nBytesThisPass = nFramesThisPass * pWfx->nBlockAlign;
000000013F8B17E7 movzx edi,word ptr [r14+0Ch]

LONG nBytesGotten = mmioRead(hFile, (HPSTR)pData, nBytesThisPass);
000000013F8B17EC mov rdx,qword ptr [rbp+0Fh]
000000013F8B17F0 mov rcx,qword ptr [rbp+5Fh]
000000013F8B17F4 imul edi,ebx
000000013F8B17F7 mov r8d,edi
000000013F8B17FA call qword ptr [__imp_mmioRead (13F8B41B8h)]
if (0 == nBytesGotten) {
000000013F8B1800 test eax,eax
000000013F8B1802 je 000000013F8B1985
} else if (-1 == nBytesGotten) {
000000013F8B1808 cmp eax,0FFFFFFFFh
000000013F8B180B je 000000013F8B197C
} else if (nBytesGotten != (LONG)nBytesThisPass) {
000000013F8B1811 cmp eax,edi
000000013F8B1813 jne 000000013F8B1968
}

// if there's leftover buffer space, zero it out
// it would be much better if we could intelligently fill this with silence
// ah well, c'est la vie
if (nFramesThisPass < nFramesInBuffer) {
000000013F8B1819 mov edx,dword ptr [rbp+6Fh]
000000013F8B181C cmp ebx,edx
000000013F8B181E jae 000000013F8B183D
UINT32 nBytesToZero = (nFramesInBuffer * pWfx->nBlockAlign) - nBytesThisPass;
ZeroMemory(pData + nBytesGotten, nBytesToZero);
000000013F8B1820 movzx r8d,word ptr [r14+0Ch]
000000013F8B1825 movsxd rcx,eax
000000013F8B1828 add rcx,qword ptr [rbp+0Fh]
000000013F8B182C imul r8d,edx
000000013F8B1830 sub r8d,edi
000000013F8B1833 xor edx,edx
000000013F8B1835 call memset (13F8B30D6h)
000000013F8B183A mov edx,dword ptr [rbp+6Fh]
}

hr = pAudioRenderClient->ReleaseBuffer(nFramesInBuffer, 0); // no flags
000000013F8B183D mov rcx,qword ptr [rbp-1]
000000013F8B1841 xor r8d,r8d
000000013F8B1844 mov rax,qword ptr [rcx]
000000013F8B1847 call qword ptr [rax+20h]
000000013F8B184A mov edi,eax
if (FAILED(hr)) {
000000013F8B184C test eax,eax
000000013F8B184E js 000000013F8B195F
nFramesPlayed < nFramesInFile;
nFramesPlayed += nFramesThisPass
) {
000000013F8B1854 add esi,ebx
000000013F8B1856 cmp esi,r12d
000000013F8B1859 jb 000000013F8B17B0
if (FAILED(hr)) {
000000013F8B185F mov edi,dword ptr [rbp-0Dh]
}
} // render loop

http://mqnplayer.blogspot.co.uk/


This post is made possible by the generous support of people like you and our sponsors:
  VH Audio  


Follow Ups Full Thread
Follow Ups

FAQ

Post a Message!

Forgot Password?
Moniker (Username):
Password (Optional):
  Remember my Moniker & Password  (What's this?)    Eat Me
E-Mail (Optional):
Subject:
Message:   (Posts are subject to Content Rules)
Optional Link URL:
Optional Link Title:
Optional Image URL:
Upload Image:
E-mail Replies:  Automagically notify you when someone responds.