unsafe int /*HRESULT*/ SetPrimaryBufferFormat(int primaryChannels, int primaryFrequency, int primaryBitRate, bool allowLogError) { int hr; void */*IDirectSoundBuffer*/ primaryBuffer = null; // Get the primary buffer DSBUFFERDESC bufferDesc = new DSBUFFERDESC(); //ZeroMemory( &bufferDesc, sizeof( DSBUFFERDESC ) ); bufferDesc.dwSize = (uint)sizeof(DSBUFFERDESC); bufferDesc.dwFlags = /*DSound.DSBCAPS_CTRL3D | */ DSound.DSBCAPS_PRIMARYBUFFER; //bufferDesc.dwBufferBytes = 0; //bufferDesc.lpwfxFormat = NULL; hr = IDirectSound8.CreateSoundBuffer(directSound, ref bufferDesc, out primaryBuffer, null); if (Wrapper.FAILED(hr)) { if (allowLogError) { Error("CreateSoundBuffer", hr); } return(hr); } WAVEFORMATEX waveFormat = new WAVEFORMATEX(); //ZeroMemory( &waveFormat, sizeof( WAVEFORMATEX ) ); waveFormat.wFormatTag = (ushort)DSound.WAVE_FORMAT_PCM; waveFormat.nChannels = (ushort)primaryChannels; waveFormat.nSamplesPerSec = (uint)primaryFrequency; waveFormat.wBitsPerSample = (ushort)primaryBitRate; waveFormat.nBlockAlign = (ushort)(waveFormat.wBitsPerSample / 8 * waveFormat.nChannels); waveFormat.nAvgBytesPerSec = (uint)(waveFormat.nSamplesPerSec * waveFormat.nBlockAlign); hr = IDirectSoundBuffer.SetFormat(primaryBuffer, ref waveFormat); if (Wrapper.FAILED(hr)) { IDirectSoundBuffer.Release(primaryBuffer); if (allowLogError) { Error("SetFormat", hr); } return(hr); } IDirectSoundBuffer.Release(primaryBuffer); return(DSound.S_OK); }
public unsafe static extern int SetFormat(void */*IDirectSoundBuffer*/ _this, ref WAVEFORMATEX pcfxFormat);
unsafe int/*HRESULT*/ SetPrimaryBufferFormat( int primaryChannels, int primaryFrequency, int primaryBitRate, bool allowLogError ) { int hr; void*/*IDirectSoundBuffer*/ primaryBuffer = null; // Get the primary buffer DSBUFFERDESC bufferDesc = new DSBUFFERDESC(); //ZeroMemory( &bufferDesc, sizeof( DSBUFFERDESC ) ); bufferDesc.dwSize = (uint)sizeof( DSBUFFERDESC ); bufferDesc.dwFlags = /*DSound.DSBCAPS_CTRL3D | */DSound.DSBCAPS_PRIMARYBUFFER; //bufferDesc.dwBufferBytes = 0; //bufferDesc.lpwfxFormat = NULL; hr = IDirectSound8.CreateSoundBuffer( directSound, ref bufferDesc, out primaryBuffer, null ); if( Wrapper.FAILED( hr ) ) { if( allowLogError ) Error( "CreateSoundBuffer", hr ); return hr; } WAVEFORMATEX waveFormat = new WAVEFORMATEX(); //ZeroMemory( &waveFormat, sizeof( WAVEFORMATEX ) ); waveFormat.wFormatTag = (ushort)DSound.WAVE_FORMAT_PCM; waveFormat.nChannels = (ushort)primaryChannels; waveFormat.nSamplesPerSec = (uint)primaryFrequency; waveFormat.wBitsPerSample = (ushort)primaryBitRate; waveFormat.nBlockAlign = (ushort)( waveFormat.wBitsPerSample / 8 * waveFormat.nChannels ); waveFormat.nAvgBytesPerSec = (uint)( waveFormat.nSamplesPerSec * waveFormat.nBlockAlign ); hr = IDirectSoundBuffer.SetFormat( primaryBuffer, ref waveFormat ); if( Wrapper.FAILED( hr ) ) { IDirectSoundBuffer.Release( primaryBuffer ); if( allowLogError ) Error( "SetFormat", hr ); return hr; } IDirectSoundBuffer.Release( primaryBuffer ); return DSound.S_OK; }
public unsafe static extern int SetFormat( void*/*IDirectSoundBuffer*/ _this, ref WAVEFORMATEX pcfxFormat );