mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/oboe: Add prefixes to the C functions
This commit is contained in:
parent
fc8b3d70fe
commit
bb4a3ce89b
24
audio/internal/oboe/binding_android.cpp
vendored
24
audio/internal/oboe/binding_android.cpp
vendored
@ -208,50 +208,52 @@ private:
|
||||
|
||||
extern "C" {
|
||||
|
||||
const char *Suspend() { return Player::Suspend(); }
|
||||
const char *ebiten_oboe_Suspend() { return Player::Suspend(); }
|
||||
|
||||
const char *Resume() { return Player::Resume(); }
|
||||
const char *ebiten_oboe_Resume() { return Player::Resume(); }
|
||||
|
||||
PlayerID Player_Create(int sample_rate, int channel_num, int bit_depth_in_bytes,
|
||||
double volume, uintptr_t go_player) {
|
||||
PlayerID ebiten_oboe_Player_Create(int sample_rate, int channel_num,
|
||||
int bit_depth_in_bytes, double volume,
|
||||
uintptr_t go_player) {
|
||||
Player *p = new Player(sample_rate, channel_num, bit_depth_in_bytes, volume,
|
||||
go_player);
|
||||
return reinterpret_cast<PlayerID>(p);
|
||||
}
|
||||
|
||||
bool Player_IsPlaying(PlayerID audio_player) {
|
||||
bool ebiten_oboe_Player_IsPlaying(PlayerID audio_player) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
return p->IsPlaying();
|
||||
}
|
||||
|
||||
void Player_AppendBuffer(PlayerID audio_player, uint8_t *data, int length) {
|
||||
void ebiten_oboe_Player_AppendBuffer(PlayerID audio_player, uint8_t *data,
|
||||
int length) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
p->AppendBuffer(data, length);
|
||||
}
|
||||
|
||||
const char *Player_Play(PlayerID audio_player) {
|
||||
const char *ebiten_oboe_Player_Play(PlayerID audio_player) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
return p->Play();
|
||||
}
|
||||
|
||||
const char *Player_Pause(PlayerID audio_player) {
|
||||
const char *ebiten_oboe_Player_Pause(PlayerID audio_player) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
return p->Pause();
|
||||
}
|
||||
|
||||
void Player_SetVolume(PlayerID audio_player, double volume) {
|
||||
void ebiten_oboe_Player_SetVolume(PlayerID audio_player, double volume) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
p->SetVolume(volume);
|
||||
}
|
||||
|
||||
const char *Player_Close(PlayerID audio_player) {
|
||||
const char *ebiten_oboe_Player_Close(PlayerID audio_player) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
const char *msg = p->CloseAndRemove();
|
||||
delete p;
|
||||
return msg;
|
||||
}
|
||||
|
||||
int Player_UnplayedBufferSize(PlayerID audio_player) {
|
||||
int ebiten_oboe_Player_UnplayedBufferSize(PlayerID audio_player) {
|
||||
Player *p = reinterpret_cast<Player *>(audio_player);
|
||||
return p->GetUnplayedBufferSize();
|
||||
}
|
||||
|
20
audio/internal/oboe/binding_android.go
vendored
20
audio/internal/oboe/binding_android.go
vendored
@ -31,14 +31,14 @@ import (
|
||||
)
|
||||
|
||||
func Suspend() error {
|
||||
if msg := C.Suspend(); msg != nil {
|
||||
if msg := C.ebiten_oboe_Suspend(); msg != nil {
|
||||
return fmt.Errorf("oboe: Suspend failed: %s", C.GoString(msg))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Resume() error {
|
||||
if msg := C.Resume(); msg != nil {
|
||||
if msg := C.ebiten_oboe_Resume(); msg != nil {
|
||||
return fmt.Errorf("oboe: Resume failed: %s", C.GoString(msg))
|
||||
}
|
||||
return nil
|
||||
@ -53,7 +53,7 @@ func NewPlayer(sampleRate, channelNum, bitDepthInBytes int, volume float64, onWr
|
||||
p := &Player{
|
||||
onWritten: onWritten,
|
||||
}
|
||||
p.player = C.Player_Create(C.int(sampleRate), C.int(channelNum), C.int(bitDepthInBytes), C.double(volume), C.uintptr_t(uintptr(unsafe.Pointer(p))))
|
||||
p.player = C.ebiten_oboe_Player_Create(C.int(sampleRate), C.int(channelNum), C.int(bitDepthInBytes), C.double(volume), C.uintptr_t(uintptr(unsafe.Pointer(p))))
|
||||
runtime.SetFinalizer(p, (*Player).Close)
|
||||
return p
|
||||
}
|
||||
@ -65,21 +65,21 @@ func onWrittenCallback(player C.uintptr_t) {
|
||||
}
|
||||
|
||||
func (p *Player) IsPlaying() bool {
|
||||
return bool(C.Player_IsPlaying(p.player))
|
||||
return bool(C.ebiten_oboe_Player_IsPlaying(p.player))
|
||||
}
|
||||
|
||||
func (p *Player) AppendBuffer(buf []byte) {
|
||||
ptr := C.CBytes(buf)
|
||||
defer C.free(ptr)
|
||||
|
||||
C.Player_AppendBuffer(p.player, (*C.uint8_t)(ptr), C.int(len(buf)))
|
||||
C.ebiten_oboe_Player_AppendBuffer(p.player, (*C.uint8_t)(ptr), C.int(len(buf)))
|
||||
}
|
||||
|
||||
func (p *Player) Play() error {
|
||||
if p.player == 0 {
|
||||
return fmt.Errorf("oboe: player is already closed at Play")
|
||||
}
|
||||
if msg := C.Player_Play(p.player); msg != nil {
|
||||
if msg := C.ebiten_oboe_Player_Play(p.player); msg != nil {
|
||||
return fmt.Errorf("oboe: Player_Play failed: %s", C.GoString(msg))
|
||||
}
|
||||
return nil
|
||||
@ -89,14 +89,14 @@ func (p *Player) Pause() error {
|
||||
if p.player == 0 {
|
||||
return fmt.Errorf("oboe: player is already closed at Pause")
|
||||
}
|
||||
if msg := C.Player_Pause(p.player); msg != nil {
|
||||
if msg := C.ebiten_oboe_Player_Pause(p.player); msg != nil {
|
||||
return fmt.Errorf("oboe: Player_Pause failed: %s", C.GoString(msg))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Player) SetVolume(volume float64) {
|
||||
C.Player_SetVolume(p.player, C.double(volume))
|
||||
C.ebiten_oboe_Player_SetVolume(p.player, C.double(volume))
|
||||
}
|
||||
|
||||
func (p *Player) Close() error {
|
||||
@ -104,7 +104,7 @@ func (p *Player) Close() error {
|
||||
if p.player == 0 {
|
||||
return fmt.Errorf("oboe: player is already closed at Close")
|
||||
}
|
||||
if msg := C.Player_Close(p.player); msg != nil {
|
||||
if msg := C.ebiten_oboe_Player_Close(p.player); msg != nil {
|
||||
return fmt.Errorf("oboe: Player_Close failed: %s", C.GoString(msg))
|
||||
}
|
||||
p.player = 0
|
||||
@ -112,5 +112,5 @@ func (p *Player) Close() error {
|
||||
}
|
||||
|
||||
func (p *Player) UnplayedBufferSize() int {
|
||||
return int(C.Player_UnplayedBufferSize(p.player))
|
||||
return int(C.ebiten_oboe_Player_UnplayedBufferSize(p.player))
|
||||
}
|
||||
|
24
audio/internal/oboe/binding_android.h
vendored
24
audio/internal/oboe/binding_android.h
vendored
@ -25,17 +25,19 @@ extern "C" {
|
||||
|
||||
typedef uintptr_t PlayerID;
|
||||
|
||||
const char *Suspend();
|
||||
const char *Resume();
|
||||
PlayerID Player_Create(int sample_rate, int channel_num, int bit_depth_in_bytes,
|
||||
double volume, uintptr_t go_player);
|
||||
bool Player_IsPlaying(PlayerID audio_player);
|
||||
void Player_AppendBuffer(PlayerID audio_player, uint8_t *data, int length);
|
||||
const char *Player_Play(PlayerID audio_player);
|
||||
const char *Player_Pause(PlayerID audio_player);
|
||||
const char *Player_Close(PlayerID audio_player);
|
||||
void Player_SetVolume(PlayerID audio_player, double volume);
|
||||
int Player_UnplayedBufferSize(PlayerID audio_player);
|
||||
const char *ebiten_oboe_Suspend();
|
||||
const char *ebiten_oboe_Resume();
|
||||
PlayerID ebiten_oboe_Player_Create(int sample_rate, int channel_num,
|
||||
int bit_depth_in_bytes, double volume,
|
||||
uintptr_t go_player);
|
||||
bool ebiten_oboe_Player_IsPlaying(PlayerID audio_player);
|
||||
void ebiten_oboe_Player_AppendBuffer(PlayerID audio_player, uint8_t *data,
|
||||
int length);
|
||||
const char *ebiten_oboe_Player_Play(PlayerID audio_player);
|
||||
const char *ebiten_oboe_Player_Pause(PlayerID audio_player);
|
||||
const char *ebiten_oboe_Player_Close(PlayerID audio_player);
|
||||
void ebiten_oboe_Player_SetVolume(PlayerID audio_player, double volume);
|
||||
int ebiten_oboe_Player_UnplayedBufferSize(PlayerID audio_player);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user