pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/audio/spiralsynth Fixes for SpiralSound/Midi.C



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f5bb030e271b
branches:  trunk
changeset: 492989:f5bb030e271b
user:      ben <ben%pkgsrc.org@localhost>
date:      Sun Apr 24 14:41:28 2005 +0000

description:
Fixes for SpiralSound/Midi.C

* test for failure of open() should be == -1, not == 0
        This causes Open() to behave as intended, only creating the
        m_MidiReader thread if the MIDI device is successfully opened.

* unconditionally initialize m_Mutex in Open()

* conditionally close m_MidiReader in Close(), if NULL do nothing

* make m_MidiFd and m_MidiWrFd the same file descriptor.  The MIDI
        device special file can only be opened once at a time.

diffstat:

 audio/spiralsynth/distinfo         |   4 +-
 audio/spiralsynth/patches/patch-an |  57 ++++++++++++++++++++++++++++++-------
 2 files changed, 48 insertions(+), 13 deletions(-)

diffs (82 lines):

diff -r be313bbb32d6 -r f5bb030e271b audio/spiralsynth/distinfo
--- a/audio/spiralsynth/distinfo        Sun Apr 24 14:05:06 2005 +0000
+++ b/audio/spiralsynth/distinfo        Sun Apr 24 14:41:28 2005 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.9 2005/04/24 03:29:11 ben Exp $
+$NetBSD: distinfo,v 1.10 2005/04/24 14:41:28 ben Exp $
 
 SHA1 (SpiralSynth-2.0.0.tar.gz) = ea42c5b7710237139f5281cf0c4ca155c184c4cd
 RMD160 (SpiralSynth-2.0.0.tar.gz) = c05f38a9ae8b8b87f520c11854631e6dfa00c034
@@ -15,5 +15,5 @@
 SHA1 (patch-ak) = 67643c5abea0498f8ea046c5abd52f2d328a5538
 SHA1 (patch-al) = 7436bce933cbddcd4f869ab2cbbe27762d4273e5
 SHA1 (patch-am) = 4899c78015028a6e8047e5527362646e40a10708
-SHA1 (patch-an) = b99c57cd7aa4d5c95bbeffea6c992e9cd7b7c414
+SHA1 (patch-an) = d93e9a613ca52ac0ed21b38d58902783666ac5b1
 SHA1 (patch-ao) = 138f58bd7fae0226690747efcb8daf472e3a5337
diff -r be313bbb32d6 -r f5bb030e271b audio/spiralsynth/patches/patch-an
--- a/audio/spiralsynth/patches/patch-an        Sun Apr 24 14:05:06 2005 +0000
+++ b/audio/spiralsynth/patches/patch-an        Sun Apr 24 14:41:28 2005 +0000
@@ -1,16 +1,51 @@
-$NetBSD: patch-an,v 1.1 2004/11/25 17:24:27 ben Exp $
+$NetBSD: patch-an,v 1.2 2005/04/24 14:41:28 ben Exp $
 
---- SpiralSound/Midi.C.orig    Tue Jun 11 15:08:56 2002
+--- SpiralSound/Midi.C.orig    2002-06-11 15:08:56.000000000 -0700
 +++ SpiralSound/Midi.C
-@@ -174,7 +174,10 @@ void MidiDevice::SendEvent(int Device,co
- void MidiDevice::ReadByte(unsigned char *c)
+@@ -76,12 +76,12 @@ MidiDevice::~MidiDevice() 
+ void MidiDevice::Close()
  {
-       *c=MIDI_CLOCK;
--      do read(m_MidiFd,c,1);                          
-+      do {
-+              read(m_MidiFd,c,1);                             
-+              sched_yield();
-+      }
-       while (*c>=STATUS_END);         
+       pthread_mutex_lock(m_Mutex);
+-      pthread_cancel(m_MidiReader); 
++      if (m_MidiReader != NULL)
++              pthread_cancel(m_MidiReader); 
+       pthread_mutex_unlock(m_Mutex);
+       pthread_mutex_destroy(m_Mutex);
+               
+       close(m_MidiFd);
+-      close(m_MidiWrFd);
+       cerr<<"Closed midi device"<<endl;
  }
  
+@@ -90,24 +90,19 @@ void MidiDevice::Open()
+ {
+       //if (!SpiralInfo::WANTMIDI) return;
+       
+-      m_MidiFd = open(m_DeviceName.c_str(),O_RDONLY|O_SYNC);  
+-      if (!m_MidiFd) 
+-      {
+-              cerr<<"Couldn't open midi for reading ["<<m_DeviceName<<"]"<<endl;
+-              return;
+-      }
+-      
+-      m_MidiWrFd = open(m_DeviceName.c_str(),O_WRONLY);  
+-      if (!m_MidiWrFd) 
++      m_Mutex = new pthread_mutex_t;
++    pthread_mutex_init(m_Mutex, NULL);
++      m_MidiReader = NULL;
++
++      m_MidiWrFd = m_MidiFd = open(m_DeviceName.c_str(),O_RDWR|O_SYNC);  
++      if (m_MidiFd == -1) 
+       {
+-              cerr<<"Couldn't open midi for writing ["<<m_DeviceName<<"]"<<endl;
++              cerr<<"Couldn't open midi ["<<m_DeviceName<<"]"<<endl;
+               return;
+       }
+       
+       cerr<<"Opened midi device ["<<m_DeviceName<<"]"<<endl;
+       
+-      m_Mutex = new pthread_mutex_t;
+-    pthread_mutex_init(m_Mutex, NULL);
+     int ret=pthread_create(&m_MidiReader,NULL,(void*(*)(void*))MidiDevice::MidiReaderCallback,(void*)this);   
+ }
+ 



Home | Main Index | Thread Index | Old Index