mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/readdriver: Bug fix: Wait for a while after finishing to write
Closes #1632
This commit is contained in:
parent
ded3cd1433
commit
1fecaa0a90
5
audio/internal/oboe/binding_android.cpp
vendored
5
audio/internal/oboe/binding_android.cpp
vendored
@ -57,11 +57,6 @@ public:
|
||||
std::lock_guard<std::mutex> lock(GetPlayersMutex());
|
||||
GetPlayers().insert(this);
|
||||
}
|
||||
// Fill zeros with 1/60[s] as the first part to avoid noises (#1632).
|
||||
// 1/60[s] is an arbitrary duration and might need to be adjusted.
|
||||
size_t mul = channel_num_ * bit_depth_in_bytes_;
|
||||
size_t size = (sample_rate_ * channel_num_ * bit_depth_in_bytes_) / 60 / mul * mul;
|
||||
buf_.resize(size);
|
||||
}
|
||||
|
||||
void SetVolume(double volume) {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"io"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/audio/internal/oboe"
|
||||
)
|
||||
@ -268,6 +269,9 @@ func (p *player) loop() {
|
||||
|
||||
// Now p.p.Reset() doesn't close the stream gracefully. Then buffer size check is necessary here.
|
||||
if err == io.EOF && p.UnplayedBufferSize() == 0 {
|
||||
// Even when the unplayed buffer size is 0, the audio data in the hardware might not be played yet (#1632).
|
||||
// Just wait for a while.
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
p.Reset()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user