1 /*
2 Copyright (C) 2003 Paul Davis
3 Copyright (C) 2004-2008 Grame
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
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 Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 
21 #ifndef __JackClientControl__
22 #define __JackClientControl__
23 
24 #include "JackShmMem.h"
25 #include "JackPort.h"
26 #include "JackSynchro.h"
27 #include "JackNotification.h"
28 #include "JackSession.h"
29 
30 namespace Jack
31 {
32 
33 /*!
34 \brief Client control possibly in shared memory.
35 */
36 
37 PRE_PACKED_STRUCTURE
38 struct JackClientControl : public JackShmMemAble
39 {
40     char fName[JACK_CLIENT_NAME_SIZE + 1];
41     bool fCallback[kMaxNotification];
42     volatile jack_transport_state_t fTransportState;
43     volatile bool fTransportSync;      /* Will be true when slow-sync cb has to be called */
44     volatile bool fTransportTimebase;  /* Will be true when timebase cb is called with new_pos on */
45     int fRefNum;
46     int fPID;
47     bool fActive;
48 
49     jack_uuid_t fSessionID;
50     char fSessionCommand[JACK_SESSION_COMMAND_SIZE];
51     jack_session_flags_t fSessionFlags;
52 
JackClientControlJackClientControl53     JackClientControl(const char* name, int pid, int refnum, jack_uuid_t uuid)
54     {
55         Init(name, pid, refnum, uuid);
56     }
57 
JackClientControlJackClientControl58     JackClientControl(const char* name, jack_uuid_t uuid)
59     {
60         Init(name, 0, -1, uuid);
61     }
62 
JackClientControlJackClientControl63     JackClientControl()
64     {
65         Init("", 0, -1, JACK_UUID_EMPTY_INITIALIZER);
66     }
67 
InitJackClientControl68     void Init(const char* name, int pid, int refnum, jack_uuid_t uuid)
69     {
70         strcpy(fName, name);
71         for (int i = 0; i < kMaxNotification; i++) {
72             fCallback[i] = false;
73         }
74         // Always activated
75         fCallback[kAddClient] = true;
76         fCallback[kRemoveClient] = true;
77         fCallback[kActivateClient] = true;
78         fCallback[kLatencyCallback] = true;
79         // So that driver synchro are correctly setup in "flush" or "normal" mode
80         fCallback[kStartFreewheelCallback] = true;
81         fCallback[kStopFreewheelCallback] = true;
82         fRefNum = refnum;
83         fPID = pid;
84         fTransportState = JackTransportStopped;
85         fTransportSync = false;
86         fTransportTimebase = false;
87         fActive = false;
88 
89         fSessionID = uuid;
90     }
91 
92 } POST_PACKED_STRUCTURE;
93 
94 } // end of namespace
95 
96 
97 #endif
98