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

Method write

Engine/source/sfx/sfxInternal.cpp:145–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143//--------------------------------------------------------------------------
144
145void SFXWrapAroundBuffer::write( SFXStreamPacket* const* packets, U32 num )
146{
147 AssertFatal( SFXInternal::isSFXThread(), "SFXWrapAroundBuffer::write() - not on SFX thread" );
148
149 for( U32 i = 0; i < num; ++ i )
150 {
151 const SFXStreamPacket* packet = packets[ i ];
152
153 // Determine where in the buffer to copy the data to. In case we are crossing over
154 // the wrap-around point, we need to copy in two slices.
155
156 U32 offset1 = 0;
157 U32 offset2 = 0;
158 U32 numBytes1 = 0;
159 U32 numBytes2 = 0;
160
161 offset1 = mWriteOffset % mBufferSize;
162 numBytes1 = packet->size;
163
164 if( offset1 + numBytes1 > mBufferSize )
165 {
166 // Crossing wrap-around point.
167
168 numBytes1 = mBufferSize - offset1;
169 numBytes2 = packet->size - numBytes1;
170 }
171
172 offset2 = offset1 + numBytes1;
173
174 #ifdef DEBUG_SPEW
175 Platform::outputDebugString( "[SFXWrapAroundBuffer] writing %i bytes from packet #%i at %i (stream offset: %i)",
176 numBytes1, packet->mIndex, offset1, mWriteOffset );
177 #endif
178
179 // Copy the packet data.
180
181 _copyData( offset1, packet->data, numBytes1 );
182 if( numBytes2 > 0 )
183 {
184 #ifdef DEBUG_SPEW
185 Platform::outputDebugString( "[SFXWrapAroundBuffer] writing %i more bytes at %i",
186 numBytes2, offset2 );
187 #endif
188
189 _copyData( offset2, &packet->data[ numBytes1 ], numBytes2 );
190 }
191
192 dFetchAndAdd( mWriteOffset, packet->size );
193
194 // Free the packet.
195
196 destructSingle( packet );
197 }
198}
199
200} // namespace SFXInternal

Callers 15

packDataMethod · 0.45
packDataMethod · 0.45
packDataMethod · 0.45
packDataMethod · 0.45
printMethod · 0.45
printMethod · 0.45
printShaderHeaderMethod · 0.45
printMainCommentMethod · 0.45
printLineMethod · 0.45
printMethod · 0.45
printMethod · 0.45

Calls 3

isSFXThreadFunction · 0.85
dFetchAndAddFunction · 0.50
destructSingleFunction · 0.50

Tested by

no test coverage detected