MCPcopy
hub / github.com/ebitengine/oto / writeOnRenderThread

Method writeOnRenderThread

driver_wasapi_windows.go:373–413  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

371}
372
373func (c *wasapiContext) writeOnRenderThread() error {
374 c.m.Lock()
375 defer c.m.Unlock()
376
377 paddingFrames, err := c.client.GetCurrentPadding()
378 if err != nil {
379 return err
380 }
381
382 frames := c.bufferFrames - paddingFrames
383 if frames <= 0 {
384 return nil
385 }
386
387 // Get the destination buffer.
388 dstBuf, err := c.renderClient.GetBuffer(frames)
389 if err != nil {
390 return err
391 }
392
393 // Calculate the buffer size.
394 if buflen := int(frames) * c.channelCount; cap(c.buf) < buflen {
395 c.buf = make([]float32, buflen)
396 } else {
397 c.buf = c.buf[:buflen]
398 }
399
400 // Read the buffer from the players.
401 c.mux.ReadFloat32s(c.buf)
402
403 // Copy the read buf to the destination buffer.
404 copy(unsafe.Slice((*float32)(unsafe.Pointer(dstBuf)), len(c.buf)), c.buf)
405
406 // Release the buffer.
407 if err := c.renderClient.ReleaseBuffer(frames, 0); err != nil {
408 return err
409 }
410
411 c.buf = c.buf[:0]
412 return nil
413}
414
415func (c *wasapiContext) Suspend() error {
416 c.suspendedCond.L.Lock()

Callers 1

loopOnRenderThreadMethod · 0.95

Calls 4

GetCurrentPaddingMethod · 0.80
GetBufferMethod · 0.80
ReadFloat32sMethod · 0.80
ReleaseBufferMethod · 0.80

Tested by

no test coverage detected