void SndFmt2WaveFmt(SNDMIXFORMAT *pfmt,WAVEFORMATEX *pwfx) { ASSERTPOINTER(pfmt!=NULL && pwfx!=NULL); INITTOZERO(pwfx,sizeof(WAVEFORMATEX)); pwfx->wFormatTag = WAVE_FORMAT_PCM; pwfx->nChannels= pfmt->nChannels; pwfx->nSamplesPerSec=pfmt->nSamplesPerSec; pwfx->wBitsPerSample=pfmt->wBitsPerSample; // The nBlockAlign calculation below only works for whole-byte samples ASSERTRANGE( pwfx->wBitsPerSample % 8 == 0 ); pwfx->nBlockAlign=pwfx->nChannels * (pwfx->wBitsPerSample / 8); pwfx->nAvgBytesPerSec= pwfx->nBlockAlign * pwfx->nSamplesPerSec; }
//-------------------------------------------------------------------------- // It returns the next possible format, changes only frequency, if there is! // Return FALSE if no formats are available! BOOL TryOtherSndFormat(SNDMIXFORMAT *pfmt) { int i; ASSERTPOINTER(pfmt!=NULL); // find the first descending frequency for(i=N_SPS-1; i>=0; i--) { if(nSamplesPerSecBaseV[i]>pfmt->nSamplesPerSec) continue; pfmt->nSamplesPerSec=nSamplesPerSecBaseV[i]; break; } return (i>=0); }
aart::camera * aart_post::getactive(tbagstepper<aart::camera *> * astep) const { aart::camera * tmpcam ; ASSERTPOINTER(astep) ; tmpcam= NULL ; if (astep-> next(tmpcam)) { if (* mcamera) { while (tmpcam && strcmp(mcamera, tmpcam-> getname())) { if (! astep-> next(tmpcam)) tmpcam= NULL ; } } } delete astep ; return tmpcam ; }
//-------------------------------------------------------------------------- // First check about snd card capability and change the requested format to // the available format (without change frequency) // Return FALSE if the snd card doesn't support any format (it's not very feasible) BOOL MakeWaveFmtCompatible(WAVEFORMATEX *pwfx, LPDSCAPS lpdsCaps) { BOOL bflag=TRUE; ASSERTPOINTER(pwfx!=NULL && lpdsCaps); ASSERTRANGE(pwfx->nChannels==2 || pwfx->nChannels==1); if(pwfx->nChannels==2) //STEREO if((lpdsCaps->dwFlags & DSCAPS_PRIMARYSTEREO)==0) pwfx->nChannels=1; if(pwfx->nChannels==1) //MONO if((lpdsCaps->dwFlags & DSCAPS_PRIMARYMONO)==0) bflag=FALSE; // IT'S VERY STRANGE BUT POSSIBLE, THE SOUND CARD ISN'T GOOD ;-) ASSERTRANGE(pwfx->wBitsPerSample==16 || pwfx->wBitsPerSample==8); if(pwfx->wBitsPerSample==16) //16 Bit Sample if((lpdsCaps->dwFlags & DSCAPS_PRIMARY16BIT)==0) pwfx->wBitsPerSample=8; if(pwfx->wBitsPerSample==8) //8 Bit Sample if((lpdsCaps->dwFlags & DSCAPS_PRIMARY8BIT)==0) bflag=FALSE; // IT'S VERY STRANGE BUT POSSIBLE, THE SOUND CARD ISN'T GOOD ;-) return bflag; }