--- liblscp/trunk/src/client.c 2007/10/12 22:43:38 1412 +++ liblscp/trunk/src/client.c 2008/02/15 17:04:34 1692 @@ -2,7 +2,7 @@ // /**************************************************************************** liblscp - LinuxSampler Control Protocol API - Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2008, rncbc aka Rui Nuno Capela. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -84,27 +84,30 @@ if (cchBuffer > 0) { // Make sure received buffer it's null terminated. achBuffer[cchBuffer] = (char) 0; - // Parse for the notification event message... - pszToken = lscp_strtok(achBuffer, pszSeps, &(pch)); // Have "NOTIFY". - if (strcasecmp(pszToken, "NOTIFY") == 0) { - pszToken = lscp_strtok(NULL, pszSeps, &(pch)); - event = lscp_event_from_text(pszToken); - // And pick the rest of data... - pszToken = lscp_strtok(NULL, pszSeps, &(pch)); - cchToken = (pszToken == NULL ? 0 : strlen(pszToken)); - // Double-check if we're really up to it... - if (pClient->events & event) { - // Invoke the client event callback... - if ((*pClient->pfnCallback)( - pClient, - event, - pszToken, - cchToken, - pClient->pvData) != LSCP_OK) { - pClient->evt.iState = 0; + pch = achBuffer; + do { + // Parse for the notification event message... + pszToken = lscp_strtok(NULL, pszSeps, &(pch)); // Have "NOTIFY" + if (strcasecmp(pszToken, "NOTIFY") == 0) { + pszToken = lscp_strtok(NULL, pszSeps, &(pch)); + event = lscp_event_from_text(pszToken); + // And pick the rest of data... + pszToken = lscp_strtok(NULL, pszSeps, &(pch)); + cchToken = (pszToken == NULL ? 0 : strlen(pszToken)); + // Double-check if we're really up to it... + if (pClient->events & event) { + // Invoke the client event callback... + if ((*pClient->pfnCallback)( + pClient, + event, + pszToken, + cchToken, + pClient->pvData) != LSCP_OK) { + pClient->evt.iState = 0; + } } } - } + } while (*pch); } else { lscp_socket_perror("_lscp_client_evt_proc: recv"); pClient->evt.iState = 0; @@ -578,7 +581,13 @@ // Client registration protocol functions. /** - * Register frontend for receiving event messages: + * Register frontend for receiving event messages. + * @e Caution: since liblscp v0.5.5.4 you have to call lscp_client_subscribe() + * for @e each event you want to subscribe. That is the old bitflag approach + * was abondoned at this point. You can however still register all older + * events with one lscp_client_subscribe() call at once. Thus, the old + * behavior of this functions was not broken. Those older events are namely: + * @code * SUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT * | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT * | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO @@ -586,6 +595,13 @@ * | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO * | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO * | MISCELLANEOUS + * @endcode + * The old events occupy the lower 16 bits (as bit flags), and all younger + * events enumerate the whole upper 16 bits range. The new, enumerated + * events are namely: + * @code + * SUBSCRIBE CHANNEL_MIDI + * @endcode * * @param pClient Pointer to client instance structure. * @param events Bit-wise OR'ed event flags to subscribe. @@ -594,7 +610,7 @@ */ lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient, lscp_event_t events ) { - lscp_status_t ret = LSCP_FAILED; + lscp_status_t ret = LSCP_OK; if (pClient == NULL) return LSCP_FAILED; @@ -637,6 +653,9 @@ ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MIDI_INSTRUMENT_INFO); if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS); + // Caution: for the upper 16 bits, we don't use bit flags anymore ... + if (ret == LSCP_OK && ((events & 0xffff0000) == LSCP_EVENT_CHANNEL_MIDI)) + ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_MIDI); // Unlock this section down. lscp_mutex_unlock(pClient->mutex); @@ -647,6 +666,13 @@ /** * Deregister frontend from receiving UDP event messages anymore: + * @e Caution: since liblscp v0.5.5.4 you have to call + * lscp_client_unsubscribe() for @e each event you want to unsubscribe. + * That is the old bitflag approach was abondoned at this point. You can + * however still register all older events with one lscp_client_subscribe() + * call at once. Thus, the old behavior of this functions was not broken. + * Those older events are namely: + * @code * UNSUBSCRIBE CHANNEL_COUNT | VOICE_COUNT | STREAM_COUNT * | BUFFER_FILL | CHANNEL_INFO | TOTAL_VOICE_COUNT * | AUDIO_OUTPUT_DEVICE_COUNT | AUDIO_OUTPUT_DEVICE_INFO @@ -654,6 +680,13 @@ * | MIDI_INSTRUMENT_MAP_COUNT | MIDI_INSTRUMENT_MAP_INFO * | MIDI_INSTRUMENT_COUNT | MIDI_INSTRUMENT_INFO * | MISCELLANEOUS + * @endcode + * The old events occupy the lower 16 bits (as bit flags), and all younger + * events enumerate the whole upper 16 bits range. The new, enumerated + * events are namely: + * @code + * UNSUBSCRIBE CHANNEL_MIDI + * @endcode * * @param pClient Pointer to client instance structure. * @param events Bit-wise OR'ed event flags to unsubscribe. @@ -701,6 +734,9 @@ ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MIDI_INSTRUMENT_INFO); if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS); + // Caution: for the upper 16 bits, we don't use bit flags anymore ... + if (ret == LSCP_OK && ((events & 0xffff0000) == LSCP_EVENT_CHANNEL_MIDI)) + ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_MIDI); // If necessary, close the alternate connection... if (pClient->events == LSCP_EVENT_NONE) @@ -2051,6 +2087,29 @@ return pFxSendInfo; } +/** + * Alter effect send's name: + * @code + * SET FX_SEND NAME + * @endcode + * + * @param pClient Pointer to client instance structure. + * @param iSamplerChannel Sampler channel number. + * @param iFxSend Effect send number. + * @param pszFxName Effect send's new name. + * + * @returns LSCP_OK on success, LSCP_FAILED otherwise. + */ +lscp_status_t lscp_set_fxsend_name ( lscp_client_t *pClient, int iSamplerChannel, int iFxSend, const char *pszFxName ) +{ + char szQuery[LSCP_BUFSIZ]; + + if (!pClient || iSamplerChannel < 0 || iFxSend < 0 || !pszFxName) + return LSCP_FAILED; + + snprintf(szQuery, LSCP_BUFSIZ, "SET FX_SEND NAME %d %d '%s'\r\n", iSamplerChannel, iFxSend, pszFxName); + return lscp_client_query(pClient, szQuery); +} /** * Alter effect send's audio routing: