1
//----------------------------------------------------------------------------
3
// This file is part of seq24.
5
// seq24 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
// seq24 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 seq24; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
//-----------------------------------------------------------------------------
22
#include <sigc++/slot.h>
29
lash::lash(int *argc, char ***argv)
32
m_client = lash_init(lash_extract_args(argc, argv), PACKAGE_NAME,
33
LASH_Config_File, LASH_PROTOCOL(2, 0));
34
if (m_client == NULL) {
35
fprintf(stderr, "Failed to connect to LASH. Session management will not occur.\n");
37
lash_event_t* event = lash_event_new_with_type(LASH_Client_Name);
38
lash_event_set_string(event, "Seq24");
39
lash_send_event(m_client, event);
40
printf("[Connected to LASH]\n");
42
#endif // LASH_SUPPORT
47
lash::set_alsa_client_id(int id)
50
lash_alsa_client_id(m_client, id);
56
lash::start(perform* perform)
61
/* Process any LASH events every 250 msec (arbitrarily chosen interval) */
62
Glib::signal_timeout().connect(sigc::mem_fun(*this, &lash::process_events), 250);
63
#endif // LASH_SUPPORT
70
lash::process_events()
72
lash_event_t *ev = NULL;
73
//lash_config_t *conf = NULL;
76
while ((ev = lash_get_event(m_client)) != NULL) {
78
lash_event_destroy(ev);
86
lash::handle_event(lash_event_t* ev)
88
LASH_Event_Type type = lash_event_get_type(ev);
89
const char *c_str = lash_event_get_string(ev);
90
std::string str = (c_str == NULL) ? "" : c_str;
92
if (type == LASH_Save_File) {
93
midifile f(str + "/seq24.mid");
95
lash_send_event(m_client, lash_event_new_with_type(LASH_Save_File));
96
} else if (type == LASH_Restore_File) {
97
midifile f(str + "/seq24.mid");
98
f.parse(m_perform, 0);
99
lash_send_event(m_client, lash_event_new_with_type(LASH_Restore_File));
100
} else if (type == LASH_Quit) {
104
fprintf(stderr, "Warning: Unhandled LASH event.\n");
110
lash::handle_config(lash_config_t* conf)
112
const char *key = NULL;
113
const void *val = NULL;
116
key = lash_config_get_key(conf);
117
val = lash_config_get_value(conf);
118
val_size = lash_config_get_value_size(conf);
122
#endif // LASH_SUPPORT