Thread names and cosmetics

This commit is contained in:
Bertrand Songis
2019-06-18 12:13:11 +02:00
parent ad13301389
commit afa69cb0c5
5 changed files with 92 additions and 82 deletions
+2 -1
View File
@@ -554,7 +554,8 @@ void StartAudioThread(int volumeGain)
struct sched_param sp;
sp.sched_priority = SCHED_RR;
pthread_attr_setschedparam(&attr, &sp);
pthread_create(&simuAudio.threadPid, &attr, &audioThread, NULL);
pthread_create(&simuAudio.threadPid, &attr, &audioThread, nullptr);
pthread_setname_np(simuAudio.threadPid, "audio");
return;
}
+10 -7
View File
@@ -20,8 +20,8 @@
#include "opentx.h"
const char * eepromFile = NULL;
FILE * fp = NULL;
const char * eepromFile = nullptr;
FILE * fp = nullptr;
uint32_t eeprom_pointer;
uint8_t * eeprom_buffer_data;
@@ -33,7 +33,7 @@ bool eeprom_thread_running = false;
#if defined(EEPROM_SIZE)
uint8_t eeprom[EEPROM_SIZE];
#else
uint8_t * eeprom = NULL;
uint8_t * eeprom = nullptr;
#endif
sem_t * eeprom_write_sem;
@@ -75,7 +75,7 @@ void * eeprom_thread_function(void *)
{
while (!sem_wait(eeprom_write_sem)) {
if (!eeprom_thread_running)
return NULL;
return nullptr;
assert(eeprom_buffer_size);
if (eeprom_read_operation) {
eepromReadBlock(eeprom_buffer_data, eeprom_pointer, eeprom_buffer_size);
@@ -162,17 +162,20 @@ void StartEepromThread(const char * filename)
sem_init(eeprom_write_sem, 0, 0);
#endif
if (!pthread_create(&eeprom_thread_pid, NULL, &eeprom_thread_function, NULL))
if (!pthread_create(&eeprom_thread_pid, nullptr, &eeprom_thread_function, nullptr)) {
pthread_setname_np(eeprom_thread_pid, "eeprom");
eeprom_thread_running = true;
else
}
else {
perror("Could not create eeprom thread.");
}
}
void StopEepromThread()
{
eeprom_thread_running = false;
sem_post(eeprom_write_sem);
pthread_join(eeprom_thread_pid, NULL);
pthread_join(eeprom_thread_pid, nullptr);
#ifdef __APPLE__
sem_close(eeprom_write_sem);