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

Method appendBuffer

driver_darwin.go:183–217  ·  view source on GitHub ↗
(buf32 []float32)

Source from the content-addressed store, hash-verified

181}
182
183func (c *context) appendBuffer(buf32 []float32) {
184 c.cond.L.Lock()
185 defer c.cond.L.Unlock()
186
187 if c.err.Load() != nil {
188 return
189 }
190
191 if c.toPause {
192 if err := c.pause(); err != nil {
193 c.err.TryStore(err)
194 }
195 c.toPause = false
196 return
197 }
198
199 if c.toResume {
200 if err := c.resume(); err != nil {
201 c.err.TryStore(err)
202 }
203 c.toResume = false
204 return
205 }
206
207 buf := c.unqueuedBuffers[0]
208 copy(c.unqueuedBuffers, c.unqueuedBuffers[1:])
209 c.unqueuedBuffers = c.unqueuedBuffers[:len(c.unqueuedBuffers)-1]
210
211 c.mux.ReadFloat32s(buf32)
212 copy(unsafe.Slice((*float32)(unsafe.Pointer(buf.mAudioData)), buf.mAudioDataByteSize/float32SizeInBytes), buf32)
213
214 if osstatus := _AudioQueueEnqueueBuffer(c.audioQueue, buf, 0, nil); osstatus != noErr {
215 c.err.TryStore(fmt.Errorf("oto: AudioQueueEnqueueBuffer failed: %d", osstatus))
216 }
217}
218
219func (c *context) Suspend() error {
220 c.cond.L.Lock()

Callers 1

loopMethod · 0.95

Calls 5

pauseMethod · 0.95
resumeMethod · 0.95
LoadMethod · 0.80
TryStoreMethod · 0.80
ReadFloat32sMethod · 0.80

Tested by

no test coverage detected