[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Important KMid patch
From:       Antonio Larrosa <antlarr () arrakis ! es>
Date:       2000-10-03 23:36:29
[Download RAW message or body]

Hello,

This patch fixes two kind of crashes kmid can do to konqueror while it is a
part. They are happening when you open two kmid instances inside the same
konqueror process (for example, by using "Split View" when in a kmid view)

The first change is using a local variable in kmidClient instead of a global one
(kmidClient::m_kMid instead of kMid), which is obviously not the way to go when
using two embeeded kmid windows.

The second change is 
-m_kMid.pctlsmID=shmget( getpid()  ,sizeof(PlayerController),0666 | IPC_CREAT );
+m_kMid.pctlsmID=shmget(IPC_PRIVATE,sizeof(PlayerController),0666 | IPC_CREAT );

so that it always creates a new shared memory segment instead of reusing the
segment of the previous instance (which makes both instances go crazy as this
shared data is shared between too many people :) )

Is it ok to commit ? (I'll do if nobody objects)

Btw, do I have to do anything to "retag" the changed files ? or is it being done
automatically when using "cvs commit" ?

Greetings,

--
Antonio Larrosa Jimenez
KDE Core developer
antonio@larrosa.org        larrosa@kde.org
http://www.larrosa.org
KDE - The development framework of the future, today.
["kmid.diff" (text/plain)]

Index: kmid_part.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kmid/kmid_part.cpp,v
retrieving revision 1.8
diff -u -r1.8 kmid_part.cpp
--- kmid_part.cpp	2000/10/01 03:09:37	1.8
+++ kmid_part.cpp	2000/10/03 23:32:56
@@ -33,6 +33,7 @@
 
 KMidFactory::KMidFactory()
 {
+  s_instance=0L;
 }
 
 KMidFactory::~KMidFactory()
Index: kmidclient.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kmid/kmidclient.cpp,v
retrieving revision 1.60
diff -u -r1.60 kmidclient.cpp
--- kmidclient.cpp	2000/10/02 01:58:20	1.60
+++ kmidclient.cpp	2000/10/03 23:32:59
@@ -85,7 +85,7 @@
     currentsl=NULL;
     //	currentsl=slman->getCollection(activecollection);
     itsme=0;
-    kMid.pid=0;
+    m_kMid.pid=0;
     timebar = new QSlider(0,240000,30000,60000,QSlider::Horizontal, this);
     timebar->setSteps(30000,60000);
     timebar->setValue(0);
@@ -140,27 +140,27 @@
     samplefile.truncate(samplefile.findRev('/'));
     FMOut::setFMPatchesDirectory(samplefile.ascii());
     
-    kMid.pctlsmID=shmget(getpid(),sizeof(PlayerController),0666 | IPC_CREAT);
-    if (kMid.pctlsmID==-1)
+    m_kMid.pctlsmID=shmget(IPC_PRIVATE,sizeof(PlayerController),0666 | IPC_CREAT );
+    if (m_kMid.pctlsmID==-1)
     {
         printf("ERROR : Can't allocate shared memory !!!\n"
-               "Please report to antlarr@arrakis.es\n");
+               "Please report to larrosa@kde.org\n");
 	exit(1);
     };
     
-    kMid.pctl=(PlayerController *)shmat(kMid.pctlsmID,0L,0);
-    if (!kMid.pctl)
+    m_kMid.pctl=(PlayerController *)shmat(m_kMid.pctlsmID,0L,0);
+    if (!m_kMid.pctl)
         printf("ERROR : Can't get shared memory !!! "
-               "Please report to antlarr@arrakis.es\n");
-    kMid.pctl->playing=0;
-    kMid.pctl->gm=1;
-    kMid.pctl->volumepercentage=100;
-    kMid.pctl->tempo=500000;
-    kMid.pctl->ratioTempo=1.0;
+               "Please report to larrosa@kde.org\n");
+    m_kMid.pctl->playing=0;
+    m_kMid.pctl->gm=1;
+    m_kMid.pctl->volumepercentage=100;
+    m_kMid.pctl->tempo=500000;
+    m_kMid.pctl->ratioTempo=1.0;
     for (int i=0;i<16;i++)
     {
-        kMid.pctl->forcepgm[i]=0;
-        kMid.pctl->pgm[i]=0;
+        m_kMid.pctl->forcepgm[i]=0;
+        m_kMid.pctl->pgm[i]=0;
     };
     
     
@@ -169,7 +169,7 @@
     
     midi = new DeviceManager(mididev);
     midi->initManager();
-    player= new MidiPlayer(midi,kMid.pctl);
+    player= new MidiPlayer(midi,m_kMid.pctl);
     
     kconf->setGroup("Midimapper");
     QString qs=kconf->readEntry("Loadfile","gm.map");
