mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/cbackend: add AudioBufferSizeInSeconds
This commit is contained in:
parent
1799ed0b28
commit
e6131894a7
@ -71,8 +71,7 @@ func (c *Context) Err() error {
|
||||
}
|
||||
|
||||
func (c *Context) oneBufferSize() int {
|
||||
// TODO: This must be audio.oneBufferSize(p.context.sampleRate). Avoid the duplication.
|
||||
return c.sampleRate * c.channelNum * c.bitDepthInBytes / 4
|
||||
return int(float64(c.sampleRate*c.channelNum*c.bitDepthInBytes) * cbackend.AudioBufferSizeInSeconds())
|
||||
}
|
||||
|
||||
func (c *Context) MaxBufferSize() int {
|
||||
|
@ -51,6 +51,7 @@ package cbackend
|
||||
// void EbitenGetTouches(struct Touch* touches);
|
||||
//
|
||||
// // Audio
|
||||
// // TODO: Implement mixing on Go side and reduce the API.
|
||||
// typedef void (*OnWrittenCallback)(int id);
|
||||
// void EbitenOpenAudio(int sample_rate, int channel_num, int bit_depth_in_bytes);
|
||||
// void EbitenCloseAudio();
|
||||
@ -62,6 +63,7 @@ package cbackend
|
||||
// double EbitenAudioPlayerGetVolume(int id);
|
||||
// void EbitenAudioPlayerSetVolume(int id, double volume);
|
||||
// int EbitenAudioPlayerGetUnplayedBufferSize(int id);
|
||||
// float EbitenAudioBufferSizeInSeconds();
|
||||
//
|
||||
// void EbitenAudioPlayerOnWrittenCallback(int id);
|
||||
// static int EbitenCreateAudioPlayerProxy() {
|
||||
@ -187,6 +189,10 @@ func CreateAudioPlayer(onWritten func()) *AudioPlayer {
|
||||
return p
|
||||
}
|
||||
|
||||
func AudioBufferSizeInSeconds() float64 {
|
||||
return float64(C.EbitenAudioBufferSizeInSeconds())
|
||||
}
|
||||
|
||||
type AudioPlayer struct {
|
||||
id C.int
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user