[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#384894: Not able to exit via close window button in xfce4



Hi,

the attached diff fixes two issues with amsynth.

1. By cancelling the midi thread instead of trying to shut it down cleanly at 
least now amsynth exits always.
2. Not closing the audio pcm device at exit avoids a strange crash. The OS 
will clean up after us.

Both are very rudimentary fixes :(

A nice little program though!

Greetings, Joost

-- 
The planet Andete is famous for it's killer edible poets.
diff -ur amsynth-1.1.0/src/drivers/ALSAAudioDriver.cc amsynth-1.1.0.new/src/drivers/ALSAAudioDriver.cc
--- amsynth-1.1.0/src/drivers/ALSAAudioDriver.cc	2005-10-26 21:29:00.000000000 +0200
+++ amsynth-1.1.0.new/src/drivers/ALSAAudioDriver.cc	2006-10-22 20:05:49.000000000 +0200
@@ -68,7 +68,7 @@
 void ALSAAudioDriver::close()
 {
 #ifdef with_alsa
-	snd_pcm_close( playback_handle );
+	//snd_pcm_close( playback_handle );
 #endif
 }
 
Only in amsynth-1.1.0.new/src/drivers: ALSAAudioDriver.o
Only in amsynth-1.1.0.new/src/drivers: ALSAMidiDriver.o
diff -ur amsynth-1.1.0/src/drivers/ALSAmmapAudioDriver.cc amsynth-1.1.0.new/src/drivers/ALSAmmapAudioDriver.cc
--- amsynth-1.1.0/src/drivers/ALSAmmapAudioDriver.cc	2005-10-26 21:29:00.000000000 +0200
+++ amsynth-1.1.0.new/src/drivers/ALSAmmapAudioDriver.cc	2006-10-22 20:05:34.000000000 +0200
@@ -142,7 +142,7 @@
 void ALSAmmapAudioDriver::close()
 {
 #ifdef with_alsa
-	snd_pcm_close( playback_handle );
+	//snd_pcm_close( playback_handle );
 #endif
 }
 
diff -ur amsynth-1.1.0/src/MidiController.cc amsynth-1.1.0.new/src/MidiController.cc
--- amsynth-1.1.0/src/MidiController.cc	2005-10-26 21:29:00.000000000 +0200
+++ amsynth-1.1.0.new/src/MidiController.cc	2006-10-22 19:58:34.000000000 +0200
@@ -82,9 +82,10 @@
 // need to kill the thread, otherwise it waits indefinitely for the next incoming byte
 void
 MidiController::Stop ()
-{ 
-	Thread::Kill (); 
-	Thread::Join ();
+{
+    Thread::Cancel ();
+	//Thread::Kill (); 
+	//Thread::Join ();
 }
 
 
diff -ur amsynth-1.1.0/src/Thread.h amsynth-1.1.0.new/src/Thread.h
--- amsynth-1.1.0/src/Thread.h	2005-10-26 21:45:10.000000000 +0200
+++ amsynth-1.1.0.new/src/Thread.h	2006-10-22 19:59:10.000000000 +0200
@@ -26,6 +26,7 @@
 #define _THREAD_H
 
 #include <pthread.h>
+#include <signal.h>
 
 class Thread
 {
@@ -36,6 +37,7 @@
 	void	Stop	() { mShouldStop = true; }
 	int		Kill	(int sig = 2) { return pthread_kill (mThread, sig); }
 	int		Join	() { return pthread_join (mThread, NULL); }
+	int		Cancel	() { return pthread_cancel (mThread); }
 
 protected:
 	// override me!

Attachment: pgpdFEHvtav_i.pgp
Description: PGP signature


Reply to: