Jack2 1.9.6

JackWaitThreadedDriver.h

00001 /*
00002  Copyright (C) 2001 Paul Davis
00003  Copyright (C) 2004-2008 Grame
00004 
00005  This program is free software; you can redistribute it and/or modify
00006  it under the terms of the GNU General Public License as published by
00007  the Free Software Foundation; either version 2 of the License, or
00008  (at your option) any later version.
00009 
00010  This program is distributed in the hope that it will be useful,
00011  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  GNU General Public License for more details.
00014 
00015  You should have received a copy of the GNU General Public License
00016  along with this program; if not, write to the Free Software
00017  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 */
00020 
00021 #ifndef __JackWaitThreadedDriver__
00022 #define __JackWaitThreadedDriver__
00023 
00024 #include "JackThreadedDriver.h"
00025 #include "JackAudioDriver.h"
00026 
00027 namespace Jack
00028 {
00029     
00038 class SERVER_EXPORT JackWaitThreadedDriver : public JackThreadedDriver
00039 {
00040     private:
00041     
00042         struct SERVER_EXPORT JackDriverStarter : public JackRunnableInterface 
00043         {
00044         
00045                 JackDriver* fDriver;
00046                 JackThread fThread;
00047                 bool fRunning;
00048                 
00049                 JackDriverStarter(JackDriver* driver)
00050                     :fDriver(driver),fThread(this),fRunning(false)
00051                 {}
00052                 
00053                 ~JackDriverStarter()
00054                 {
00055                      fThread.Kill();
00056                 }
00057                 
00058                 int Start()
00059                 {
00060                     fRunning = false;
00061                     return fThread.Start();
00062                 }
00063             
00064                 // JackRunnableInterface interface
00065                 bool Execute()
00066                 {
00067                     // Blocks until decorated driver is started (that is when it's Init method returns).
00068                     fDriver->Initialize();
00069                     fRunning = true;
00070                     return false;
00071                 }
00072         
00073         };
00074         
00075         JackDriverStarter fStarter;
00076                 
00077     public:
00078 
00079         JackWaitThreadedDriver(JackDriver* netdriver)
00080             :JackThreadedDriver(netdriver),fStarter(netdriver)
00081         {}
00082         virtual ~JackWaitThreadedDriver()
00083         {}
00084     
00085         // JackRunnableInterface interface
00086         bool Init();
00087         bool Execute();
00088 };    
00089 
00090 
00091 } // end of namespace
00092 
00093 
00094 #endif