mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/readerdriver: Implement {,Set}Volume for macOS
This commit is contained in:
parent
9df1092507
commit
22567d20b6
@ -97,6 +97,7 @@ type playerImpl struct {
|
|||||||
eof bool
|
eof bool
|
||||||
cond *sync.Cond
|
cond *sync.Cond
|
||||||
started bool
|
started bool
|
||||||
|
volume float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type players struct {
|
type players struct {
|
||||||
@ -186,6 +187,7 @@ func (c *context) NewPlayer(src io.Reader) Player {
|
|||||||
context: c,
|
context: c,
|
||||||
src: src,
|
src: src,
|
||||||
cond: sync.NewCond(&sync.Mutex{}),
|
cond: sync.NewCond(&sync.Mutex{}),
|
||||||
|
volume: 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(p, (*player).Close)
|
runtime.SetFinalizer(p, (*player).Close)
|
||||||
@ -258,6 +260,9 @@ func (p *playerImpl) Play() {
|
|||||||
buf.mAudioDataByteSize = C.UInt32(size)
|
buf.mAudioDataByteSize = C.UInt32(size)
|
||||||
p.unqueuedBufs = append(p.unqueuedBufs, buf)
|
p.unqueuedBufs = append(p.unqueuedBufs, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
C.AudioQueueSetParameter(p.audioQueue, C.kAudioQueueParam_Volume, C.AudioQueueParameterValue(p.volume))
|
||||||
|
|
||||||
runLoop = true
|
runLoop = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,13 +379,28 @@ func (p *playerImpl) IsPlaying() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *player) Volume() float64 {
|
func (p *player) Volume() float64 {
|
||||||
// TODO: Implement this
|
return p.p.Volume()
|
||||||
// See AudioQueueSetParameter
|
}
|
||||||
return 1
|
|
||||||
|
func (p *playerImpl) Volume() float64 {
|
||||||
|
p.cond.L.Lock()
|
||||||
|
defer p.cond.L.Unlock()
|
||||||
|
return p.volume
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *player) SetVolume(volume float64) {
|
func (p *player) SetVolume(volume float64) {
|
||||||
// TODO: Implement this
|
p.p.SetVolume(volume)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *playerImpl) SetVolume(volume float64) {
|
||||||
|
p.cond.L.Lock()
|
||||||
|
defer p.cond.L.Unlock()
|
||||||
|
|
||||||
|
p.volume = volume
|
||||||
|
if p.audioQueue == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
C.AudioQueueSetParameter(p.audioQueue, C.kAudioQueueParam_Volume, C.AudioQueueParameterValue(volume))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *player) UnplayedBufferSize() int64 {
|
func (p *player) UnplayedBufferSize() int64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user