581 |
// Client registration protocol functions. |
// Client registration protocol functions. |
582 |
|
|
583 |
/** |
/** |
584 |
* Register frontend for receiving event messages. |
* Register frontend for receiving event messages by the sampler backend. |
585 |
* @e Caution: since liblscp v0.5.5.4 you have to call lscp_client_subscribe() |
* @e Caution: since liblscp v0.5.5.4 you have to call lscp_client_subscribe() |
586 |
* for @e each event you want to subscribe. That is the old bitflag approach |
* for @e each event you want to subscribe. That is the old bitflag approach |
587 |
* was abondoned at this point. You can however still register all older |
* was abondoned at this point. You can however still register all older |
604 |
* @endcode |
* @endcode |
605 |
* |
* |
606 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
607 |
* @param events Bit-wise OR'ed event flags to subscribe. |
* @param events LSCP event to subscribe. |
608 |
* |
* |
609 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
610 |
*/ |
*/ |
611 |
lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient, lscp_event_t events ) |
lscp_status_t lscp_client_subscribe ( lscp_client_t *pClient, lscp_event_t events ) |
612 |
{ |
{ |
613 |
lscp_status_t ret = LSCP_OK; |
lscp_status_t ret = LSCP_OK; |
614 |
|
lscp_event_t currentEvent; |
615 |
|
|
616 |
if (pClient == NULL) |
if (pClient == NULL) |
617 |
return LSCP_FAILED; |
return LSCP_FAILED; |
655 |
if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) |
656 |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS); |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_MISCELLANEOUS); |
657 |
// Caution: for the upper 16 bits, we don't use bit flags anymore ... |
// Caution: for the upper 16 bits, we don't use bit flags anymore ... |
658 |
if (ret == LSCP_OK && ((events & 0xffff0000) == LSCP_EVENT_CHANNEL_MIDI)) |
currentEvent = events & 0xffff0000; |
659 |
ret = _lscp_client_evt_request(pClient, 1, LSCP_EVENT_CHANNEL_MIDI); |
if (ret == LSCP_OK && currentEvent) { |
660 |
|
switch (currentEvent) { |
661 |
|
case LSCP_EVENT_CHANNEL_MIDI: |
662 |
|
case LSCP_EVENT_DEVICE_MIDI: |
663 |
|
ret = _lscp_client_evt_request(pClient, 1, currentEvent); |
664 |
|
break; |
665 |
|
default: // unknown "upper" event type |
666 |
|
ret = LSCP_FAILED; |
667 |
|
break; |
668 |
|
} |
669 |
|
} |
670 |
|
|
671 |
// Unlock this section down. |
// Unlock this section down. |
672 |
lscp_mutex_unlock(pClient->mutex); |
lscp_mutex_unlock(pClient->mutex); |
676 |
|
|
677 |
|
|
678 |
/** |
/** |
679 |
* Deregister frontend from receiving UDP event messages anymore: |
* Deregister frontend from receiving UDP event messages anymore. |
680 |
* @e Caution: since liblscp v0.5.5.4 you have to call |
* @e Caution: since liblscp v0.5.5.4 you have to call |
681 |
* lscp_client_unsubscribe() for @e each event you want to unsubscribe. |
* lscp_client_unsubscribe() for @e each event you want to unsubscribe. |
682 |
* That is the old bitflag approach was abondoned at this point. You can |
* That is the old bitflag approach was abondoned at this point. You can |
700 |
* @endcode |
* @endcode |
701 |
* |
* |
702 |
* @param pClient Pointer to client instance structure. |
* @param pClient Pointer to client instance structure. |
703 |
* @param events Bit-wise OR'ed event flags to unsubscribe. |
* @param events LSCP event to unsubscribe. |
704 |
* |
* |
705 |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
* @returns LSCP_OK on success, LSCP_FAILED otherwise. |
706 |
*/ |
*/ |
707 |
lscp_status_t lscp_client_unsubscribe ( lscp_client_t *pClient, lscp_event_t events ) |
lscp_status_t lscp_client_unsubscribe ( lscp_client_t *pClient, lscp_event_t events ) |
708 |
{ |
{ |
709 |
lscp_status_t ret = LSCP_OK; |
lscp_status_t ret = LSCP_OK; |
710 |
|
lscp_event_t currentEvent; |
711 |
|
|
712 |
if (pClient == NULL) |
if (pClient == NULL) |
713 |
return LSCP_FAILED; |
return LSCP_FAILED; |
747 |
if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) |
if (ret == LSCP_OK && (events & LSCP_EVENT_MISCELLANEOUS)) |
748 |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS); |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_MISCELLANEOUS); |
749 |
// Caution: for the upper 16 bits, we don't use bit flags anymore ... |
// Caution: for the upper 16 bits, we don't use bit flags anymore ... |
750 |
if (ret == LSCP_OK && ((events & 0xffff0000) == LSCP_EVENT_CHANNEL_MIDI)) |
currentEvent = events & 0xffff0000; |
751 |
ret = _lscp_client_evt_request(pClient, 0, LSCP_EVENT_CHANNEL_MIDI); |
if (ret == LSCP_OK && currentEvent) { |
752 |
|
switch (currentEvent) { |
753 |
|
case LSCP_EVENT_CHANNEL_MIDI: |
754 |
|
case LSCP_EVENT_DEVICE_MIDI: |
755 |
|
ret = _lscp_client_evt_request(pClient, 0, currentEvent); |
756 |
|
break; |
757 |
|
default: // unknown "upper" event type |
758 |
|
ret = LSCP_FAILED; |
759 |
|
break; |
760 |
|
} |
761 |
|
} |
762 |
|
|
763 |
// If necessary, close the alternate connection... |
// If necessary, close the alternate connection... |
764 |
if (pClient->events == LSCP_EVENT_NONE) |
if (pClient->events == LSCP_EVENT_NONE) |