summaryrefslogtreecommitdiff
path: root/drivers/pulseaudio/audio_driver_pulseaudio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pulseaudio/audio_driver_pulseaudio.cpp')
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 440b7d7f53..01bed4e735 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -179,7 +179,7 @@ Error AudioDriverPulseAudio::init_device() {
break;
}
- int latency = GLOBAL_GET("audio/output_latency");
+ int latency = GLOBAL_GET("audio/driver/output_latency");
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
pa_buffer_size = buffer_frames * pa_map.channels;
@@ -233,11 +233,15 @@ Error AudioDriverPulseAudio::init_device() {
}
Error AudioDriverPulseAudio::init() {
+ if (initialize_pulse()) {
+ return ERR_CANT_OPEN;
+ }
+
active = false;
thread_exited = false;
exit_thread = false;
- mix_rate = GLOBAL_GET("audio/mix_rate");
+ mix_rate = GLOBAL_GET("audio/driver/mix_rate");
pa_ml = pa_mainloop_new();
ERR_FAIL_COND_V(pa_ml == nullptr, ERR_CANT_OPEN);
@@ -287,7 +291,7 @@ Error AudioDriverPulseAudio::init() {
Error err = init_device();
if (err == OK) {
- thread = Thread::create(AudioDriverPulseAudio::thread_func, this);
+ thread.start(AudioDriverPulseAudio::thread_func, this);
}
return OK;
@@ -581,16 +585,10 @@ void AudioDriverPulseAudio::set_device(String device) {
}
void AudioDriverPulseAudio::lock() {
- if (!thread) {
- return;
- }
mutex.lock();
}
void AudioDriverPulseAudio::unlock() {
- if (!thread) {
- return;
- }
mutex.unlock();
}
@@ -603,12 +601,12 @@ void AudioDriverPulseAudio::finish_device() {
}
void AudioDriverPulseAudio::finish() {
- if (!thread) {
+ if (!thread.is_started()) {
return;
}
exit_thread = true;
- Thread::wait_to_finish(thread);
+ thread.wait_to_finish();
finish_device();
@@ -622,10 +620,6 @@ void AudioDriverPulseAudio::finish() {
pa_mainloop_free(pa_ml);
pa_ml = nullptr;
}
-
- memdelete(thread);
-
- thread = nullptr;
}
Error AudioDriverPulseAudio::capture_init_device() {