MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _createBuffer

Method _createBuffer

Engine/source/sfx/dsound/sfxDSBuffer.cpp:75–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75bool SFXDSBuffer::_createBuffer( IDirectSoundBuffer8 **buffer8 )
76{
77 AssertFatal( mAsyncState != NULL,
78 "SFXDSBuffer::_createBuffer() - Can't create buffer when not connected to stream!" );
79
80 const SFXFormat& format = getFormat();
81
82 // Set up WAV format structure.
83 WAVEFORMATEX wfx;
84 dMemset( &wfx, 0, sizeof( WAVEFORMATEX ) );
85 wfx.wFormatTag = WAVE_FORMAT_PCM;
86 wfx.nChannels = format.getChannels();
87 wfx.nSamplesPerSec = format.getSamplesPerSecond();
88 wfx.wBitsPerSample = format.getBitsPerChannel();
89 wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
90 wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
91
92 // Set up DSBUFFERDESC structure.
93 DSBUFFERDESC dsbdesc;
94 dMemset( &dsbdesc, 0, sizeof( DSBUFFERDESC ) );
95 dsbdesc.dwSize = sizeof( DSBUFFERDESC );
96 dsbdesc.dwFlags =
97 ( mIs3d ? DSBCAPS_CTRL3D | DSBCAPS_MUTE3DATMAXDISTANCE : DSBCAPS_CTRLPAN ) |
98 ( isStreaming() ? DSBCAPS_CTRLPOSITIONNOTIFY : 0 ) |
99 DSBCAPS_CTRLFREQUENCY |
100 DSBCAPS_CTRLVOLUME |
101 DSBCAPS_GETCURRENTPOSITION2 |
102 DSBCAPS_GLOBALFOCUS |
103 DSBCAPS_STATIC |
104 ( mUseHardware ? DSBCAPS_LOCHARDWARE : DSBCAPS_LOCSOFTWARE );
105 dsbdesc.dwBufferBytes = mBufferSize;
106 if ( mIs3d )
107 dsbdesc.guid3DAlgorithm = DS3DALG_HRTF_FULL;
108 dsbdesc.lpwfxFormat = &wfx;
109
110 // Create the buffer.
111 IDirectSoundBuffer *buffer = NULL;
112 HRESULT hr = mDSound->CreateSoundBuffer( &dsbdesc, &buffer, NULL );
113 if ( FAILED( hr ) || !buffer )
114 return false;
115
116 // Grab the version 8 interface.
117 IDirectSoundBuffer8* buffer8Ptr;
118 hr = buffer->QueryInterface( IID_IDirectSoundBuffer8, ( LPVOID* ) &buffer8Ptr );
119
120 // Release the original interface.
121 buffer->Release();
122
123 // If we failed to get the 8 interface... exit.
124 if ( FAILED( hr ) || !buffer8Ptr )
125 return false;
126
127 // Set up notification positions, if this is a streaming buffer.
128
129 if( isStreaming() )
130 {
131 using namespace SFXInternal;
132

Callers 1

createMethod · 0.45

Calls 9

UPDATE_THREADFunction · 0.85
getBitsPerChannelMethod · 0.80
getPacketSizeMethod · 0.80
getUpdateEventMethod · 0.80
dMemsetFunction · 0.50
getChannelsMethod · 0.45
getSamplesPerSecondMethod · 0.45
ReleaseMethod · 0.45
getDataLengthMethod · 0.45

Tested by

no test coverage detected