@@ -365,12 +365,12 @@ Error AudioDriverWASAPI::init_capture_device(bool reinit) {
365365}
366366
367367Error AudioDriverWASAPI::audio_device_finish (AudioDeviceWASAPI *p_device) {
368- if (p_device->active ) {
368+ if (p_device->active . is_set () ) {
369369 if (p_device->audio_client ) {
370370 p_device->audio_client ->Stop ();
371371 }
372372
373- p_device->active = false ;
373+ p_device->active . clear () ;
374374 }
375375
376376 SAFE_RELEASE (p_device->audio_client )
@@ -396,8 +396,7 @@ Error AudioDriverWASAPI::init() {
396396 ERR_PRINT (" WASAPI: init_render_device error" );
397397 }
398398
399- exit_thread = false ;
400- thread_exited = false ;
399+ exit_thread.clear ();
401400
402401 thread.start (thread_func, this );
403402
@@ -543,15 +542,15 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
543542 uint32_t avail_frames = 0 ;
544543 uint32_t write_ofs = 0 ;
545544
546- while (!ad->exit_thread ) {
545+ while (!ad->exit_thread . is_set () ) {
547546 uint32_t read_frames = 0 ;
548547 uint32_t written_frames = 0 ;
549548
550549 if (avail_frames == 0 ) {
551550 ad->lock ();
552551 ad->start_counting_ticks ();
553552
554- if (ad->audio_output .active ) {
553+ if (ad->audio_output .active . is_set () ) {
555554 ad->audio_server_process (ad->buffer_frames , ad->samples_in .ptrw ());
556555 } else {
557556 for (int i = 0 ; i < ad->samples_in .size (); i++) {
@@ -617,7 +616,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
617616 }
618617 } else {
619618 ERR_PRINT (" WASAPI: Get buffer error" );
620- ad->exit_thread = true ;
619+ ad->exit_thread . set () ;
621620 }
622621 }
623622 } else if (hr == AUDCLNT_E_DEVICE_INVALIDATED) {
@@ -666,7 +665,7 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
666665 write_ofs = 0 ;
667666 }
668667
669- if (ad->audio_input .active ) {
668+ if (ad->audio_input .active . is_set () ) {
670669 UINT32 packet_length = 0 ;
671670 BYTE *data;
672671 UINT32 num_frames_available;
@@ -745,8 +744,6 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
745744 OS::get_singleton ()->delay_usec (1000 );
746745 }
747746 }
748-
749- ad->thread_exited = true ;
750747}
751748
752749void AudioDriverWASAPI::start () {
@@ -755,7 +752,7 @@ void AudioDriverWASAPI::start() {
755752 if (hr != S_OK) {
756753 ERR_PRINT (" WASAPI: Start failed" );
757754 } else {
758- audio_output.active = true ;
755+ audio_output.active . set () ;
759756 }
760757 }
761758}
@@ -769,7 +766,7 @@ void AudioDriverWASAPI::unlock() {
769766}
770767
771768void AudioDriverWASAPI::finish () {
772- exit_thread = true ;
769+ exit_thread. set () ;
773770 thread.wait_to_finish ();
774771
775772 finish_capture_device ();
@@ -783,19 +780,19 @@ Error AudioDriverWASAPI::capture_start() {
783780 return err;
784781 }
785782
786- if (audio_input.active ) {
783+ if (audio_input.active . is_set () ) {
787784 return FAILED;
788785 }
789786
790787 audio_input.audio_client ->Start ();
791- audio_input.active = true ;
788+ audio_input.active . set () ;
792789 return OK;
793790}
794791
795792Error AudioDriverWASAPI::capture_stop () {
796- if (audio_input.active ) {
793+ if (audio_input.active . is_set () ) {
797794 audio_input.audio_client ->Stop ();
798- audio_input.active = false ;
795+ audio_input.active . clear () ;
799796
800797 return OK;
801798 }
@@ -827,9 +824,6 @@ AudioDriverWASAPI::AudioDriverWASAPI() {
827824 channels = 0 ;
828825 mix_rate = 0 ;
829826 buffer_frames = 0 ;
830-
831- thread_exited = false ;
832- exit_thread = false ;
833827}
834828
835829#endif
0 commit comments