[Summary] Fixed windows issue with GLib atomic counter types

This commit is contained in:
Greg Zharun 2014-07-02 18:04:36 +03:00
parent cd4e856da4
commit a3ab8d9c52
2 changed files with 18 additions and 30 deletions

View file

@ -246,11 +246,11 @@ public:
bool _in_destructor; bool _in_destructor;
Glib::Threads::Thread* _hw_reset_event_thread; Glib::Threads::Thread* _hw_reset_event_thread;
uint16_t _hw_reset_request_count; gint _hw_reset_request_count;
bool _stop_hw_reset_processing; gint _stop_hw_reset_processing;
Glib::Threads::Thread* _hw_devicelist_update_thread; Glib::Threads::Thread* _hw_devicelist_update_thread;
uint16_t _hw_devicelist_update_count; gint _hw_devicelist_update_count;
uint16_t _stop_hw_devicelist_processing; gint _stop_hw_devicelist_processing;
void start_hw_event_processing(); void start_hw_event_processing();
void stop_hw_event_processing(); void stop_hw_event_processing();

View file

@ -82,10 +82,10 @@ AudioEngine::AudioEngine ()
, _in_destructor (false) , _in_destructor (false)
, _hw_reset_event_thread(0) , _hw_reset_event_thread(0)
, _hw_reset_request_count(0) , _hw_reset_request_count(0)
, _stop_hw_reset_processing(false) , _stop_hw_reset_processing(0)
, _hw_devicelist_update_thread(0) , _hw_devicelist_update_thread(0)
, _hw_devicelist_update_count(0) , _hw_devicelist_update_count(0)
, _stop_hw_devicelist_processing(false) , _stop_hw_devicelist_processing(0)
{ {
g_atomic_int_set (&m_meter_exit, 0); g_atomic_int_set (&m_meter_exit, 0);
start_hw_event_processing(); start_hw_event_processing();
@ -365,8 +365,7 @@ AudioEngine::process_callback (pframes_t nframes)
void void
AudioEngine::request_backend_reset() AudioEngine::request_backend_reset()
{ {
//g_atomic_int_inc(&_hw_reset_request_count); g_atomic_int_inc(&_hw_reset_request_count);
_hw_reset_request_count++;
} }
@ -379,8 +378,7 @@ AudioEngine::do_reset_backend()
if (_hw_reset_request_count && _backend) { if (_hw_reset_request_count && _backend) {
//g_atomic_int_dec_and_test (&_hw_reset_request_count); g_atomic_int_dec_and_test (&_hw_reset_request_count);
_hw_reset_request_count--;
// backup the device name // backup the device name
std::string name = _backend->device_name (); std::string name = _backend->device_name ();
@ -411,8 +409,7 @@ AudioEngine::do_reset_backend()
void void
AudioEngine::request_device_list_update() AudioEngine::request_device_list_update()
{ {
//g_atomic_int_inc (&_hw_devicelist_update_count); g_atomic_int_inc (&_hw_devicelist_update_count);
_hw_devicelist_update_count++;
} }
@ -423,8 +420,7 @@ AudioEngine::do_devicelist_update()
while (!_stop_hw_devicelist_processing) { while (!_stop_hw_devicelist_processing) {
if (_hw_devicelist_update_count) { if (_hw_devicelist_update_count) {
//g_atomic_int_dec_and_test (&_hw_devicelist_update_count); g_atomic_int_dec_and_test (&_hw_devicelist_update_count);
_hw_devicelist_update_count--;
DeviceListChanged (); /* EMIT SIGNAL */ DeviceListChanged (); /* EMIT SIGNAL */
} }
g_usleep(0); g_usleep(0);
@ -436,18 +432,14 @@ void
AudioEngine::start_hw_event_processing() AudioEngine::start_hw_event_processing()
{ {
if (_hw_reset_event_thread == 0) { if (_hw_reset_event_thread == 0) {
//g_atomic_int_set(&_hw_reset_request_count, 0); g_atomic_int_set(&_hw_reset_request_count, 0);
//g_atomic_int_set(&_stop_hw_reset_processing, 0); g_atomic_int_set(&_stop_hw_reset_processing, 0);
_hw_reset_request_count = 0;
_stop_hw_reset_processing = 0;
_hw_reset_event_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_reset_backend, this)); _hw_reset_event_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_reset_backend, this));
} }
if (_hw_devicelist_update_thread == 0) { if (_hw_devicelist_update_thread == 0) {
//g_atomic_int_set(&_hw_devicelist_update_count, 0); g_atomic_int_set(&_hw_devicelist_update_count, 0);
//g_atomic_int_set(&_stop_hw_devicelist_processing, 0); g_atomic_int_set(&_stop_hw_devicelist_processing, 0);
_hw_devicelist_update_count = 0;
_stop_hw_devicelist_processing = 0;
_hw_devicelist_update_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this)); _hw_devicelist_update_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this));
} }
} }
@ -457,19 +449,15 @@ void
AudioEngine::stop_hw_event_processing() AudioEngine::stop_hw_event_processing()
{ {
if (_hw_reset_event_thread) { if (_hw_reset_event_thread) {
//g_atomic_int_set(&_stop_hw_reset_processing, 1); g_atomic_int_set(&_stop_hw_reset_processing, 1);
//g_atomic_int_set(&_hw_reset_request_count, 0); g_atomic_int_set(&_hw_reset_request_count, 0);
_stop_hw_reset_processing = 1;
_hw_reset_request_count = 0;
_hw_reset_event_thread->join (); _hw_reset_event_thread->join ();
_hw_reset_event_thread = 0; _hw_reset_event_thread = 0;
} }
if (_hw_devicelist_update_thread) { if (_hw_devicelist_update_thread) {
//g_atomic_int_set(&_stop_hw_devicelist_processing, 1); g_atomic_int_set(&_stop_hw_devicelist_processing, 1);
//g_atomic_int_set(&_hw_devicelist_update_count, 0); g_atomic_int_set(&_hw_devicelist_update_count, 0);
_stop_hw_devicelist_processing = 1;
_hw_devicelist_update_count = 0;
_hw_devicelist_update_thread->join (); _hw_devicelist_update_thread->join ();
_hw_devicelist_update_thread = 0; _hw_devicelist_update_thread = 0;
} }