mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
audio/internal/readerdriver: Refactoring
This commit is contained in:
parent
d1138bc615
commit
089883aba0
@ -593,16 +593,20 @@ func (p *playerImpl) appendBufferImpl(inBuffer C.AudioQueueBufferRef) (bool, err
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bs := make([]byte, p.context.oneBufferSize())
|
oneBufferSize := p.context.oneBufferSize()
|
||||||
n := copy(bs, p.buf)
|
n := oneBufferSize
|
||||||
var signal bool
|
if len(p.buf) < n {
|
||||||
if len(p.buf[n:]) < p.context.maxBufferSize() {
|
n = len(p.buf)
|
||||||
signal = true
|
|
||||||
}
|
}
|
||||||
|
buf := p.buf[:n]
|
||||||
|
signal := len(p.buf[n:]) < p.context.maxBufferSize()
|
||||||
|
|
||||||
for i, b := range bs {
|
for i, b := range buf {
|
||||||
*(*byte)(unsafe.Pointer(uintptr(inBuffer.mAudioData) + uintptr(i))) = b
|
*(*byte)(unsafe.Pointer(uintptr(inBuffer.mAudioData) + uintptr(i))) = b
|
||||||
}
|
}
|
||||||
|
for i := len(buf); i < oneBufferSize; i++ {
|
||||||
|
*(*byte)(unsafe.Pointer(uintptr(inBuffer.mAudioData) + uintptr(i))) = 0
|
||||||
|
}
|
||||||
|
|
||||||
if osstatus := C.AudioQueueEnqueueBuffer(p.audioQueue, inBuffer, 0, nil); osstatus != C.noErr {
|
if osstatus := C.AudioQueueEnqueueBuffer(p.audioQueue, inBuffer, 0, nil); osstatus != C.noErr {
|
||||||
// This can happen just after resetting.
|
// This can happen just after resetting.
|
||||||
|
Loading…
Reference in New Issue
Block a user