mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/readerdriver: Change the returning type of UnplayedBufferSize int64 -> int
This commit is contained in:
parent
7a6bdc8388
commit
52c609459c
@ -127,7 +127,7 @@ func (p *Player) Play() {
|
||||
// TODO: Get the appropriate buffer size from the C++ side.
|
||||
if p.buf == nil {
|
||||
n := p.context.oneBufferSize()
|
||||
if max := p.context.MaxBufferSize() - int(p.UnplayedBufferSize()); n > max {
|
||||
if max := p.context.MaxBufferSize() - p.UnplayedBufferSize(); n > max {
|
||||
n = max
|
||||
}
|
||||
p.buf = make([]byte, n)
|
||||
@ -195,11 +195,11 @@ func (p *Player) SetVolume(volume float64) {
|
||||
p.v.Set("volume", volume)
|
||||
}
|
||||
|
||||
func (p *Player) UnplayedBufferSize() int64 {
|
||||
func (p *Player) UnplayedBufferSize() int {
|
||||
if !p.v.Truthy() {
|
||||
return 0
|
||||
}
|
||||
return int64(p.v.Get("unplayedBufferSize").Int())
|
||||
return p.v.Get("unplayedBufferSize").Int()
|
||||
}
|
||||
|
||||
func (p *Player) Err() error {
|
||||
@ -303,7 +303,7 @@ func (p *Player) loop() {
|
||||
}
|
||||
|
||||
n := readChunkSize
|
||||
if max := p.context.MaxBufferSize() - int(p.UnplayedBufferSize()); n > max {
|
||||
if max := p.context.MaxBufferSize() - p.UnplayedBufferSize(); n > max {
|
||||
n = max
|
||||
}
|
||||
n2, err := p.src.Read(buf[:n])
|
||||
|
4
audio/internal/oboe/binding_android.go
vendored
4
audio/internal/oboe/binding_android.go
vendored
@ -101,6 +101,6 @@ func (p *Player) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Player) UnplayedBufferSize() int64 {
|
||||
return int64(C.Player_UnplayedBufferSize(p.player))
|
||||
func (p *Player) UnplayedBufferSize() int {
|
||||
return int(C.Player_UnplayedBufferSize(p.player))
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ type Player interface {
|
||||
Reset()
|
||||
Volume() float64
|
||||
SetVolume(volume float64)
|
||||
UnplayedBufferSize() int64
|
||||
UnplayedBufferSize() int
|
||||
Err() error
|
||||
io.Closer
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func (p *player) Play() {
|
||||
}
|
||||
|
||||
buf := make([]byte, p.context.maxBufferSize())
|
||||
for p.p.UnplayedBufferSize() < int64(p.context.maxBufferSize()) {
|
||||
for p.p.UnplayedBufferSize() < p.context.maxBufferSize() {
|
||||
n, err := p.src.Read(buf)
|
||||
if err != nil && err != io.EOF {
|
||||
p.setErrorImpl(err)
|
||||
@ -183,7 +183,7 @@ func (p *player) SetVolume(volume float64) {
|
||||
p.p.SetVolume(volume)
|
||||
}
|
||||
|
||||
func (p *player) UnplayedBufferSize() int64 {
|
||||
func (p *player) UnplayedBufferSize() int {
|
||||
p.cond.L.Lock()
|
||||
defer p.cond.L.Unlock()
|
||||
if p.p == nil {
|
||||
@ -240,7 +240,7 @@ func (p *player) shouldWait() bool {
|
||||
return false
|
||||
}
|
||||
if p.p.IsPlaying() {
|
||||
return p.p.UnplayedBufferSize() >= int64(p.context.maxBufferSize())
|
||||
return p.p.UnplayedBufferSize() >= p.context.maxBufferSize()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -525,14 +525,14 @@ func (p *playerImpl) SetVolume(volume float64) {
|
||||
C.AudioQueueSetParameter(p.audioQueue, C.kAudioQueueParam_Volume, C.AudioQueueParameterValue(volume))
|
||||
}
|
||||
|
||||
func (p *player) UnplayedBufferSize() int64 {
|
||||
func (p *player) UnplayedBufferSize() int {
|
||||
return p.p.UnplayedBufferSize()
|
||||
}
|
||||
|
||||
func (p *playerImpl) UnplayedBufferSize() int64 {
|
||||
func (p *playerImpl) UnplayedBufferSize() int {
|
||||
p.cond.L.Lock()
|
||||
defer p.cond.L.Unlock()
|
||||
return int64(len(p.buf))
|
||||
return len(p.buf)
|
||||
}
|
||||
|
||||
func (p *player) Close() error {
|
||||
|
@ -296,7 +296,7 @@ func (p *player) SetVolume(volume float64) {
|
||||
p.gain.Get("gain").Set("value", volume)
|
||||
}
|
||||
|
||||
func (p *player) UnplayedBufferSize() int64 {
|
||||
func (p *player) UnplayedBufferSize() int {
|
||||
p.cond.L.Lock()
|
||||
defer p.cond.L.Unlock()
|
||||
|
||||
@ -305,7 +305,7 @@ func (p *player) UnplayedBufferSize() int64 {
|
||||
for _, n := range p.bufferSourceNodes {
|
||||
sec += n.Get("buffer").Get("duration").Float()
|
||||
}
|
||||
return int64(len(p.buf)) + int64(sec*float64(p.context.sampleRate*p.context.channelNum*p.context.bitDepthInBytes))
|
||||
return len(p.buf) + int(sec*float64(p.context.sampleRate*p.context.channelNum*p.context.bitDepthInBytes))
|
||||
}
|
||||
|
||||
func (p *player) Err() error {
|
||||
|
@ -189,7 +189,7 @@ func (p *readerPlayer) Current() time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
sample := (p.stream.Current() - p.player.UnplayedBufferSize()) / bytesPerSample
|
||||
sample := (p.stream.Current() - int64(p.player.UnplayedBufferSize())) / bytesPerSample
|
||||
return time.Duration(sample) * time.Second / time.Duration(p.factory.sampleRate)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user