summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/zalsa/alsathread.cc10
-rw-r--r--tools/zalsa/pxthread.cc9
-rw-r--r--tools/zalsa/pxthread.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/tools/zalsa/alsathread.cc b/tools/zalsa/alsathread.cc
index 1ce5dd93..bb5cf75b 100644
--- a/tools/zalsa/alsathread.cc
+++ b/tools/zalsa/alsathread.cc
@@ -45,7 +45,15 @@ Alsathread::Alsathread (Alsa_pcmi *alsadev, int mode) :
Alsathread::~Alsathread (void)
{
- _alsadev->pcm_stop ();
+ if (_state != INIT)
+ {
+ _state = TERM;
+ thr_wait ();
+ }
+ else
+ {
+ _alsadev->pcm_stop ();
+ }
}
diff --git a/tools/zalsa/pxthread.cc b/tools/zalsa/pxthread.cc
index e3e88499..522827d4 100644
--- a/tools/zalsa/pxthread.cc
+++ b/tools/zalsa/pxthread.cc
@@ -76,3 +76,12 @@ void Pxthread::thr_main (void)
{
}
+
+void Pxthread::thr_wait (void)
+{
+ if (_thrid == 0)
+ return;
+ pthread_join (_thrid, NULL);
+ _thrid = 0;
+}
+
diff --git a/tools/zalsa/pxthread.h b/tools/zalsa/pxthread.h
index 32d115fb..542aa6ed 100644
--- a/tools/zalsa/pxthread.h
+++ b/tools/zalsa/pxthread.h
@@ -42,6 +42,7 @@ public:
virtual void thr_main (void) = 0;
virtual int thr_start (int policy, int priority, size_t stacksize = 0);
+ virtual void thr_wait (void);
private: