diff options
author | falkTX <falktx@falktx.com> | 2021-04-29 16:55:29 +0100 |
---|---|---|
committer | falkTX <falktx@falktx.com> | 2021-04-29 16:57:52 +0100 |
commit | 1b3594e70fb4d512bd3f7cbc8e808e9a5a6aef5e (patch) | |
tree | 290e8703439282757f3680d09e9949f0fcc6447a | |
parent | 852ba2b8ebc944865e75d8eb5d4550d408772f3b (diff) | |
download | jack2-1b3594e70fb4d512bd3f7cbc8e808e9a5a6aef5e.tar.gz |
wait for zalsa thread to finish
Signed-off-by: falkTX <falktx@falktx.com>
-rw-r--r-- | tools/zalsa/alsathread.cc | 10 | ||||
-rw-r--r-- | tools/zalsa/pxthread.cc | 9 | ||||
-rw-r--r-- | tools/zalsa/pxthread.h | 1 |
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: |