@@ -220,17 +220,17 @@
 
 kmidClient::~kmidClient()
 {
-    if (kMid.pctl->playing==1)
+    if (m_kMid.pctl->playing==1)
     {
         stop();
         //    sleep(1);
     }; 
     
-    if (kMid.pid!=0)
+    if (m_kMid.pid!=0)
     {
-        kill(kMid.pid,SIGTERM);
-        waitpid(kMid.pid, 0L, 0);
-        kMid.pid=0;
+        kill(m_kMid.pid,SIGTERM);
+        waitpid(m_kMid.pid, 0L, 0);
+        m_kMid.pid=0;
     };
     
     kdispt->PreDestroyer();
@@ -249,8 +249,8 @@
     delete slman;
 
 // Let's detach and delete shared memory
-    shmdt((char *)kMid.pctl);
-    shmctl(kMid.pctlsmID, IPC_RMID, 0L);
+    shmdt((char *)m_kMid.pctl);
+    shmctl(m_kMid.pctlsmID, IPC_RMID, 0L);
 };
 
 // Use KURL::filename ! (David)
@@ -276,8 +276,7 @@
 
 int kmidClient::openFile(const char *filename)
 {
-    kdDebug() << filename << "\n";
-    kMid.pctl->message|=PLAYER_HALT;
+    m_kMid.pctl->message|=PLAYER_HALT;
     stop();
     int r;
     player->setGenerateBeats(true);
@@ -292,7 +291,7 @@
         case (-2) : errormsg =
                             i18n("The file %1 is not a midi \
file").arg(filename);break;  case (-3) : errormsg =
-                            i18n("Ticks per cuarter note is negative, please, send \
this file to antlarr@arrakis.es");break; +                            i18n("Ticks per \
cuarter note is negative, please, send this file to larrosa@kde.org");break;  case \
(-4) : errormsg =  i18n("Not enough memory !!");break;
         case (-5) : errormsg =
@@ -341,9 +340,9 @@
 //    kdispt->updateScrollBars();
     emit mustRechooseTextEvent();
     kdispt->repaint(TRUE);
-    tempoLCD->display(tempoToMetronomeTempo(kMid.pctl->tempo));
+    tempoLCD->display(tempoToMetronomeTempo(m_kMid.pctl->tempo));
     currentTempo=tempoLCD->getValue();
-    tempoLCD->setDefaultValue(tempoToMetronomeTempo(kMid.pctl->tempo)*kMid.pctl->ratioTempo);
 +    tempoLCD->setDefaultValue(tempoToMetronomeTempo(m_kMid.pctl->tempo)*m_kMid.pctl->ratioTempo);
  
     char *fn=new char[strlen(filename)+20];
     extractFilename(filename,fn);
@@ -359,7 +358,6 @@
 
 int kmidClient::openURL(const QString _url)
 {
-    kdDebug() << "openURL " << _url << "\n";
     KURL u(_url);
     if (u.isMalformed()) {printf("Malformed URL\n");return -1;};
     
@@ -502,14 +500,13 @@
 
 void kmidClient::slotPlay()
 {
-    printf("slotPlay\n");
     if (!player->isSongLoaded())
     {
         KMessageBox::sorry(this,
                          i18n("You must load a file before playing it"));
         return;
     };
-    if (kMid.pctl->playing==1)
+    if (m_kMid.pctl->playing==1)
     {
         KMessageBox::sorry(this,
                          i18n("A song is already being played"));
@@ -523,19 +520,19 @@
     };
 
     kdispt->CursorToHome();
-    kMid.pctl->message=0;
-    kMid.pctl->playing=0;
-    kMid.pctl->finished=0;
-    kMid.pctl->error=0;
-    kMid.pctl->SPEVplayed=0;
-    kMid.pctl->SPEVprocessed=0;
+    m_kMid.pctl->message=0;
+    m_kMid.pctl->playing=0;
+    m_kMid.pctl->finished=0;
+    m_kMid.pctl->error=0;
+    m_kMid.pctl->SPEVplayed=0;
+    m_kMid.pctl->SPEVprocessed=0;
 #ifdef KMidDEBUG
     passcount=0;
 #endif
     noteArray->iteratorBegin();
     
     QApplication::flushX();
-    if ((kMid.pid=fork())==0)
+    if ((m_kMid.pid=fork())==0)
     {
 #ifdef KMidDEBUG
         printf("PlayerProcessID : %d\n",getpid());
@@ -546,7 +543,7 @@
 #endif
         _exit(0);
     };
-    kMid.pctl->millisecsPlayed=0;
+    m_kMid.pctl->millisecsPlayed=0;
 
 
     spev=player->specialEvents();
@@ -556,10 +553,10 @@
     printf("writing SPEV(END)\n");
 #endif
 
-    while ((kMid.pctl->playing==0)&&(kMid.pctl->error==0)) ;
+    while ((m_kMid.pctl->playing==0)&&(m_kMid.pctl->error==0)) ;
 
-    if (kMid.pctl->error==1) return;
-    beginmillisec=kMid.pctl->beginmillisec;
+    if (m_kMid.pctl->error==1) return;
+    beginmillisec=m_kMid.pctl->beginmillisec;
 
     int type;
     ulong x=timeOfNextEvent(&type);
@@ -569,7 +566,7 @@
     timer4timebar->start(1000);
     
 #ifdef KMidDEBUG
-    printf("PlayerProcess : %d . ParentProcessID : %d\n",kMid.pid,getpid());
+    printf("PlayerProcess : %d . ParentProcessID : %d\n",m_kMid.pid,getpid());
     printf("******************************-\n");
 #endif
 };
@@ -577,7 +574,7 @@
 void kmidClient::timebarUpdate()
 {
     itsme=1;
-    if (kMid.pctl->playing==0)
+    if (m_kMid.pctl->playing==0)
     {
         timer4timebar->stop();
     };
@@ -585,13 +582,13 @@
     timeval tv;
     gettimeofday(&tv, NULL);
     ulong currentmillisec=tv.tv_sec*1000+tv.tv_usec/1000;
-    kMid.pctl->millisecsPlayed=(currentmillisec-beginmillisec);
+    m_kMid.pctl->millisecsPlayed=(currentmillisec-beginmillisec);
     
-    timebar->setValue((int)(kMid.pctl->millisecsPlayed));
+    timebar->setValue((int)(m_kMid.pctl->millisecsPlayed));
     itsme=0;
-    if ((kMid.pctl->playing==0)&&(kMid.pctl->finished==1))
+    if ((m_kMid.pctl->playing==0)&&(m_kMid.pctl->finished==1))
     {
-        waitpid(kMid.pid, NULL, 0);
+        waitpid(m_kMid.pid, NULL, 0);
         if (loopsong)
         {
             play();
@@ -606,7 +603,7 @@
 {
     if (itsme) return;
 
-    if (kMid.pctl->playing==0) 
+    if (m_kMid.pctl->playing==0) 
     {
         itsme=1;
         timebar->setValue(0);
@@ -614,16 +611,16 @@
         return;
     };
 
-    if (kMid.pctl->paused) return;
+    if (m_kMid.pctl->paused) return;
 
-    if (kMid.pid!=0)
+    if (m_kMid.pid!=0)
     {
-        kill(kMid.pid,SIGTERM);
+        kill(m_kMid.pid,SIGTERM);
 #ifdef KMidDEBUG
-        printf("Waiting for Process %d to be killed\n",kMid.pid);
+        printf("Waiting for Process %d to be killed\n",m_kMid.pid);
 #endif
-        waitpid(kMid.pid, NULL, 0);
-        kMid.pid=0;
+        waitpid(m_kMid.pid, NULL, 0);
+        m_kMid.pid=0;
     };
     
     
@@ -636,14 +633,14 @@
     
     moveEventPointersTo((ulong)i);
     
-    kMid.pctl->playing=0;
-    kMid.pctl->OK=0;
-    kMid.pctl->error=0;
-    kMid.pctl->gotomsec=i;
-    kMid.pctl->message|=PLAYER_SETPOS;
+    m_kMid.pctl->playing=0;
+    m_kMid.pctl->OK=0;
+    m_kMid.pctl->error=0;
+    m_kMid.pctl->gotomsec=i;
+    m_kMid.pctl->message|=PLAYER_SETPOS;
     
     QApplication::flushX();
-    if ((kMid.pid=fork())==0)
+    if ((m_kMid.pid=fork())==0)
     {
 #ifdef KMidDEBUG
         printf("Player_ProcessID : %d\n",getpid());
@@ -657,11 +654,11 @@
         _exit(0);
     };
     
-    while ((kMid.pctl->playing==0)&&(kMid.pctl->error==0)) ;
+    while ((m_kMid.pctl->playing==0)&&(m_kMid.pctl->error==0)) ;
     
-    if (kMid.pctl->error==1) return;
-    beginmillisec=kMid.pctl->beginmillisec-i;
-    ulong currentmillisec=kMid.pctl->beginmillisec;
+    if (m_kMid.pctl->error==1) return;
+    beginmillisec=m_kMid.pctl->beginmillisec-i;
+    ulong currentmillisec=m_kMid.pctl->beginmillisec;
 
     int type;
     ulong x=timeOfNextEvent(&type);
@@ -674,11 +671,11 @@
      timer4events->start(delaymillisec,TRUE);
      */
 
-    kMid.pctl->OK=0;
+    m_kMid.pctl->OK=0;
 /*
-    tempoLCD->display(tempoToMetronomeTempo(kMid.pctl->tempo));
+    tempoLCD->display(tempoToMetronomeTempo(m_kMid.pctl->tempo));
     currentTempo=tempoLCD->getValue();
-    tempoLCD->setDefaultValue(tempoToMetronomeTempo(kMid.pctl->tempo)*kMid.pctl->ratioTempo);
 +    tempoLCD->setDefaultValue(tempoToMetronomeTempo(m_kMid.pctl->tempo)*m_kMid.pctl->ratioTempo);
                
 */
 };
 
@@ -689,7 +686,7 @@
 #endif
     spev=player->specialEvents();
 
-    ulong tempo=(ulong)(500000 * kMid.pctl->ratioTempo);
+    ulong tempo=(ulong)(500000 * m_kMid.pctl->ratioTempo);
     int num=4;
     int den=4;
     
@@ -701,7 +698,7 @@
     };
     tempoLCD->display(tempoToMetronomeTempo(tempo));
     currentTempo=tempoLCD->getValue();
-    tempoLCD->setDefaultValue(tempoToMetronomeTempo(tempo)*kMid.pctl->ratioTempo);
+    tempoLCD->setDefaultValue(tempoToMetronomeTempo(tempo)*m_kMid.pctl->ratioTempo);
 
     rhythmview->setRhythm(num,den);
     
@@ -715,8 +712,8 @@
         {
             for (int j=0;j<16;j++)
             {
-                if (!kMid.pctl->forcepgm[j]) \
                channelView->changeInstrument(j,(kMid.pctl->gm==1)?(pgm[j]):(MT32toGM[pgm[j]]));
                
-                else channelView->changeInstrument(j,(kMid.pctl->pgm[j]));
+                if (!m_kMid.pctl->forcepgm[j]) \
channelView->changeInstrument(j,(m_kMid.pctl->gm==1)?(pgm[j]):(MT32toGM[pgm[j]])); +  \
else channelView->changeInstrument(j,(m_kMid.pctl->pgm[j]));  };
         };
     };
@@ -739,14 +736,14 @@
 void kmidClient::slotSetVolume(int i)
 {
     int autochangemap=0;
-    if ((kMid.pctl->playing==1)&&(kMid.pctl->paused==0)) autochangemap=1;
+    if ((m_kMid.pctl->playing==1)&&(m_kMid.pctl->paused==0)) autochangemap=1;
     
     if (autochangemap)
     {
         pause();
     };
     i=200-i;
-    kMid.pctl->volumepercentage=i;
+    m_kMid.pctl->volumepercentage=i;
     
     if (autochangemap)
     {
@@ -786,7 +783,7 @@
         return;
     };
     
-    if (kMid.pctl->paused) emit stopPause();
+    if (m_kMid.pctl->paused) emit stopPause();
     comboSongs->setCurrentItem(currentsl->getActiveSongID()-1);
     if (openURL(currentsl->getActiveSongName())==-1) return;
     play();
@@ -826,7 +823,7 @@
         return;
     };
     
-    if (kMid.pctl->paused) emit stopPause();
+    if (m_kMid.pctl->paused) emit stopPause();
     comboSongs->setCurrentItem(currentsl->getActiveSongID()-1);
     if (openURL(currentsl->getActiveSongName())==-1) return;
     play();
@@ -834,35 +831,35 @@
 
 void kmidClient::slotPause()
 {
-    if (kMid.pctl->playing==0) return;
+    if (m_kMid.pctl->playing==0) return;
 #ifdef KMidDEBUG
     printf("song Pause\n");
 #endif
-    if (kMid.pctl->paused==0)
+    if (m_kMid.pctl->paused==0)
     {
-        if (kMid.pid!=0)
+        if (m_kMid.pid!=0)
         {
-            kill(kMid.pid,SIGTERM);
-            waitpid(kMid.pid, NULL, 0);
-            kMid.pid=0;
+            kill(m_kMid.pid,SIGTERM);
+            waitpid(m_kMid.pid, NULL, 0);
+            m_kMid.pid=0;
         };
-        pausedatmillisec=(ulong)kMid.pctl->millisecsPlayed;
-        kMid.pctl->paused=1;
+        pausedatmillisec=(ulong)m_kMid.pctl->millisecsPlayed;
+        m_kMid.pctl->paused=1;
         timer4timebar->stop(); 
         timer4events->stop();
-        //    kill(kMid.pid,SIGSTOP);
+        //    kill(m_kMid.pid,SIGSTOP);
         //   The previous line doesn't work because it stops the two processes (!?)
     }
     else
     {
-        kMid.pctl->playing=0;
-        kMid.pctl->OK=0;
-        kMid.pctl->error=0;
-        kMid.pctl->gotomsec=pausedatmillisec;
-        kMid.pctl->message|=PLAYER_SETPOS;
+        m_kMid.pctl->playing=0;
+        m_kMid.pctl->OK=0;
+        m_kMid.pctl->error=0;
+        m_kMid.pctl->gotomsec=pausedatmillisec;
+        m_kMid.pctl->message|=PLAYER_SETPOS;
 
 	QApplication::flushX();
-        if ((kMid.pid=fork())==0)
+        if ((m_kMid.pid=fork())==0)
         {
 #ifdef KMidDEBUG
             printf("PlayerProcessID : %d\n",getpid());
@@ -874,15 +871,15 @@
             _exit(0);
         };
         
-        while ((kMid.pctl->playing==0)&&(kMid.pctl->error==0)) ;
+        while ((m_kMid.pctl->playing==0)&&(m_kMid.pctl->error==0)) ;
         
-        if (kMid.pctl->error) return;
+        if (m_kMid.pctl->error) return;
 
-        kMid.pctl->OK=0;
-        kMid.pctl->paused=0;
+        m_kMid.pctl->OK=0;
+        m_kMid.pctl->paused=0;
         
-        beginmillisec=kMid.pctl->beginmillisec-pausedatmillisec;
-        ulong currentmillisec=kMid.pctl->beginmillisec;
+        beginmillisec=m_kMid.pctl->beginmillisec-pausedatmillisec;
+        ulong currentmillisec=m_kMid.pctl->beginmillisec;
         
         int type;
         ulong x=timeOfNextEvent(&type);
@@ -898,8 +895,8 @@
             {
                 for (int j=0;j<16;j++)
                 {
-                    if (!kMid.pctl->forcepgm[j]) \
                channelView->changeInstrument(j,(kMid.pctl->gm==1)?(pgm[j]):(MT32toGM[pgm[j]]));
                
-                    else channelView->changeInstrument(j,(kMid.pctl->pgm[j]));
+                    if (!m_kMid.pctl->forcepgm[j]) \
channelView->changeInstrument(j,(m_kMid.pctl->gm==1)?(pgm[j]):(MT32toGM[pgm[j]])); +  \
else channelView->changeInstrument(j,(m_kMid.pctl->pgm[j]));  };
             };
 
@@ -918,41 +915,41 @@
 {
     if (!shuttingdown)
     {
-        for (int i=0;i<16;i++) kMid.pctl->forcepgm[i]=FALSE;
+        for (int i=0;i<16;i++) m_kMid.pctl->forcepgm[i]=FALSE;
         if (channelView) channelView->reset();
-        tempoLCD->display(tempoToMetronomeTempo(kMid.pctl->tempo));
+        tempoLCD->display(tempoToMetronomeTempo(m_kMid.pctl->tempo));
         currentTempo=tempoLCD->getValue();
-        tempoLCD->setDefaultValue(tempoToMetronomeTempo(kMid.pctl->tempo)*kMid.pctl->ratioTempo);
 +        tempoLCD->setDefaultValue(tempoToMetronomeTempo(m_kMid.pctl->tempo)*m_kMid.pctl->ratioTempo);
  }
     
-    if (kMid.pctl->playing==0) return;
+    if (m_kMid.pctl->playing==0) return;
 
-    if (kMid.pctl->paused) return;
+    if (m_kMid.pctl->paused) return;
 #ifdef KMidDEBUG
     printf("song Stop\n");
 #endif
-    if (kMid.pid!=0)
+    if (m_kMid.pid!=0)
     {
-        kill(kMid.pid,SIGTERM);
+        kill(m_kMid.pid,SIGTERM);
 #ifdef KMidDEBUG
 	printf("Killing\n");
 #endif
-        waitpid(kMid.pid, NULL, 0);
-        kMid.pid=0;
+        waitpid(m_kMid.pid, NULL, 0);
+        m_kMid.pid=0;
     };
-    kMid.pctl->playing=0;
-    ////////kMid.pctl->OK=0;
-    ////////kMid.pctl->message|=PLAYER_HALT;
+    m_kMid.pctl->playing=0;
+    ////////m_kMid.pctl->OK=0;
+    ////////m_kMid.pctl->message|=PLAYER_HALT;
     timer4timebar->stop();
     timer4events->stop();
-    //kMid.pctl->playing=0;
-    //kMid.pctl->paused=0;
-    ////////while (kMid.pctl->OK==0) ;
+    //m_kMid.pctl->playing=0;
+    //m_kMid.pctl->paused=0;
+    ////////while (m_kMid.pctl->OK==0) ;
 };
 
 void kmidClient::slotRewind()
 {
-    if ((kMid.pctl->playing)&&(!kMid.pctl->paused))
+    if ((m_kMid.pctl->playing)&&(!m_kMid.pctl->paused))
     {
         timebar->subtractPage();
         slotSeek(timebar->value());
@@ -961,7 +958,7 @@
 
 void kmidClient::slotForward()
 {
-    if ((kMid.pctl->playing)&&(!kMid.pctl->paused))
+    if ((m_kMid.pctl->playing)&&(!m_kMid.pctl->paused))
     {
         timebar->addPage();
         slotSeek(timebar->value());
@@ -1043,11 +1040,11 @@
             {
                 tempoLCD->display(tempoToMetronomeTempo(spev->tempo));
 #ifdef KMidDEBUG
-                printf("Changing lcd tempo : spev->tempo : %d , ratio : \
%.9g\n",spev->tempo,kMid.pctl->ratioTempo); +                printf("Changing lcd \
                tempo : spev->tempo : %d , ratio : \
                %.9g\n",spev->tempo,m_kMid.pctl->ratioTempo);
                 printf("Result : %g %.9g \
%d\n",tempoToMetronomeTempo(spev->tempo),tempoToMetronomeTempo(spev->tempo),(int)tempoToMetronomeTempo(spev->tempo));
  #endif
                 currentTempo=tempoLCD->getValue();
-                tempoLCD->setDefaultValue(tempoToMetronomeTempo(spev->tempo)*kMid.pctl->ratioTempo);
 +                tempoLCD->setDefaultValue(tempoToMetronomeTempo(spev->tempo)*m_kMid.pctl->ratioTempo);
  }
             else if (spev->type==6)
             {
@@ -1060,7 +1057,7 @@
 #endif
                 rhythmview->Beat(spev->num);
             };
-            kMid.pctl->SPEVprocessed++;
+            m_kMid.pctl->SPEVprocessed++;
             spev=spev->next;
         };
         if (type==2)
@@ -1072,8 +1069,8 @@
                 if (ncmd->cmd==1) channelView->noteOn(ncmd->chn,ncmd->note);
                 else if (ncmd->cmd==0) channelView->noteOff(ncmd->chn,ncmd->note);
                 else if (ncmd->cmd==2)
-                    if (!kMid.pctl->forcepgm[ncmd->chn]) \
channelView->changeInstrument(ncmd->chn,(kMid.pctl->gm==1)?(ncmd->note):(MT32toGM[ncmd->note]));
                
-                    else \
channelView->changeInstrument(ncmd->chn,(kMid.pctl->pgm[ncmd->chn])); +               \
if (!m_kMid.pctl->forcepgm[ncmd->chn]) \
channelView->changeInstrument(ncmd->chn,(m_kMid.pctl->gm==1)?(ncmd->note):(MT32toGM[ncmd->note]));
 +                    else \
channelView->changeInstrument(ncmd->chn,(m_kMid.pctl->pgm[ncmd->chn]));  
                 noteArray->next();
             };
@@ -1111,13 +1108,13 @@
 void kmidClient::setSongType(int i)
 {
     int autochangetype=0;
-    if ((kMid.pctl->playing==1)&&(kMid.pctl->paused==0)) autochangetype=1;
+    if ((m_kMid.pctl->playing==1)&&(m_kMid.pctl->paused==0)) autochangetype=1;
     
     if (autochangetype) 
     {
         pause();
     };
-    kMid.pctl->gm=i;
+    m_kMid.pctl->gm=i;
 
     if (autochangetype)
     {
@@ -1157,7 +1154,7 @@
         };
     };
     int autochangemap=0;
-    if ((kMid.pctl->playing==1)&&(kMid.pctl->paused==0)) autochangemap=1;
+    if ((m_kMid.pctl->playing==1)&&(m_kMid.pctl->paused==0)) autochangemap=1;
     
     if (autochangemap)
     {
@@ -1230,7 +1227,7 @@
         printf("Empty\n"); 
 #endif
         emit stopPause();
-        if (kMid.pctl->playing) stop();
+        if (m_kMid.pctl->playing) stop();
         if (midifile_opened!=NULL) delete midifile_opened;
         midifile_opened=NULL;
         player->removeSong();
@@ -1247,9 +1244,9 @@
     
     if ((i==currentsl->getActiveSongID())&&(!initializing_songs)) return;
     int pl=0;
-    if (kMid.pctl->playing==1) pl=1;
+    if (m_kMid.pctl->playing==1) pl=1;
     
-    if (kMid.pctl->paused) emit stopPause();
+    if (m_kMid.pctl->paused) emit stopPause();
     if (/*(i!=currentsl->getActiveSongID())&&*/(pl==1)) stop();
     currentsl->setActiveSong(i);
     if (openURL(currentsl->getActiveSongName())==-1) return;
@@ -1335,12 +1332,12 @@
         if (noteArray!=NULL)
         {
             int pgm[16],j;
-            noteArray->moveIteratorTo((ulong)kMid.pctl->millisecsPlayed,pgm);
+            noteArray->moveIteratorTo((ulong)m_kMid.pctl->millisecsPlayed,pgm);
             for (j=0;j<16;j++)
             {
-                if (!kMid.pctl->forcepgm[j]) \
                channelView->changeInstrument(j,(kMid.pctl->gm==1)?(pgm[j]):(MT32toGM[pgm[j]]));
                
-                else channelView->changeInstrument(j,(kMid.pctl->pgm[j]));
-                channelView->changeForceState(j,kMid.pctl->forcepgm[j]);
+                if (!m_kMid.pctl->forcepgm[j]) \
channelView->changeInstrument(j,(m_kMid.pctl->gm==1)?(pgm[j]):(MT32toGM[pgm[j]])); +  \
else channelView->changeInstrument(j,(m_kMid.pctl->pgm[j])); +                \
channelView->changeForceState(j,m_kMid.pctl->forcepgm[j]);  };
         };
         channelView->show();
@@ -1366,7 +1363,7 @@
 
 void kmidClient::rethinkNextEvent(void)
 {
-    if (kMid.pctl->playing==0) return;
+    if (m_kMid.pctl->playing==0) return;
     timer4events->stop();
     
     int type;
@@ -1390,7 +1387,7 @@
     int autocontplaying=0;
     if ((i[0]==CHN_CHANGE_PGM)||((i[0]==CHN_CHANGE_FORCED_STATE)&&(i[3]==1)))
     {
-        if ((kMid.pctl->playing==1)&&(kMid.pctl->paused==0)) autocontplaying=1;
+        if ((m_kMid.pctl->playing==1)&&(m_kMid.pctl->paused==0)) autocontplaying=1;
         
         if (autocontplaying)
         {
@@ -1398,9 +1395,9 @@
         };
     };
     if (i[0]==CHN_CHANGE_PGM)
-        kMid.pctl->pgm[i[1]-1]=i[2];
+        m_kMid.pctl->pgm[i[1]-1]=i[2];
     else if (i[0]==CHN_CHANGE_FORCED_STATE)
-        kMid.pctl->forcepgm[i[1]-1]=i[2];
+        m_kMid.pctl->forcepgm[i[1]-1]=i[2];
     if ((i[0]==CHN_CHANGE_PGM)||((i[0]==CHN_CHANGE_FORCED_STATE)&&(i[3]==1)))
     {
         if (autocontplaying)
@@ -1426,7 +1423,7 @@
 #endif
     int autocontplaying=0;
 
-    if ((kMid.pctl->playing==1)&&(kMid.pctl->paused==0)) autocontplaying=1;
+    if ((m_kMid.pctl->playing==1)&&(m_kMid.pctl->paused==0)) autocontplaying=1;
     
 
     if (autocontplaying)
@@ -1434,22 +1431,22 @@
         pause();
     }
 
-//    double ratio=(tempoToMetronomeTempo(kMid.pctl->tempo)*kMid.pctl->ratioTempo)/(value);
                
-//    double ratio=(tempoLCD->getOldValue()*kMid.pctl->ratioTempo)/(value);
-    double ratio=(currentTempo*kMid.pctl->ratioTempo)/value;
+//    double ratio=(tempoToMetronomeTempo(m_kMid.pctl->tempo)*m_kMid.pctl->ratioTempo)/(value);
 +//    double ratio=(tempoLCD->getOldValue()*m_kMid.pctl->ratioTempo)/(value);
+    double ratio=(currentTempo*m_kMid.pctl->ratioTempo)/value;
 
     char s[20];
     sprintf(s,"%g",ratio);
     if (strcmp(s,"1")!=0) tempoLCD->setLCDColor (255,100,100);
     else tempoLCD->setLCDColor (100,255,100);
 #ifdef KMidDEBUG
-    printf("ratio : (%.9g = %g ) tempo now : %g , new tempo \
%g\n",ratio,ratio,tempoToMetronomeTempo(kMid.pctl->tempo),value); +    printf("ratio \
: (%.9g = %g ) tempo now : %g , new tempo \
%g\n",ratio,ratio,tempoToMetronomeTempo(m_kMid.pctl->tempo),value);  printf("OldValue \
: %g , value %g\n",tempoLCD->getOldValue(),value);  #endif
     
-    if (kMid.pctl->paused==1)
+    if (m_kMid.pctl->paused==1)
     {
-        pausedatmillisec=(long)(((double)pausedatmillisec/kMid.pctl->ratioTempo)*ratio);
 +        pausedatmillisec=(long)(((double)pausedatmillisec/m_kMid.pctl->ratioTempo)*ratio);
  #ifdef KMidDEBUG
         printf("pausedat : %ld\n",pausedatmillisec);
 #endif
@@ -1477,7 +1474,7 @@
     
     kdispt->calculatePositions();
     kdispt->CursorToHome();
-    if (kMid.pctl->paused==1)
+    if (m_kMid.pctl->paused==1)
         moveEventPointersTo(pausedatmillisec);
     
     if (autocontplaying)
@@ -1508,7 +1505,6 @@
 
 void kmidClient::play()
 {
-  printf("::play\n");
   slotPlay();
 }
 void kmidClient::pause()
Index: kmidclient.h
===================================================================
RCS file: /home/kde/kdemultimedia/kmid/kmidclient.h,v
retrieving revision 1.28
diff -u -r1.28 kmidclient.h
--- kmidclient.h	2000/08/03 03:55:55	1.28
+++ kmidclient.h	2000/10/03 23:33:00
@@ -63,14 +63,11 @@
     DeviceManager *midi;
     MidiPlayer *player;
 
-//    int playerProcessID;
-//    int sharedMemID;
-//    PlayerController *pctl;
+    struct kMidData m_kMid;
 
     QTimer *timer4timebar;
     QTimer *timer4events;
 
-//    timeval begintv;
     ulong beginmillisec;
     ulong pausedatmillisec;
     double currentTempo;
@@ -113,8 +110,8 @@
     char *midiFileName(void) {return midifile_opened;};
 			// If it returns NULL then there isn't any file opened
 
-    int isPlaying(void) {return kMid.pctl->playing;};
-    int isPaused(void) {return (kMid.pctl->playing)&&(kMid.pctl->paused);};
+    int isPlaying(void) {return m_kMid.pctl->playing;};
+    int isPaused(void) {return (m_kMid.pctl->playing)&&(m_kMid.pctl->paused);};
 
     int openURL(const QString s);
 
Index: kmidframe.cpp
===================================================================
RCS file: /home/kde/kdemultimedia/kmid/kmidframe.cpp,v
retrieving revision 1.43
diff -u -r1.43 kmidframe.cpp
--- kmidframe.cpp	2000/10/02 01:58:20	1.43
+++ kmidframe.cpp	2000/10/03 23:33:01
@@ -224,7 +224,7 @@
 
     if ((kapp->argc()>1)&&(kapp->argv()[1][0]!='-'))
     {
-        printf("Opening command line file...\n");
+//        printf("Opening command line file...\n");
         int backautoadd=cfg->readNumEntry("AutoAddToCollection",0);
         cfg->writeEntry("AutoAddToCollection",0);
         
@@ -347,7 +347,6 @@
   cfg->setGroup("KMid");
   if (cfg->readNumEntry("AutoAddToCollection",0)==0)
   {
-    printf("autoadd0\n");
     r=0;
     slman=kmidclient->getSLManager();
     if (setactive) slman->createTemporaryCollection();
@@ -357,22 +356,16 @@
   }
   else
   {
-    kdDebug() << "autoadd1 " << filename << "\n";
     slman=kmidclient->getSLManager();
     sl=slman->getCollection(kmidclient->getActiveCollection());
-    printf("autoadd2\n");
     r=kmidclient->getActiveCollection();
     if (sl==NULL) return 0;
     int id;
-    printf("autoadd3\n");
     if (filename==NULL) id=sl->AddSong(kmidclient->midiFileName());
     else id=sl->AddSong(filename.ascii());
-    printf("autoadd4\n");
     if (setactive)
     { 
-    printf("autoadd5\n");
       sl->setActiveSong(id);
-    printf("autoadd6\n");
     }
   }
   return r;
@@ -393,22 +386,17 @@
   QStringList list;
   QUriDrag::decodeToUnicodeUris(event, list);
   
-  kdDebug() << "dropE\n";
   if (list.count()==0) return;
 
   QStringList::ConstIterator it = list.begin();
 
-  kdDebug() << "dropE0\n";
   int c = autoAddSongToCollection(*it,1);
   
-  kdDebug() << "dropE1\n";
   for (it++ ; it != list.end(); it++) {
     autoAddSongToCollection(*it,0);
   }
 
-  kdDebug() << "dropE2\n";
   kmidclient->setActiveCollection(c);
-  kdDebug() << "dropE3\n";
 
   if ((!kmidclient->isPlaying())&&(kmidclient->midiFileName()!=NULL))
 		kmidclient->play();



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic