Use jack_client_open instead of old jack_client_new.
[jack2.git] / common / JackWaitThreadedDriver.h
blobf81db20c5f56b66c30d38bfd73aa4c7589d99abc
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JackWaitThreadedDriver__
22 #define __JackWaitThreadedDriver__
24 #include "JackThreadedDriver.h"
25 #include "JackAudioDriver.h"
27 namespace Jack
30 /*!
31 \brief To be used as a wrapper of JackNetDriver.
33 The idea is to behave as the "dummy" driver, until the network connection is really started and processing starts.
34 The Execute method will call the ProcessNull method until the decorated driver Init method returns.
35 A helper JackDriverStarter thread is used for that purpose.
38 class SERVER_EXPORT JackWaitThreadedDriver : public JackThreadedDriver
40 private:
42 struct SERVER_EXPORT JackDriverStarter : public JackRunnableInterface
45 JackDriver* fDriver;
46 JackThread fThread;
47 bool fRunning;
49 JackDriverStarter(JackDriver* driver)
50 :fDriver(driver),fThread(this),fRunning(false)
53 ~JackDriverStarter()
55 fThread.Kill();
58 int Start()
60 fRunning = false;
61 return fThread.Start();
64 // JackRunnableInterface interface
65 bool Execute()
67 // Blocks until decorated driver is started (that is when it's Init method returns).
68 fDriver->Initialize();
69 fRunning = true;
70 return false;
75 JackDriverStarter fStarter;
77 public:
79 JackWaitThreadedDriver(JackDriver* netdriver)
80 :JackThreadedDriver(netdriver),fStarter(netdriver)
82 virtual ~JackWaitThreadedDriver()
85 // JackRunnableInterface interface
86 bool Init();
87 bool Execute();
88 };
91 } // end of namespace
94 #endif