|
@@ -365,12 +365,12 @@ Error AudioDriverWASAPI::init_capture_device(bool reinit) {
|
|
}
|
|
}
|
|
|
|
|
|
Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
|
|
Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
|
|
- if (p_device->active) {
|
|
|
|
|
|
+ if (p_device->active.is_set()) {
|
|
if (p_device->audio_client) {
|
|
if (p_device->audio_client) {
|
|
p_device->audio_client->Stop();
|
|
p_device->audio_client->Stop();
|
|
}
|
|
}
|
|
|
|
|
|
- p_device->active = false;
|
|
|
|
|
|
+ p_device->active.clear();
|
|
}
|
|
}
|
|
|
|
|
|
SAFE_RELEASE(p_device->audio_client)
|
|
SAFE_RELEASE(p_device->audio_client)
|
|
@@ -396,8 +396,7 @@ Error AudioDriverWASAPI::init() {
|
|
ERR_PRINT("WASAPI: init_render_device error");
|
|
ERR_PRINT("WASAPI: init_render_device error");
|
|
}
|
|
}
|
|
|
|
|
|
- exit_thread = false;
|
|
|
|
- thread_exited = false;
|
|
|
|
|
|
+ exit_thread.clear();
|
|
|
|
|
|
thread.start(thread_func, this);
|
|
thread.start(thread_func, this);
|
|
|
|
|
|
@@ -543,7 +542,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
|
uint32_t avail_frames = 0;
|
|
uint32_t avail_frames = 0;
|
|
uint32_t write_ofs = 0;
|
|
uint32_t write_ofs = 0;
|
|
|
|
|
|
- while (!ad->exit_thread) {
|
|
|
|
|
|
+ while (!ad->exit_thread.is_set()) {
|
|
uint32_t read_frames = 0;
|
|
uint32_t read_frames = 0;
|
|
uint32_t written_frames = 0;
|
|
uint32_t written_frames = 0;
|
|
|
|
|
|
@@ -551,7 +550,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
|
ad->lock();
|
|
ad->lock();
|
|
ad->start_counting_ticks();
|
|
ad->start_counting_ticks();
|
|
|
|
|
|
- if (ad->audio_output.active) {
|
|
|
|
|
|
+ if (ad->audio_output.active.is_set()) {
|
|
ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptrw());
|
|
ad->audio_server_process(ad->buffer_frames, ad->samples_in.ptrw());
|
|
} else {
|
|
} else {
|
|
for (int i = 0; i < ad->samples_in.size(); i++) {
|
|
for (int i = 0; i < ad->samples_in.size(); i++) {
|
|
@@ -617,7 +616,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
ERR_PRINT("WASAPI: Get buffer error");
|
|
ERR_PRINT("WASAPI: Get buffer error");
|
|
- ad->exit_thread = true;
|
|
|
|
|
|
+ ad->exit_thread.set();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
|
|
} else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
|
|
@@ -666,7 +665,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
|
write_ofs = 0;
|
|
write_ofs = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- if (ad->audio_input.active) {
|
|
|
|
|
|
+ if (ad->audio_input.active.is_set()) {
|
|
UINT32 packet_length = 0;
|
|
UINT32 packet_length = 0;
|
|
BYTE *data;
|
|
BYTE *data;
|
|
UINT32 num_frames_available;
|
|
UINT32 num_frames_available;
|
|
@@ -745,8 +744,6 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
|
|
OS::get_singleton()->delay_usec(1000);
|
|
OS::get_singleton()->delay_usec(1000);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- ad->thread_exited = true;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void AudioDriverWASAPI::start() {
|
|
void AudioDriverWASAPI::start() {
|
|
@@ -755,7 +752,7 @@ void AudioDriverWASAPI::start() {
|
|
if (hr != S_OK) {
|
|
if (hr != S_OK) {
|
|
ERR_PRINT("WASAPI: Start failed");
|
|
ERR_PRINT("WASAPI: Start failed");
|
|
} else {
|
|
} else {
|
|
- audio_output.active = true;
|
|
|
|
|
|
+ audio_output.active.set();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -769,7 +766,7 @@ void AudioDriverWASAPI::unlock() {
|
|
}
|
|
}
|
|
|
|
|
|
void AudioDriverWASAPI::finish() {
|
|
void AudioDriverWASAPI::finish() {
|
|
- exit_thread = true;
|
|
|
|
|
|
+ exit_thread.set();
|
|
thread.wait_to_finish();
|
|
thread.wait_to_finish();
|
|
|
|
|
|
finish_capture_device();
|
|
finish_capture_device();
|
|
@@ -783,19 +780,19 @@ Error AudioDriverWASAPI::capture_start() {
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
- if (audio_input.active) {
|
|
|
|
|
|
+ if (audio_input.active.is_set()) {
|
|
return FAILED;
|
|
return FAILED;
|
|
}
|
|
}
|
|
|
|
|
|
audio_input.audio_client->Start();
|
|
audio_input.audio_client->Start();
|
|
- audio_input.active = true;
|
|
|
|
|
|
+ audio_input.active.set();
|
|
return OK;
|
|
return OK;
|
|
}
|
|
}
|
|
|
|
|
|
Error AudioDriverWASAPI::capture_stop() {
|
|
Error AudioDriverWASAPI::capture_stop() {
|
|
- if (audio_input.active) {
|
|
|
|
|
|
+ if (audio_input.active.is_set()) {
|
|
audio_input.audio_client->Stop();
|
|
audio_input.audio_client->Stop();
|
|
- audio_input.active = false;
|
|
|
|
|
|
+ audio_input.active.clear();
|
|
|
|
|
|
return OK;
|
|
return OK;
|
|
}
|
|
}
|
|
@@ -827,9 +824,6 @@ AudioDriverWASAPI::AudioDriverWASAPI() {
|
|
channels = 0;
|
|
channels = 0;
|
|
mix_rate = 0;
|
|
mix_rate = 0;
|
|
buffer_frames = 0;
|
|
buffer_frames = 0;
|
|
-
|
|
|
|
- thread_exited = false;
|
|
|
|
- exit_thread = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#endif
|
|
#endif
|