| 698 | } |
| 699 | |
| 700 | int CsoundPerformanceThread::Join() |
| 701 | { |
| 702 | int retval; |
| 703 | retval = status; |
| 704 | |
| 705 | if (recordData.running) { |
| 706 | recordData.running = false; |
| 707 | csoundCondSignal(recordData.condvar); |
| 708 | csoundJoinThread(recordData.thread); |
| 709 | } |
| 710 | if (perfThread) { |
| 711 | retval = csoundJoinThread(perfThread); |
| 712 | perfThread = (void*) 0; |
| 713 | } |
| 714 | |
| 715 | // delete any pending messages |
| 716 | { |
| 717 | CsoundPerformanceThreadMessage *msg; |
| 718 | msg = (CsoundPerformanceThreadMessage*) firstMessage; |
| 719 | firstMessage = (CsoundPerformanceThreadMessage*) 0; |
| 720 | lastMessage = (CsoundPerformanceThreadMessage*) 0; |
| 721 | while (msg) { |
| 722 | CsoundPerformanceThreadMessage *nxt = msg->nxt; |
| 723 | delete msg; |
| 724 | msg = nxt; |
| 725 | } |
| 726 | } |
| 727 | // delete all thread locks |
| 728 | if (queueLock) { |
| 729 | csoundDestroyMutex(queueLock); |
| 730 | queueLock = (void*) 0; |
| 731 | } |
| 732 | if (pauseLock) { |
| 733 | csoundNotifyThreadLock(pauseLock); |
| 734 | csoundDestroyThreadLock(pauseLock); |
| 735 | pauseLock = (void*) 0; |
| 736 | } |
| 737 | if (flushLock) { |
| 738 | csoundNotifyThreadLock(flushLock); |
| 739 | csoundDestroyThreadLock(flushLock); |
| 740 | flushLock = (void*) 0; |
| 741 | } |
| 742 | |
| 743 | running = 0; |
| 744 | return retval; |
| 745 | } |
| 746 | |
| 747 | /** |
| 748 | * Waits until all pending messages (pause, send score event, etc.) |