mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/oboe: Bug fix: Opening a stream might fail when too many streams are opened
openStream might fail when too many streams are opened in a short time. In this case, sleep 1[ms] and retry to open the stream. Updates #1549 Closes #1645
This commit is contained in:
parent
1dd48388b4
commit
58c1ed0e23
12
audio/internal/oboe/binding_android.cpp
vendored
12
audio/internal/oboe/binding_android.cpp
vendored
@ -84,6 +84,8 @@ public:
|
||||
return "bit_depth_in_bytes_ must be 2 but not";
|
||||
}
|
||||
|
||||
int retry_count = 0;
|
||||
retry:
|
||||
if (!stream_) {
|
||||
oboe::AudioStreamBuilder builder;
|
||||
oboe::Result result =
|
||||
@ -96,6 +98,16 @@ public:
|
||||
->setDataCallback(this)
|
||||
->openStream(stream_);
|
||||
if (result != oboe::Result::OK) {
|
||||
// openStream might fail with oboe::Result::ErrorInternal when too many
|
||||
// streams are opened in a short time (#1645).
|
||||
if (result == oboe::Result::ErrorInternal && retry_count < 100) {
|
||||
retry_count++;
|
||||
// Sleep 10[ms]
|
||||
timespec ts = {};
|
||||
ts.tv_nsec = 10000000;
|
||||
nanosleep(&ts, nullptr);
|
||||
goto retry;
|
||||
}
|
||||
return oboe::convertToText(result);
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ import (
|
||||
)
|
||||
|
||||
func IsAvailable() bool {
|
||||
// Disable the reader driver for Android temporarily (#1645).
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
type context struct {
|
||||
|
Loading…
Reference in New Issue
Block a user