mirror of https://github.com/auygun/kaliber.git
fix audio
This commit is contained in:
parent
41bb5e286a
commit
5cad50bf55
|
@ -164,7 +164,8 @@ int AudioDriverAlsa::GetHardwareSampleRate() {
|
||||||
void AudioDriverAlsa::StartAudioThread() {
|
void AudioDriverAlsa::StartAudioThread() {
|
||||||
LOG << "Starting audio thread.";
|
LOG << "Starting audio thread.";
|
||||||
terminate_audio_thread_.store(false, std::memory_order_relaxed);
|
terminate_audio_thread_.store(false, std::memory_order_relaxed);
|
||||||
suspend_audio_thread_.store(true, std::memory_order_relaxed);
|
suspend_audio_thread_.store(delegate_ ? false : true,
|
||||||
|
std::memory_order_relaxed);
|
||||||
audio_thread_ = std::thread(&AudioDriverAlsa::AudioThreadMain, this);
|
audio_thread_ = std::thread(&AudioDriverAlsa::AudioThreadMain, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@ AudioDriverOboe::~AudioDriverOboe() = default;
|
||||||
|
|
||||||
void AudioDriverOboe::SetDelegate(AudioDriverDelegate* delegate) {
|
void AudioDriverOboe::SetDelegate(AudioDriverDelegate* delegate) {
|
||||||
delegate_ = delegate;
|
delegate_ = delegate;
|
||||||
Resume();
|
stream_->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioDriverOboe::Initialize() {
|
bool AudioDriverOboe::Initialize() {
|
||||||
LOG << "Initializing audio system.";
|
LOG << "Initializing audio system.";
|
||||||
|
|
||||||
return RestartStream(true);
|
return RestartStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDriverOboe::Shutdown() {
|
void AudioDriverOboe::Shutdown() {
|
||||||
|
@ -31,11 +31,11 @@ void AudioDriverOboe::Shutdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDriverOboe::Suspend() {
|
void AudioDriverOboe::Suspend() {
|
||||||
stream_->stop();
|
stream_->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDriverOboe::Resume() {
|
void AudioDriverOboe::Resume() {
|
||||||
RestartStream();
|
stream_->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioDriverOboe::GetHardwareSampleRate() {
|
int AudioDriverOboe::GetHardwareSampleRate() {
|
||||||
|
@ -64,7 +64,7 @@ void AudioDriverOboe::StreamCallback::onErrorAfterClose(
|
||||||
driver_->RestartStream();
|
driver_->RestartStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioDriverOboe::RestartStream(bool suspended) {
|
bool AudioDriverOboe::RestartStream() {
|
||||||
oboe::AudioStreamBuilder builder;
|
oboe::AudioStreamBuilder builder;
|
||||||
oboe::Result result =
|
oboe::Result result =
|
||||||
builder.setSharingMode(oboe::SharingMode::Exclusive)
|
builder.setSharingMode(oboe::SharingMode::Exclusive)
|
||||||
|
@ -88,7 +88,7 @@ bool AudioDriverOboe::RestartStream(bool suspended) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!suspended)
|
if (delegate_)
|
||||||
stream_->start();
|
stream_->start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class AudioDriverOboe final : public AudioDriver {
|
||||||
|
|
||||||
AudioDriverDelegate* delegate_ = nullptr;
|
AudioDriverDelegate* delegate_ = nullptr;
|
||||||
|
|
||||||
bool RestartStream(bool suspended = false);
|
bool RestartStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace eng
|
} // namespace eng
|
||||||
|
|
Loading…
Reference in New Issue