Skip to content

Commit

Permalink
Merge pull request #21 from th1000s/misc_linux
Browse files Browse the repository at this point in the history
Linux build fixes: remove unused osMutex code and typedefs
  • Loading branch information
Lgt2x authored Apr 17, 2024
2 parents 7111a6f + 73cde6e commit 8592b5f
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 130 deletions.
6 changes: 3 additions & 3 deletions Descent3/newui_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ class newuiHotspot;

#define DEFAULT_NEWUID -5

typedef enum tAlignment { NEWUI_ALIGN_VERT, NEWUI_ALIGN_HORIZ };
enum tAlignment { NEWUI_ALIGN_VERT, NEWUI_ALIGN_HORIZ };

#define SLIDER_UNITS_INT 0
#define SLIDER_UNITS_PERCENT 1
#define SLIDER_UNITS_FLOAT 2

// used optionally for sliders.
typedef struct tSliderSettings {
struct tSliderSettings {
union {
int i;
float f;
Expand All @@ -157,7 +157,7 @@ typedef struct tSliderSettings {
float f;
} max_val;
int type; // enumerated above in SLIDER_UNITS
} tSliderStruct;
};

#define NEWUI_EDIT_CANCELED_STR "\1" // if a newuiEditbox returns this, then we cancelled. invalid string

Expand Down
28 changes: 0 additions & 28 deletions lib/TaskSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,4 @@ class osTask {
void resume(); // resumes task
};

// This establishes a mutual exclusion object. once one thread locks the object,
// any code in another thread that contains a mutex check will block or skip that code until
// the locking thread unlocks it.
class osMutex {
#if defined(DD_ACCESS_RING)
public:
#else
private:
#endif

#if defined(WIN32)
unsigned mutex_os_handle;
#endif

public:
osMutex();
~osMutex();

bool Create(); // creates a mutex object.
void Destroy(); // destroys a mutex object

// calling thread will attempt to acquire mutex (wait until timeout in ms.) if timeout == -1, wait forever...
bool Acquire(int timeout = -1);

// calling thread releases control of mutex.
void Release();
};

#endif
1 change: 0 additions & 1 deletion lib/streamaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ class AudioStream {
int m_playbytesleft, m_playbytestotal;
int m_curid; // stream's id #
int *m_stopflag; // location of stop flag used in stop function
osMutex m_loopmutex; // stop flag is manipulated by caller and stream thread.
bool m_loop; // are we looping?
bool m_stopnextmeasure; // stop on next measure.
bool m_start_on_frame; // we will play this stream on the next ::Frame call.
Expand Down
3 changes: 3 additions & 0 deletions libmve/snd8to16.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
#pragma warning(disable : 4245)
#pragma warning(disable : 4309)
#pragma GCC diagnostic ignored "-Wnarrowing"

signed short snd_8to16[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
Expand All @@ -35,5 +36,7 @@ signed short snd_8to16[256] = {
-32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19,
-18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5,
-4, -3, -2, -1};

#pragma GCC diagnostic pop
#pragma warning(default : 4245)
#pragma warning(default : 4309)
1 change: 0 additions & 1 deletion linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ SET (CPPS
lnxcon.cpp
lnxcon_raw.cpp
lnxdebug.cpp
lnxtask.cpp
lnxapp.cpp
lnxcon_null.cpp
lnxdata.cpp
Expand Down
34 changes: 0 additions & 34 deletions linux/lnxtask.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions mac/MACSTREAMAUDIO.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ bool AudioStream::Open(const char *filename, int open_flags) {
return false;
}

m_loopmutex.Create();
AudioStream::SetLoopCount(1);
m_laststate = m_state;
mprintf((1, "opening: STRM[%d]: STOPPED sof %d\n", this->m_curid, m_start_on_frame));
Expand All @@ -497,7 +496,6 @@ void AudioStream::Close() {
// stop the stream, close the archive, close the decoder.
AudioStream::Stop();
m_archive.Close();
m_loopmutex.Destroy();
m_curid = -1;

// free streaming buffers and decoder if we need to.
Expand Down
9 changes: 0 additions & 9 deletions mac/MACTASK.CPP

This file was deleted.

1 change: 0 additions & 1 deletion netcon/includes/inetgetfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
// Linux includes/defines
#if !MACOSX
#include <linux/types.h>
#include <linux/ipx.h>
// #include <linux/if.h>
#endif

Expand Down
2 changes: 0 additions & 2 deletions stream_audio/streamaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ bool AudioStream::Open(const char *filename, int open_flags) {
if (!AudioStream::ReopenDigitalStream(0, nbufs)) {
return false;
}
m_loopmutex.Create();
AudioStream::SetLoopCount(1);
m_laststate = m_state;
m_state = STRM_STOPPED;
Expand All @@ -383,7 +382,6 @@ void AudioStream::Close() {
// stop the stream, close the archive, close the decoder.
AudioStream::Stop();
m_archive.Close();
m_loopmutex.Destroy();
m_curid = -1;
// free streaming buffers and decoder if we need to.
for (i = 0; i < STRM_BUFCOUNT; i++) {
Expand Down
49 changes: 0 additions & 49 deletions win32/wintask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,52 +131,3 @@ bool osEvent::error() const {
else
return 0;
}

// This establishes a mutual exclusion object. once one thread locks the object,
// any code in another thread that contains a mutex check will block or skip that code until
// the locking thread unlocks it.
osMutex::osMutex() { mutex_os_handle = 0; }

osMutex::~osMutex() { Destroy(); }

bool osMutex::Create() // creates a mutex object.
{
if (!mutex_os_handle) {
mutex_os_handle = (unsigned)CreateMutex(NULL, FALSE, NULL);
return mutex_os_handle ? true : false;
}

return false;
}

void osMutex::Destroy() // destroys a mutex object
{
if (mutex_os_handle) {
CloseHandle((HANDLE)mutex_os_handle);
mutex_os_handle = 0;
}
}

// calling thread will attempt to acquire mutex (wait until timeout) if timeout == -1, wait forever...
bool osMutex::Acquire(int timeout) {
DWORD res;

if (!mutex_os_handle)
return true; // we should return true because the caller will skip code if false is returned.

if (timeout == -1)
timeout = INFINITE;

res = WaitForSingleObject((HANDLE)mutex_os_handle, timeout);
if (res == WAIT_OBJECT_0 || res == WAIT_ABANDONED)
return true;
else
return false;
}

// calling thread releases control of mutex.
void osMutex::Release() {
if (mutex_os_handle) {
ReleaseMutex((HANDLE)mutex_os_handle);
}
}

0 comments on commit 8592b5f

Please sign in to comment.