hydrogen 1.2.3
LashClient.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
30
31#if defined(H2CORE_HAVE_LASH) || _DOXYGEN_
32
33#include <lash-1.0/lash/lash.h>
35#include <core/H2Exception.h>
36
37using namespace H2Core;
38
40
41void LashClient::create_instance( const char *lashClass,
42 const char *viewName,
43 int *argc,
44 char ***argv )
45{
46 __instance = new LashClient(lashClass, viewName, argc, argv);
47}
48
49LashClient::LashClient(const char* lashClass, const char* viewName, int* argc, char*** argv)
50{
51 __instance = this;
52
53 if ( H2Core::Preferences::get_instance()->useLash() ){
54 newProject = true;
55 lash_args_t *lash_args = lash_extract_args(argc, argv);
56 lashClient = lash_init(lash_args, lashClass, LASH_Config_File, LASH_PROTOCOL(2, 0));
57
58 if (isConnected())
59 {
60 sendEvent(LASH_Client_Name, viewName);
61 }
62 }
63
64}
65
70
72{
73 return lash_enabled(lashClient);
74}
75
76
78{
79 newProject = value;
80}
81
83{
84 return newProject;
85}
86
88{
89 return lashClient;
90}
91
93{
94 lash_event_t* event = lash_get_event(lashClient);
95 return event;
96}
97
98void LashClient::sendEvent(LASH_Event_Type eventType)
99{
100 sendEvent(eventType, nullptr);
101}
102
103void LashClient::sendEvent(LASH_Event_Type eventType, const char* value)
104{
105 lash_event_t *event = lash_event_new_with_type(eventType);
106 if (value != nullptr)
107 {
108 lash_event_set_string(event, value);
109 }
110 lash_send_event(lashClient, event);
111}
112
113void LashClient::setJackClientName( const std::string& name )
114{
115 jackClientName = name;
116}
117
119{
120 lash_jack_client_name(lashClient, jackClientName.c_str());
121}
122
123void LashClient::setAlsaClientId(unsigned char id)
124{
125 alsaClientId = id;
126}
127
129{
130 lash_alsa_client_id(lashClient, alsaClientId);
131}
132
133#endif
134
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
bool newProject
Definition LashClient.h:73
static void create_instance(const char *lashClass, const char *viewName, int *argc, char ***argv)
static reference of LashClient class (Singleton)
lash_client_t * getConnection()
bool isNewProject()
void sendAlsaClientId()
lash_event_t * getNextEvent()
void sendEvent(LASH_Event_Type eventType, const char *value)
bool isConnected()
unsigned char alsaClientId
Definition LashClient.h:81
std::string jackClientName
Name of the external JACK client Hydrogen is using to communicate with the JACK server.
Definition LashClient.h:80
void setNewProject(bool value)
static LashClient * __instance
Definition LashClient.h:82
lash_client_t * lashClient
Definition LashClient.h:74
LashClient(const char *lashClass, const char *viewName, int *argc, char ***argv)
void setJackClientName(const std::string &jackClientName)
Set the name of the JACK client by modifying jackClientName.
void setAlsaClientId(unsigned char id)
void sendJackClientName()