JackSocketClientChannel.h 4.7 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
3
Copyright (C) 2004-2008 Grame

sletz's avatar
sletz committed
4
5
6
7
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
sletz's avatar
sletz committed
8

sletz's avatar
sletz committed
9
10
11
12
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.
sletz's avatar
sletz committed
13

sletz's avatar
sletz committed
14
15
16
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sletz's avatar
sletz committed
17
18
19
20
21
22
23
24

*/

#ifndef __JackSocketClientChannel__
#define __JackSocketClientChannel__

#include "JackChannel.h"
#include "JackSocket.h"
25
#include "JackPlatformPlug.h"
sletz's avatar
sletz committed
26
#include "JackRequest.h"
sletz's avatar
sletz committed
27
#include "JackError.h"
sletz's avatar
sletz committed
28
29
30
31
32
33
34
35

namespace Jack
{

/*!
\brief JackClientChannel using sockets.
*/

36
class JackSocketClientChannel : public detail::JackClientChannelInterface, public JackRunnableInterface
sletz's avatar
sletz committed
37
38
39
40
{

    private:

41
42
43
        JackClientSocket fRequestSocket;                        // Socket to communicate with the server
        JackServerSocket fNotificationListenSocket;     // Socket listener for server notification
        JackClientSocket* fNotificationSocket;          // Socket for server notification
44
        JackThread fThread;                         // Thread to execute the event loop
45
        JackClient*     fClient;
sletz's avatar
sletz committed
46

47
48
        void ServerSyncCall(JackRequest* req, JackResult* res, int* result);
        void ServerAsyncCall(JackRequest* req, JackResult* res, int* result);
sletz's avatar
sletz committed
49
50
51
52
53
54

    public:

        JackSocketClientChannel();
        virtual ~JackSocketClientChannel();

55
        int Open(const char* server_name, const char* name, int uuid, char* name_res, JackClient* obj, jack_options_t options, jack_status_t* status);
sletz's avatar
sletz committed
56
57
58
59
60
        void Close();

        int Start();
        void Stop();

sletz's avatar
sletz committed
61
62
        int ServerCheck(const char* server_name);

63
        void ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result);
64
65
        void ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result);
        void ClientOpen(const char* name, int* ref, int uuid, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, int* result)
66
        {}
sletz's avatar
sletz committed
67
68
        void ClientClose(int refnum, int* result);

sletz's avatar
sletz committed
69
        void ClientActivate(int refnum, int is_real_time, int* result);
sletz's avatar
sletz committed
70
71
        void ClientDeactivate(int refnum, int* result);

sletz's avatar
sletz committed
72
        void PortRegister(int refnum, const char* name, const char* type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index, int* result);
sletz's avatar
sletz committed
73
74
75
76
77
78
79
        void PortUnRegister(int refnum, jack_port_id_t port_index, int* result);

        void PortConnect(int refnum, const char* src, const char* dst, int* result);
        void PortDisconnect(int refnum, const char* src, const char* dst, int* result);

        void PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result);
        void PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result);
80
81
        
        void PortRename(int refnum, jack_port_id_t port, const char* name, int* result);
sletz's avatar
sletz committed
82

83
        void SetBufferSize(jack_nframes_t buffer_size, int* result);
sletz's avatar
sletz committed
84
85
86
87
        void SetFreewheel(int onoff, int* result);

        void ReleaseTimebase(int refnum, int* result);
        void SetTimebaseCallback(int refnum, int conditional, int* result);
sletz's avatar
sletz committed
88
89

        void GetInternalClientName(int refnum, int int_ref, char* name_res, int* result);
90
        void InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result);
Stéphane LETZ's avatar
Stéphane LETZ committed
91
        void InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int uuid, int* result);
92
        void InternalClientUnload(int refnum, int int_ref, int* status, int* result);
sletz's avatar
sletz committed
93

94
95
96
97
98
99
        // Session Stuff
        void SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char* path, jack_session_command_t** result);
        void SessionReply(int refnum, int* result);
        void GetUUIDForClientName( int refnum, const char *client_name, char *uuid_res, int *result );
        void GetClientNameForUUID( int refnum, const char *uuid, char *name_res, int *result );
        void ReserveClientName( int refnum, const char *client_name, const char *uuid, int *result );
100

sletz's avatar
sletz committed
101
102
103
        // JackRunnableInterface interface
        bool Init();
        bool Execute();
104

105

106
        bool IsChannelThread() { return fThread.IsThread(); }
sletz's avatar
sletz committed
107
108
109
110
111
112
};

} // end of namespace

#endif