Skip to content

Commit

Permalink
Remove unused osMutex code
Browse files Browse the repository at this point in the history
It was never Acquire'd, only Created and Destroyed; and it was
a stub on Linux and macOS.
  • Loading branch information
th1000s committed Apr 16, 2024
1 parent 5b99453 commit 7181cad
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 126 deletions.
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
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.

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 7181cad

Please sign in to comment.