1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009,2010,2011 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
8 **************************************************************************
9 * This file contains the liblash interface
10 **************************************************************************
12 * LADI Session Handler is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * LADI Session Handler is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
24 * or write to the Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <uuid/uuid.h>
35 #include <sys/types.h>
37 #define LASH_PROTOCOL_MAJOR 2
38 #define LASH_PROTOCOL_MINOR 0
39 #define LASH_PROTOCOL_MAJOR_MASK 0xFFFF0000
40 #define LASH_PROTOCOL_MINOR_MASK 0x0000FFFF
41 #define LASH_PROTOCOL(major, minor) ((lash_protocol_t)( ((major << 16) & LASH_PROTOCOL_MAJOR_MASK) | (minor & LASH_PROTOCOL_MINOR_MASK)))
42 #define LASH_PROTOCOL_VERSION (LASH_PROTOCOL (LASH_PROTOCOL_MAJOR, LASH_PROTOCOL_MINOR))
43 #define LASH_PROTOCOL_GET_MAJOR(protocol) ((lash_protocol_t) (((protocol & LASH_PROTOCOL_MAJOR_MASK) >> 16)))
44 #define LASH_PROTOCOL_GET_MINOR(protocol) ((lash_protocol_t) (protocol & LASH_PROTOCOL_MINOR_MASK))
45 #define LASH_PROTOCOL_IS_VALID(proto) ((LASH_PROTOCOL_GET_MAJOR (proto) == LASH_PROTOCOL_MAJOR) && (LASH_PROTOCOL_GET_MINOR (proto) <= LASH_PROTOCOL_MINOR))
46 #define LASH_DEFAULT_PORT 14541
47 #define lash_enabled(client) 0
48 #define LASH_PORT "14541"
50 typedef uint32_t lash_protocol_t
;
54 LASH_Config_Data_Set
= 0x00000001,
55 LASH_Config_File
= 0x00000002,
56 LASH_Server_Interface
= 0x00000004,
57 LASH_No_Autoresume
= 0x00000008,
58 LASH_Terminal
= 0x00000010,
59 LASH_No_Start_Server
= 0x00000020
65 LASH_Jack_Client_Name
,
70 LASH_Restore_Data_Set
,
83 typedef struct _lash_args lash_args_t
;
84 typedef struct _lash_client lash_client_t
;
85 typedef struct _lash_event lash_event_t
;
86 typedef struct _lash_config lash_config_t
;
95 const char * lash_protocol_string(lash_protocol_t protocol
);
97 lash_args_t
* lash_extract_args(int * argc
, char *** argv
);
98 void lash_args_destroy(lash_args_t
* args
);
100 lash_client_t
* lash_init(const lash_args_t
* args
, const char * client_class
, int client_flags
, lash_protocol_t protocol
);
102 int lash_server_connected(lash_client_t
* client
);
103 const char * lash_get_server_name(lash_client_t
* client
);
105 unsigned int lash_get_pending_event_count(lash_client_t
* client
);
106 lash_event_t
* lash_get_event(lash_client_t
* client
);
107 unsigned int lash_get_pending_config_count(lash_client_t
* client
);
108 lash_config_t
* lash_get_config(lash_client_t
* client
);
111 void lash_send_event(lash_client_t
* client
, lash_event_t
* event
);
112 void lash_send_config(lash_client_t
* client
, lash_config_t
* config
);
115 lash_event_t
* lash_event_new(void);
116 lash_event_t
* lash_event_new_with_type(enum LASH_Event_Type type
);
117 lash_event_t
* lash_event_new_with_all(enum LASH_Event_Type type
, const char * string
);
118 void lash_event_destroy(lash_event_t
* event
);
120 enum LASH_Event_Type
lash_event_get_type(const lash_event_t
* event
);
121 const char * lash_event_get_string(const lash_event_t
* event
);
122 const char * lash_event_get_project(const lash_event_t
* event
);
123 void lash_event_get_client_id(const lash_event_t
* event
, uuid_t id
);
125 void lash_event_set_type(lash_event_t
* event
, enum LASH_Event_Type type
);
126 void lash_event_set_string(lash_event_t
* event
, const char * string
);
127 void lash_event_set_project(lash_event_t
* event
, const char * project
);
128 void lash_event_set_client_id(lash_event_t
* event
, uuid_t id
);
129 void lash_str_set_alsa_client_id(char * str
, unsigned char alsa_id
);
130 void lash_event_set_alsa_client_id(lash_event_t
* event
, unsigned char alsa_id
);
132 unsigned char lash_event_get_alsa_client_id(const lash_event_t
* event
);
133 unsigned char lash_str_get_alsa_client_id(const char * str
);
135 void lash_jack_client_name(lash_client_t
* client
, const char * name
);
136 void lash_alsa_client_id(lash_client_t
* client
, unsigned char id
);
139 lash_config_t
* lash_config_new(void);
140 lash_config_t
* lash_config_dup(const lash_config_t
* config
);
141 lash_config_t
* lash_config_new_with_key(const char * key
);
142 void lash_config_destroy(lash_config_t
* config
);
143 const char * lash_config_get_key(const lash_config_t
* config
);
144 const void * lash_config_get_value(const lash_config_t
* config
);
145 size_t lash_config_get_value_size(const lash_config_t
* config
);
146 void lash_config_set_key(lash_config_t
* config
, const char * key
);
147 void lash_config_set_value(lash_config_t
* config
, const void * value
, size_t value_size
);
148 uint32_t lash_config_get_value_int(const lash_config_t
* config
);
149 float lash_config_get_value_float(const lash_config_t
* config
);
150 double lash_config_get_value_double(const lash_config_t
* config
);
151 const char * lash_config_get_value_string(const lash_config_t
* config
);
152 void lash_config_set_value_int(lash_config_t
* config
, uint32_t value
);
153 void lash_config_set_value_float(lash_config_t
* config
, float value
);
154 void lash_config_set_value_double(lash_config_t
* config
, double value
);
155 void lash_config_set_value_string(lash_config_t
* config
, const char * value
);
157 /* internal function in lash-0.5.x, depecated in lash-0.6.x, used by jack-rack */
158 const char * lash_get_fqn(const char * dir
, const char * file
);
164 #endif /* __LASH_H__ */