diff --git a/audio/internal/oboe/binding_android.cpp b/audio/internal/oboe/binding_android.cpp index 9dad400cd..1390e0be6 100644 --- a/audio/internal/oboe/binding_android.cpp +++ b/audio/internal/oboe/binding_android.cpp @@ -57,11 +57,6 @@ public: std::lock_guard 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) { diff --git a/audio/internal/readerdriver/driver_android.go b/audio/internal/readerdriver/driver_android.go index 1ec97fe89..a6fbac669 100644 --- a/audio/internal/readerdriver/driver_android.go +++ b/audio/internal/readerdriver/driver_android.go @@ -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 }