summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configfile.cc3
-rw-r--r--src/drumkit.h4
-rw-r--r--src/drumkitloader.h10
-rw-r--r--src/instrumentparser.h8
-rw-r--r--src/semaphore.cc6
-rw-r--r--src/semaphore.h4
-rw-r--r--src/thread.cc40
-rw-r--r--src/thread.h14
8 files changed, 39 insertions, 50 deletions
diff --git a/src/configfile.cc b/src/configfile.cc
index 6b0d14f..8447d9a 100644
--- a/src/configfile.cc
+++ b/src/configfile.cc
@@ -30,6 +30,7 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -65,7 +66,7 @@ static std::string configPath()
configpath = szPath;
}
#else
- std::string configpath = strdup(getenv("HOME"));
+ std::string configpath = getenv("HOME");
#endif
configpath += SEP;
configpath += CONFIGDIRNAME;
diff --git a/src/drumkit.h b/src/drumkit.h
index 04b2c56..a9ceb80 100644
--- a/src/drumkit.h
+++ b/src/drumkit.h
@@ -56,13 +56,13 @@ public:
size_t samplerate();
private:
- void *magic;
+ void *magic{nullptr};
std::string _file;
std::string _name;
std::string _description;
- size_t _samplerate;
+ size_t _samplerate{0};
VersionStr _version;
};
diff --git a/src/drumkitloader.h b/src/drumkitloader.h
index 550d885..22859a0 100644
--- a/src/drumkitloader.h
+++ b/src/drumkitloader.h
@@ -92,13 +92,13 @@ private:
Semaphore semaphore;
Semaphore framesize_semaphore;
Mutex mutex;
- volatile bool running;
+ volatile bool running{false};
std::list<AudioFile*> load_queue;
- size_t total_num_audiofiles;
- size_t fraction;
- size_t loaded;
+ size_t total_num_audiofiles{0};
+ size_t fraction{1};
+ size_t loaded{0};
- size_t framesize;
+ size_t framesize{0};
};
#endif/*__DRUMGIZMO_DRUMKITLOADER_H__*/
diff --git a/src/instrumentparser.h b/src/instrumentparser.h
index 2a7a9c9..60a6261 100644
--- a/src/instrumentparser.h
+++ b/src/instrumentparser.h
@@ -47,14 +47,14 @@ protected:
int readData(char *data, size_t size);
private:
- FILE *fd;
+ FILE *fd{nullptr};
Instrument &instrument;
- Sample *s;
+ Sample *s{nullptr};
std::string path;
- level_t lower;
- level_t upper;
+ level_t lower{0};
+ level_t upper{0};
};
#endif/*__DRUMGIZMO_INSTRUMENTPARSER_H__*/
diff --git a/src/semaphore.cc b/src/semaphore.cc
index b478eb1..2bd244c 100644
--- a/src/semaphore.cc
+++ b/src/semaphore.cc
@@ -28,6 +28,8 @@
#include <hugin.hpp>
+#include <limits>
+
#ifdef WIN32
#include <windows.h>
#else
@@ -53,7 +55,7 @@ Semaphore::Semaphore(const char *name)
#ifdef WIN32
prv->semaphore = CreateSemaphore(NULL, // default security attributes
0, // initial count
- 2147483647, // maximum count (Max LONG)
+ std::numeric_limits<LONG>::max(),
NULL); // unnamed semaphore
#else
sem_init(&prv->semaphore, 0, 0);
@@ -70,7 +72,7 @@ Semaphore::~Semaphore()
sem_destroy(&prv->semaphore);
#endif
- if(prv) delete prv;
+ delete prv;
}
void Semaphore::post()
diff --git a/src/semaphore.h b/src/semaphore.h
index 7e39f5a..ed284de 100644
--- a/src/semaphore.h
+++ b/src/semaphore.h
@@ -38,8 +38,8 @@ public:
void wait();
private:
- struct semaphore_private_t *prv;
- const char *name;
+ struct semaphore_private_t *prv{nullptr};
+ const char *name{nullptr};
};
#endif/*__PRACRO_SEMAPHORE_H__*/
diff --git a/src/thread.cc b/src/thread.cc
index 8abf3cb..6e216e9 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -29,18 +29,6 @@
#include <stdio.h>
#include <hugin.hpp>
-#ifdef WIN32
-static DWORD WINAPI thread_run(void *data)
-#else
-static void* thread_run(void *data)
-#endif/*WIN32*/
-{
- DEBUG(thread, "Thread run\n");
- Thread *t = (Thread*)data;
- t->thread_main();
- return 0;
-}
-
Thread::Thread()
{}
@@ -66,19 +54,15 @@ void Thread::wait_stop()
#endif/*WIN32*/
}
-#ifdef TEST_THREAD
-//Additional dependency files
-//deps:
-//Required cflags (autoconf vars may be used)
-//cflags:
-//Required link options (autoconf vars may be used)
-//libs:
-#include "test.h"
-
-TEST_BEGIN;
-
-// TODO: Put some testcode here (see test.h for usable macros).
-
-TEST_END;
-
-#endif/*TEST_THREAD*/
+#ifdef WIN32
+DWORD WINAPI
+#else
+void*
+#endif/*WIN32*/
+Thread::thread_run(void *data)
+{
+ DEBUG(thread, "Thread run\n");
+ Thread *t = (Thread*)data;
+ t->thread_main();
+ return 0;
+}
diff --git a/src/thread.h b/src/thread.h
index 837222a..33435e6 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -24,10 +24,10 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#ifndef __DRUMGIZMO_THREAD_H__
-#define __DRUMGIZMO_THREAD_H__
+#pragma once
#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <pthread.h>
@@ -41,14 +41,16 @@ public:
void run();
void wait_stop();
+protected:
virtual void thread_main() = 0;
private:
#ifdef WIN32
- HANDLE tid;
+ HANDLE tid{nullptr};
+ static DWORD WINAPI
#else
- pthread_t tid;
+ pthread_t tid{0};
+ static void*
#endif/*WIN32*/
+ thread_run(void *data);
};
-
-#endif/*__DRUMGIZMO_THREAD_H__*/