/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2111 by capela, Thu Jul 15 08:03:32 2010 UTC revision 2112 by capela, Wed Jul 21 18:33:25 2010 UTC
# Line 93  static WSADATA _wsaData; Line 93  static WSADATA _wsaData;
93  #endif  #endif
94    
95    
96    //-------------------------------------------------------------------------
97    // LADISH Level 1 support stuff.
98    
99    #ifdef HAVE_SIGNAL_H
100    
101    #include <QSocketNotifier>
102    
103    #include <sys/types.h>
104    #include <sys/socket.h>
105    
106    #include <signal.h>
107    
108    // File descriptor for SIGUSR1 notifier.
109    static int g_fdUsr1[2];
110    
111    // Unix SIGUSR1 signal handler.
112    static void qsampler_sigusr1_handler ( int /* signo */ )
113    {
114            char c = 1;
115    
116            (::write(g_fdUsr1[0], &c, sizeof(c)) > 0);
117    }
118    
119    #endif  // HAVE_SIGNAL_H
120    
121    
122    //-------------------------------------------------------------------------
123    // qsampler -- namespace
124    
125    
126  namespace QSampler {  namespace QSampler {
127    
128  // Timer constant stuff.  // Timer constant stuff.
# Line 107  namespace QSampler { Line 137  namespace QSampler {
137    
138  // Specialties for thread-callback comunication.  // Specialties for thread-callback comunication.
139  #define QSAMPLER_LSCP_EVENT   QEvent::Type(QEvent::User + 1)  #define QSAMPLER_LSCP_EVENT   QEvent::Type(QEvent::User + 1)
 #define QSAMPLER_SAVE_EVENT   QEvent::Type(QEvent::User + 2)  
140    
141    
142  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
# Line 140  private: Line 169  private:
169    
170    
171  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
 // LADISH Level 1 support stuff.  
   
 void qsampler_on_sigusr1 ( int /*signo*/ )  
 {  
         QApplication::postEvent(  
                 MainForm::getInstance(),  
                 new QEvent(QSAMPLER_SAVE_EVENT));  
 }  
   
   
 //-------------------------------------------------------------------------  
172  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
173    
174  // Kind of singleton reference.  // Kind of singleton reference.
# Line 185  MainForm::MainForm ( QWidget *pParent ) Line 203  MainForm::MainForm ( QWidget *pParent )
203          m_iTimerSlot = 0;          m_iTimerSlot = 0;
204    
205  #ifdef HAVE_SIGNAL_H  #ifdef HAVE_SIGNAL_H
206    
207          // Set to ignore any fatal "Broken pipe" signals.          // Set to ignore any fatal "Broken pipe" signals.
208          ::signal(SIGPIPE, SIG_IGN);          ::signal(SIGPIPE, SIG_IGN);
209    
210          // LADISH Level 1 suport.          // LADISH Level 1 suport.
211          ::signal(SIGUSR1, qsampler_on_sigusr1);  
212  #endif          // Initialize file descriptors for SIGUSR1 socket notifier.
213            ::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1);
214            m_pUsr1Notifier
215                    = new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this);
216    
217            QObject::connect(m_pUsr1Notifier,
218                    SIGNAL(activated(int)),
219                    SLOT(handle_sigusr1()));
220    
221            // Install SIGUSR1 signal handler.
222        struct sigaction usr1;
223        usr1.sa_handler = qsampler_sigusr1_handler;
224        ::sigemptyset(&usr1.sa_mask);
225        usr1.sa_flags = 0;
226        usr1.sa_flags |= SA_RESTART;
227        ::sigaction(SIGUSR1, &usr1, NULL);
228    
229    #else   // HAVE_SIGNAL_H
230    
231            m_pSocketNotifier = NULL;
232            
233    #endif  // !HAVE_SIGNAL_H
234    
235  #ifdef CONFIG_VOLUME  #ifdef CONFIG_VOLUME
236          // Make some extras into the toolbar...          // Make some extras into the toolbar...
# Line 362  MainForm::~MainForm() Line 403  MainForm::~MainForm()
403          WSACleanup();          WSACleanup();
404  #endif  #endif
405    
406    #ifdef HAVE_SIGNAL_H
407            if (m_pUsr1Notifier)
408                    delete m_pUsr1Notifier;
409    #endif
410    
411          // Finally drop any widgets around...          // Finally drop any widgets around...
412          if (m_pDeviceForm)          if (m_pDeviceForm)
413                  delete m_pDeviceForm;                  delete m_pDeviceForm;
# Line 638  void MainForm::customEvent ( QEvent* pEv Line 684  void MainForm::customEvent ( QEvent* pEv
684                                          .arg(::lscp_event_to_text(pLscpEvent->event()))                                          .arg(::lscp_event_to_text(pLscpEvent->event()))
685                                          .arg(pLscpEvent->data()), "#996699");                                          .arg(pLscpEvent->data()), "#996699");
686                  }                  }
687          }       // LADISH1 Level 1 support...          }
688          else if (pEvent->type() == QSAMPLER_SAVE_EVENT)  }
689    
690    
691    // LADISH Level 1 -- SIGUSR1 signal handler.
692    void MainForm::handle_sigusr1 (void)
693    {
694            char c;
695    
696            if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0)
697                  saveSession(false);                  saveSession(false);
698  }  }
699    

Legend:
Removed from v.2111  
changed lines
  Added in v.2112

  ViewVC Help
Powered by ViewVC