|
Part of OpenCallback() responsible for linking and loading of the drumkit samples.
Upon first invocation of this function in a new project, a symbolic link to the folder containing the samples of the current drumkit will be created in following runs of the session the linked samples will be used over the default ones.
If the session were archived, the symbolic link would had been replaced by a folder containing the samples. In such an occasion the samples located in the folder will be loaded. This ensure portability of Hydrogen within a session regardless of the local drumkits present in the user's home.
- Parameters
-
| name | Absolute path to the session folder. |
| bCheckLinkage | Whether or not the linked drumkit should be verified to correspond to name. If set to none, the drumkit will always be relinked. |
|
| QString | m_sSessionFolderPath |
| | Folder all the content of the current session will be stored in. More...
|
| |
| nsm_client_t * | m_pNsm |
| | Stores the current instance of the NSM client. More...
|
| |
| bool | m_bUnderSessionManagement |
| | To determine whether Hydrogen is under Non session management, it is not sufficient to check whether the NSM_URL environmental variable is set but also whether the NSM server did respond to the announce message appropriately. More...
|
| |
| static bool | bNsmShutdown = false |
| | Indicates whether the NsmClient::NsmProcessEvent() function should continue processing events. More...
|
| |
| bool | getUnderSessionManagement () const |
| |
| static void | linkDrumkit (const char *name, bool bCheckLinkage) |
| |
| static void | printError (const QString &msg) |
| | Custom function to print a colored error message. More...
|
| |
| static void | printMessage (const QString &msg) |
| | Custom function to print a colored message. More...
|
| |
| | NsmClient () |
| | Private constructor to allow construction only via create_instance(). More...
|
| |
| static int | OpenCallback (const char *name, const char *displayName, const char *clientID, char **outMsg, void *userData) |
| | Callback function for the NSM server to tell Hydrogen to open a H2Core::Song. More...
|
| |
| static int | SaveCallback (char **outMsg, void *userData) |
| | Callback function for the NSM server to tell Hydrogen to save the current session. More...
|
| |
| static void * | ProcessEvent (void *data) |
| | Event handling function of the NSM client. More...
|
| |
| static void | copyPreferences (const char *name) |
| | Part of OpenCallback() responsible for copying and loading the preferences. More...
|
| |
Non session manager client implementation.
Non session management (NSM) is the name for both a standard/API allowing for a reproducible, multi-application session handling in Linux systems as well as for the actual application - the non-session-manager - implementing it.
Hydrogen is compliant with the standard, send dirty flag to the NSM server to indicate unsaved changes, and is able to switch between different sessions without restarting the entire application. However, Hydrogen does use several files to store all options the user is able to customize and not all of them are stored inside the folder provided by the NSM server. While the song file will be kept there, both the drumkit and preferences are stored elsewhere. Altering either of them can very well affect the state of the individual session, e.g. by disabling a prior set the per track output option of the JACK driver outside of the session and restarting it. So, be very careful.
- Author
- Sebastian Moors
| void createInitialClient |
( |
| ) |
|
Actual setup, initialization, and registration of the NSM client.
It create a new NSM client, sets the callback functions nsm_open_cb() and nsm_save_cb(), and registers the newly created client with the NSM server. It also indicates that Hydrogen does support the two NSM options "dirty" and "switch", allowing the server to notice whenever there are unsaved changes and to switch between Songs without restarting the whole application.
This function will performs action if a NSM server is already running. This will be indicated by a set environmental variable called "NSM_URL". However, this is condition is not sufficient and only after receiving a certain response - handled by the NSM API inside the nsm_free() function - to the announce message sent by Hydrogen, the client can truly be considered under session management. This particular state will be indicated by setting m_bUnderSessionManagement to true.
| int OpenCallback |
( |
const char * |
name, |
|
|
const char * |
displayName, |
|
|
const char * |
clientID, |
|
|
char ** |
outMsg, |
|
|
void * |
userData |
|
) |
| |
|
staticprivate |
Callback function for the NSM server to tell Hydrogen to open a H2Core::Song.
This function has two separate purposes:
- it is used to load the initial session including its H2Core::Song and to set up the audio driver when started via the NSM server.
- It handles the switching between sessions by loading the H2Core::Song, the H2Core::Preferences, and the H2Core::Drumkit of the new session without the need to restart the whole application.
To fulfill the 1. purpose, it is important to know that the core part of H2Core::Hydrogen is already initialized when this function is called, but the GUI isn't. In order to allow for a rewiring of all per track JACK output ports, the H2Core::JackAudioDriver::init() function must register them alongside the main left and right output ports in the very initialization and not at a later stage. Therefore, the starting of the audio driver is prohibited whenever the "NSM_URL" environmental variable is set, H2Core::Hydrogen::setInitialSong() is used to store the loaded H2Core::Song, and H2Core::Hydrogen::restartDrivers() to start the audio driver and - if JACK is chosen - to create all per track output ports right away. In addition, is also calls H2Core::Hydrogen::restartLadspaFX() and H2Core::Sampler::reinitialize_playback_track() to set up the missing core parts of Hydrogen.
In the 2. case of switching between session the function will construct an Action of type "OPEN_SONG" - or "NEW_SONG" if no file exists with the provided file path - triggering MidiActionManager::open_song() or MidiActionManager::new_song().
If the GUI is present, it waits - up to 11 seconds - until the H2Core::Song was asynchronously set by the GUI (as a response to the action). This (regular) procedure is only done if a GUI is present and fully loaded and thus H2Core::Hydrogen::m_GUIState is set to H2Core::Hydrogen::GUIState::ready.
All files and symbolic links will be stored in a folder created by this function and named according to name.
- Parameters
-
| name | Unique name corresponding to the current session. A folder using this particular name will be created, which will contain the H2Core::Song - using name appended by ".h2song" as file name -, the local H2Core::Preferences, and a symbolic link to the H2Core::Drumkit in use. |
| displayName | Name the application will be presented with by the NSM server. It is determined in NsmClient::createInitialClient() and set to "Hydrogen". |
| clientID | Unique prefix also present in name, "nJKUV". It will be stored in H2Core::Preferences::m_sNsmClientId to provide it as a suffix when creating a JACK client in H2Core::JackAudioDriver::init(). |
| outMsg | Unused argument. Kept for API compatibility. |
| userData | Unused argument. Kept for API compatibility. |
- Returns
- ERR_OK (0): indicating that everything worked fine.
- ERR_LAUNCH_FAILED (-4): If no clientID provided, the H2Core::Song corresponding to the file path of a concatenation of name and ".h2song" could not be loaded, or the Action could not be provided to MidiActionManager::handleAction().
- ERR_NOT_NOW (-8): If the H2Core::Preferences instance was not initialized.
- See also
- copyPreferences()
-
linkDrumkit()