commit 413906b20f533e1183035c2c1ec75274986e0907
parent cabae4b0d6c51cea8166eaca88f46cf154aa9ce7
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Sat, 19 Dec 2009 16:25:53 -0500
Nio: removing redundant variable threadStop
Diffstat:
7 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp
@@ -43,7 +43,6 @@ AlsaEngine::AlsaEngine(OutMgr *out)
// midi.pThread = 0;
pthread_mutex_init(&close_m, NULL);
- threadStop = true;
}
AlsaEngine::~AlsaEngine()
@@ -208,7 +207,6 @@ bool AlsaEngine::Start()
return false;
pthread_attr_t attr;
- threadStop = false;
enabled = true;
pthread_attr_init(&attr);
@@ -226,7 +224,6 @@ bool AlsaEngine::Start()
bail_out:
cerr << "Error - bail out of AlsaEngine::Start()" << endl;
Stop();
- threadStop = true;
return false;
}
@@ -235,7 +232,6 @@ void AlsaEngine::Stop()
{
if(!enabled())
return;
- threadStop = true;
enabled = false;
if (NULL != audio.handle && audio.pThread)
@@ -422,7 +418,7 @@ bool AlsaEngine::OpenStuff()
void AlsaEngine::RunStuff()
{
pthread_mutex_lock(&close_m);
- while (!threadStop()) {
+ while (enabled()) {
buffer = interleave(getNext());
rc = snd_pcm_writei(handle, buffer, SOUND_BUFFER_SIZE);
delete[] buffer;
diff --git a/src/Nio/AudioOut.cpp b/src/Nio/AudioOut.cpp
@@ -16,7 +16,6 @@
You should have received a copy of the GNU General Public License
along with yoshimi. If not, see <http://www.gnu.org/licenses/>.
*/
-#warning TODO remove threadStop in favor of enabled
#include <iostream>
#include <cstring>
@@ -28,7 +27,7 @@ using namespace std;
AudioOut::AudioOut(OutMgr *out)
:samplerate(SAMPLE_RATE),nsamples(SOUND_BUFFER_SIZE),
- manager(out),threadStop(false),enabled(false)
+ manager(out),enabled(false)
{
pthread_mutex_init(&outBuf_mutex, NULL);
pthread_cond_init (&outBuf_cv, NULL);
diff --git a/src/Nio/AudioOut.h b/src/Nio/AudioOut.h
@@ -75,7 +75,6 @@ class AudioOut
OutMgr *manager;
//thread resources
- Atomic<bool> threadStop;
pthread_t pThread;
Atomic<bool> enabled;
};
diff --git a/src/Nio/JackEngine.cpp b/src/Nio/JackEngine.cpp
@@ -109,6 +109,8 @@ bail_out:
void JackEngine::Stop()
{
+ if(!enabled())
+ return;
enabled = false;
if (jackClient)
{
diff --git a/src/Nio/NulEngine.cpp b/src/Nio/NulEngine.cpp
@@ -44,7 +44,7 @@ void *NulEngine::_AudioThread(void *arg)
void *NulEngine::AudioThread()
{
- while (!threadStop())
+ while (enabled())
{
const Stereo<Sample> smps = getNext();
dummyOut();
@@ -87,7 +87,6 @@ NulEngine::~NulEngine()
bool NulEngine::Start()
{
pthread_attr_t attr;
- threadStop = false;
enabled = true;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@@ -98,7 +97,6 @@ bool NulEngine::Start()
void NulEngine::Stop()
{
- threadStop = true;
enabled = false;
}
diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp
@@ -80,7 +80,6 @@ bool OssEngine::Start()
if(!openAudio())
return false;
pthread_attr_t attr;
- threadStop = false;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&pThread, &attr, _AudioThread, this);
@@ -92,7 +91,6 @@ bool OssEngine::Start()
void OssEngine::Stop()
{
- threadStop = true;
enabled = false;
close(snd_handle);
}
@@ -110,7 +108,7 @@ void *OssEngine::AudioThread()
manager->requestSamples();
manager->requestSamples();
set_realtime();
- while (!threadStop())
+ while (enabled())
{
const Stereo<Sample> smps = getNext();
OSSout(smps.l().c_buf(),smps.r().c_buf());
diff --git a/src/Nio/WavEngine.cpp b/src/Nio/WavEngine.cpp
@@ -54,7 +54,7 @@ bool WavEngine::openAudio()
bool WavEngine::Start()
{
pthread_attr_t attr;
- threadStop = false;
+ enabled = true;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&pThread, &attr, _AudioThread, this);
@@ -64,7 +64,7 @@ bool WavEngine::Start()
void WavEngine::Stop()
{
- threadStop = true;
+ enabled = false;
}
void WavEngine::Close()
@@ -145,7 +145,7 @@ void *WavEngine::AudioThread()
int size = SOUND_BUFFER_SIZE;
- while (!threadStop())
+ while (enabled())
{
const Stereo<Sample> smps = getNext();
for(int i = 0; i < size; i++) {