| client.h | | client.h | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| You should have received a copy of the GNU Lesser General Public | | You should have received a copy of the GNU Lesser General Public | |
| License along with this library; if not, write to the Free Software | | License along with this library; if not, write to the Free Software | |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| | | | |
| ***************************************************************************
**/ | | ***************************************************************************
**/ | |
| | | | |
| #ifndef __LSCP_CLIENT_H | | #ifndef __LSCP_CLIENT_H | |
| #define __LSCP_CLIENT_H | | #define __LSCP_CLIENT_H | |
| | | | |
| #include "lscp/socket.h" | | #include "lscp/socket.h" | |
|
| | | #include "lscp/event.h" | |
| | | | |
| #if defined(__cplusplus) | | #if defined(__cplusplus) | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Client data structures. | | // Client data structures. | |
| | | | |
|
| /** Invalid channel index. */ | | | |
| #define LSCP_CHANNEL_INVALID (-1) | | | |
| | | | |
| /** Audio output types. */ | | | |
| typedef enum _lscp_audio_t | | | |
| { | | | |
| LSCP_AUDIO_NONE = 0, | | | |
| LSCP_AUDIO_ALSA, | | | |
| LSCP_AUDIO_JACK | | | |
| | | | |
| } lscp_audio_t; | | | |
| | | | |
| /** MIDI input types. */ | | | |
| typedef enum _lscp_midi_t | | | |
| { | | | |
| LSCP_MIDI_NONE = 0, | | | |
| LSCP_MIDI_ALSA | | | |
| | | | |
| } lscp_midi_t; | | | |
| | | | |
| /** Buffer fill stream usage types. */ | | | |
| typedef enum _lscp_usage_t | | | |
| { | | | |
| LSCP_USAGE_BYTES = 0, | | | |
| LSCP_USAGE_PERCENTAGE | | | |
| | | | |
| } lscp_usage_t; | | | |
| | | | |
| /** Engine info cache struct. */ | | /** Engine info cache struct. */ | |
| typedef struct _lscp_engine_info_t | | typedef struct _lscp_engine_info_t | |
| { | | { | |
| char * description; | | char * description; | |
| char * version; | | char * version; | |
| | | | |
| } lscp_engine_info_t; | | } lscp_engine_info_t; | |
| | | | |
| /** Channel info cache struct. */ | | /** Channel info cache struct. */ | |
| typedef struct _lscp_channel_info_t | | typedef struct _lscp_channel_info_t | |
| { | | { | |
| char * engine_name; | | char * engine_name; | |
|
| lscp_audio_t audio_type; | | int audio_device; | |
| int audio_channel; | | int audio_channels; | |
| char * instrument; | | char ** audio_routing; | |
| lscp_midi_t midi_type; | | char * instrument_file; | |
| char * midi_port; | | int instrument_nr; | |
| | | int instrument_status; | |
| | | int midi_device; | |
| | | int midi_port; | |
| int midi_channel; | | int midi_channel; | |
| float volume; | | float volume; | |
| | | | |
| } lscp_channel_info_t; | | } lscp_channel_info_t; | |
| | | | |
| /** Buffer fill cache struct. */ | | /** Buffer fill cache struct. */ | |
| typedef struct _lscp_buffer_fill_t | | typedef struct _lscp_buffer_fill_t | |
| { | | { | |
| unsigned int stream_id; | | unsigned int stream_id; | |
| unsigned long stream_usage; | | unsigned long stream_usage; | |
| | | | |
| } lscp_buffer_fill_t; | | } lscp_buffer_fill_t; | |
| | | | |
|
| | | /** Buffer fill stream usage types. */ | |
| | | typedef enum _lscp_usage_t | |
| | | { | |
| | | LSCP_USAGE_BYTES = 0, | |
| | | LSCP_USAGE_PERCENTAGE | |
| | | | |
| | | } lscp_usage_t; | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Client socket main structure. | | // Client socket main structure. | |
| | | | |
|
| struct _lscp_client_t; | | /** Client opaque descriptor struct. */ | |
| | | typedef struct _lscp_client_t lscp_client_t; | |
| | | | |
|
| /** Client callback procedure prototype. */ | | /** Client event callback procedure prototype. */ | |
| typedef lscp_status_t (*lscp_client_proc_t) | | typedef lscp_status_t (*lscp_client_proc_t) | |
| ( | | ( | |
| struct _lscp_client_t *pClient, | | struct _lscp_client_t *pClient, | |
|
| const char *pchBuffer, | | lscp_event_t event, | |
| int cchBuffer, | | const char *pchData, | |
| | | int cchData, | |
| void *pvData | | void *pvData | |
| ); | | ); | |
| | | | |
|
| /** Client descriptor struct. */ | | | |
| typedef struct _lscp_client_t { | | | |
| | | | |
| // Client socket stuff. | | | |
| lscp_client_proc_t pfnCallback; | | | |
| void * pvData; | | | |
| lscp_socket_agent_t tcp; | | | |
| lscp_socket_agent_t udp; | | | |
| // Session identifier. | | | |
| char * sessid; | | | |
| // Info struct caches. | | | |
| char ** engines; | | | |
| int iMaxEngines; | | | |
| lscp_engine_info_t engine_info; | | | |
| lscp_channel_info_t channel_info; | | | |
| // Result and error status. | | | |
| char * pszResult; | | | |
| int iErrno; | | | |
| // Stream buffers status. | | | |
| lscp_buffer_fill_t *buffer_fill; | | | |
| int iStreamCount; | | | |
| | | | |
| } lscp_client_t; | | | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Client versioning teller fuunction. | | // Client versioning teller fuunction. | |
| | | | |
| const char * lscp_client_package (void); | | const char * lscp_client_package (void); | |
| const char * lscp_client_version (void); | | const char * lscp_client_version (void); | |
| const char * lscp_client_build (void); | | const char * lscp_client_build (void); | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Client socket functions. | | // Client socket functions. | |
| | | | |
|
| lscp_client_t * lscp_client_create (char *pszHost, int
iPort, lscp_client_proc_t pfnCallback, void *pvData); | | lscp_client_t * lscp_client_create (const char *pszHos
t, int iPort, lscp_client_proc_t pfnCallback, void *pvData); | |
| lscp_status_t lscp_client_join (lscp_client_t *pCl
ient); | | lscp_status_t lscp_client_join (lscp_client_t *pCl
ient); | |
| lscp_status_t lscp_client_destroy (lscp_client_t *pCl
ient); | | lscp_status_t lscp_client_destroy (lscp_client_t *pCl
ient); | |
| | | | |
|
| lscp_status_t lscp_client_call (lscp_client_t *pCl | | lscp_status_t lscp_client_set_timeout (lscp_client_t *pCl | |
| ient, const char *pchBuffer, int cchBuffer, char *pchResult, int *pcchResul | | ient, int iTimeout); | |
| t); | | int lscp_client_get_timeout (lscp_client_t *pCl | |
| | | ient); | |
| lscp_status_t lscp_client_subscribe (lscp_client_t *pCl | | | |
| ient); | | | |
| lscp_status_t lscp_client_unsubscribe (lscp_client_t *pCl | | | |
| ient); | | | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Client common protocol functions. | | // Client common protocol functions. | |
| | | | |
| lscp_status_t lscp_client_query (lscp_client_t *pCl
ient, const char *pszQuery); | | lscp_status_t lscp_client_query (lscp_client_t *pCl
ient, const char *pszQuery); | |
| const char * lscp_client_get_result (lscp_client_t *pCl
ient ); | | const char * lscp_client_get_result (lscp_client_t *pCl
ient ); | |
| int lscp_client_get_errno (lscp_client_t *pCl
ient ); | | int lscp_client_get_errno (lscp_client_t *pCl
ient ); | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
|
| | | // Client registration protocol functions. | |
| | | | |
| | | lscp_status_t lscp_client_subscribe (lscp_client_t *pCl | |
| | | ient, lscp_event_t events); | |
| | | lscp_status_t lscp_client_unsubscribe (lscp_client_t *pCl | |
| | | ient, lscp_event_t events); | |
| | | | |
| | | lscp_event_t lscp_client_events (lscp_client_t *pCl | |
| | | ient); | |
| | | | |
| | | //------------------------------------------------------------------------- | |
| // Client command protocol functions. | | // Client command protocol functions. | |
| | | | |
| lscp_status_t lscp_load_instrument (lscp_client_t *pCl
ient, const char *pszFileName, int iInstrIndex, int iSamplerChannel); | | lscp_status_t lscp_load_instrument (lscp_client_t *pCl
ient, const char *pszFileName, int iInstrIndex, int iSamplerChannel); | |
|
| | | lscp_status_t lscp_load_instrument_non_modal (lscp_client_t *pCl
ient, const char *pszFileName, int iInstrIndex, int iSamplerChannel); | |
| lscp_status_t lscp_load_engine (lscp_client_t *pCl
ient, const char *pszEngineName, int iSamplerChannel); | | lscp_status_t lscp_load_engine (lscp_client_t *pCl
ient, const char *pszEngineName, int iSamplerChannel); | |
| int lscp_get_channels (lscp_client_t *pCl
ient); | | int lscp_get_channels (lscp_client_t *pCl
ient); | |
|
| lscp_status_t lscp_add_channel (lscp_client_t *pCl | | int * lscp_list_channels (lscp_client_t *pCl | |
| ient); | | ient); | |
| | | int lscp_add_channel (lscp_client_t *pCl | |
| | | ient); | |
| lscp_status_t lscp_remove_channel (lscp_client_t *pCl
ient, int iSamplerChannel); | | lscp_status_t lscp_remove_channel (lscp_client_t *pCl
ient, int iSamplerChannel); | |
| const char ** lscp_get_available_engines (lscp_client_t *pCl
ient); | | const char ** lscp_get_available_engines (lscp_client_t *pCl
ient); | |
| | | | |
| lscp_engine_info_t * lscp_get_engine_info (lscp_client_t *pCl
ient, const char *pszEngineName); | | lscp_engine_info_t * lscp_get_engine_info (lscp_client_t *pCl
ient, const char *pszEngineName); | |
| lscp_channel_info_t * lscp_get_channel_info (lscp_client_t *pCl
ient, int iSamplerChannel); | | lscp_channel_info_t * lscp_get_channel_info (lscp_client_t *pCl
ient, int iSamplerChannel); | |
| | | | |
| int lscp_get_channel_voice_count (lscp_client_t *pCl
ient, int iSamplerChannel); | | int lscp_get_channel_voice_count (lscp_client_t *pCl
ient, int iSamplerChannel); | |
| int lscp_get_channel_stream_count (lscp_client_t *pCl
ient, int iSamplerChannel); | | int lscp_get_channel_stream_count (lscp_client_t *pCl
ient, int iSamplerChannel); | |
|
| | | int lscp_get_channel_stream_usage (lscp_client_t *pCl
ient, int iSamplerChannel); | |
| | | | |
| lscp_buffer_fill_t * lscp_get_channel_buffer_fill (lscp_client_t *pCl
ient, lscp_usage_t iUsageType, int iSamplerChannel); | | lscp_buffer_fill_t * lscp_get_channel_buffer_fill (lscp_client_t *pCl
ient, lscp_usage_t iUsageType, int iSamplerChannel); | |
| | | | |
|
| lscp_status_t lscp_set_channel_audio_type (lscp_client_t *pCl | | lscp_status_t lscp_set_channel_audio_type (lscp_client_t *pCl | |
| ient, int iSamplerChannel, lscp_audio_t iAudioType); | | ient, int iSamplerChannel, const char *pszAudioType); | |
| lscp_status_t lscp_set_channel_audio_channel (lscp_client_t *pCl | | lscp_status_t lscp_set_channel_audio_device (lscp_client_t *pCl | |
| ient, int iSamplerChannel, int iAudioChannel); | | ient, int iSamplerChannel, int iAudioDevice); | |
| | | lscp_status_t lscp_set_channel_audio_channel (lscp_client_t *pCl | |
| | | ient, int iSamplerChannel, int iAudioOut, int iAudioIn); | |
| | | | |
|
| lscp_status_t lscp_set_channel_midi_type (lscp_client_t *pCl | | lscp_status_t lscp_set_channel_midi_type (lscp_client_t *pCl | |
| ient, int iSamplerChannel, lscp_midi_t iMidiType); | | ient, int iSamplerChannel, const char *pszMidiType); | |
| lscp_status_t lscp_set_channel_midi_port (lscp_client_t *pCl | | lscp_status_t lscp_set_channel_midi_device (lscp_client_t *pCl | |
| ient, int iSamplerChannel, const char *pszMidiPort); | | ient, int iSamplerChannel, int iMidiDevice); | |
| | | lscp_status_t lscp_set_channel_midi_port (lscp_client_t *pCl | |
| | | ient, int iSamplerChannel, int iMidiPort); | |
| lscp_status_t lscp_set_channel_midi_channel (lscp_client_t *pCl
ient, int iSamplerChannel, int iMidiChannel); | | lscp_status_t lscp_set_channel_midi_channel (lscp_client_t *pCl
ient, int iSamplerChannel, int iMidiChannel); | |
| lscp_status_t lscp_set_channel_volume (lscp_client_t *pCl
ient, int iSamplerChannel, float fVolume); | | lscp_status_t lscp_set_channel_volume (lscp_client_t *pCl
ient, int iSamplerChannel, float fVolume); | |
| | | | |
| lscp_status_t lscp_reset_channel (lscp_client_t *pCl
ient, int iSamplerChannel); | | lscp_status_t lscp_reset_channel (lscp_client_t *pCl
ient, int iSamplerChannel); | |
| | | | |
| #if defined(__cplusplus) | | #if defined(__cplusplus) | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #endif // __LSCP_CLIENT_H | | #endif // __LSCP_CLIENT_H | |
| | | | |
End of changes. 16 change blocks. |
| 80 lines changed or deleted | | 57 lines changed or added | |
|
| thread.h | | thread.h | |
| | | | |
| skipping to change at line 56 | | skipping to change at line 56 | |
| #endif | | #endif | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Status. | | // Status. | |
| | | | |
| typedef enum _lscp_status_t | | typedef enum _lscp_status_t | |
| { | | { | |
| LSCP_OK = 0, | | LSCP_OK = 0, | |
| LSCP_FAILED = -1, | | LSCP_FAILED = -1, | |
| LSCP_ERROR = -2, | | LSCP_ERROR = -2, | |
|
| LSCP_WARNING = -3 | | LSCP_WARNING = -3, | |
| | | LSCP_TIMEOUT = -4, | |
| | | LSCP_QUIT = -5 | |
| | | | |
| } lscp_status_t; | | } lscp_status_t; | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
| // Mutexes. | | // Mutexes. | |
| | | | |
| #if defined(WIN32) | | #if defined(WIN32) | |
| typedef HANDLE lscp_mutex_t; | | typedef HANDLE lscp_mutex_t; | |
| #define lscp_mutex_init(m) { (m) = CreateMutex(NULL, 0, NULL); } | | #define lscp_mutex_init(m) { (m) = CreateMutex(NULL, 0, NULL); } | |
| #define lscp_mutex_destroy(m) if (m) { CloseHandle(m); } | | #define lscp_mutex_destroy(m) if (m) { CloseHandle(m); } | |
| | | | |
| skipping to change at line 78 | | skipping to change at line 80 | |
| #define lscp_mutex_unlock(m) ReleaseMutex(m) | | #define lscp_mutex_unlock(m) ReleaseMutex(m) | |
| #else | | #else | |
| typedef pthread_mutex_t lscp_mutex_t; | | typedef pthread_mutex_t lscp_mutex_t; | |
| #define lscp_mutex_init(m) pthread_mutex_init(&(m), NULL) | | #define lscp_mutex_init(m) pthread_mutex_init(&(m), NULL) | |
| #define lscp_mutex_destroy(m) pthread_mutex_destroy(&(m)) | | #define lscp_mutex_destroy(m) pthread_mutex_destroy(&(m)) | |
| #define lscp_mutex_lock(m) pthread_mutex_lock(&(m)) | | #define lscp_mutex_lock(m) pthread_mutex_lock(&(m)) | |
| #define lscp_mutex_unlock(m) pthread_mutex_unlock(&(m)) | | #define lscp_mutex_unlock(m) pthread_mutex_unlock(&(m)) | |
| #endif | | #endif | |
| | | | |
| //------------------------------------------------------------------------- | | //------------------------------------------------------------------------- | |
|
| // Threads. | | // Simple condition variables (FIXME: probably incorrect on WIN32). | |
| | | | |
| typedef void (*lscp_thread_proc_t)(void *pvData); | | | |
| | | | |
| typedef struct _lscp_thread_t { | | | |
| | | | |
| #if defined(WIN32) | | #if defined(WIN32) | |
|
| HANDLE hThread; | | typedef HANDLE lscp_cond_t; | |
| DWORD dwThreadID; | | #define lscp_cond_init(c) { (c) = CreateEvent(NULL, FALSE, FALSE, NUL | |
| | | L); } | |
| | | #define lscp_cond_destroy(c) if (c) { CloseHandle(c); } | |
| | | #define lscp_cond_wait(c, m) { lscp_mutex_unlock(m); WaitForSingleObject | |
| | | ((c), INFINITE); lscp_mutex_lock(m); } | |
| | | #define lscp_cond_signal(c) SetEvent(c) | |
| #else | | #else | |
|
| pthread_t pthread; | | typedef pthread_cond_t lscp_cond_t; | |
| | | #define lscp_cond_init(c) pthread_cond_init(&(c), NULL) | |
| | | #define lscp_cond_destroy(c) pthread_cond_destroy(&(c)) | |
| | | #define lscp_cond_wait(c, m) pthread_cond_wait(&(c), &(m)) | |
| | | #define lscp_cond_signal(c) pthread_cond_signal(&(c)) | |
| #endif | | #endif | |
|
| lscp_thread_proc_t pfnProc; | | | |
| void *pvData; | | | |
| int iDetach; | | | |
| | | | |
|
| } lscp_thread_t; | | //------------------------------------------------------------------------- | |
| | | // Threads. | |
| | | | |
| | | struct _lscp_thread_t; | |
| | | | |
| | | typedef void (*lscp_thread_proc_t)(void *pvData); | |
| | | | |
| | | typedef struct _lscp_thread_t lscp_thread_t; | |
| | | | |
| lscp_thread_t *lscp_thread_create (lscp_thread_proc_t pfnProc, void *pvDat
a, int iDetach); | | lscp_thread_t *lscp_thread_create (lscp_thread_proc_t pfnProc, void *pvDat
a, int iDetach); | |
| lscp_status_t lscp_thread_join (lscp_thread_t *pThread); | | lscp_status_t lscp_thread_join (lscp_thread_t *pThread); | |
| lscp_status_t lscp_thread_cancel (lscp_thread_t *pThread); | | lscp_status_t lscp_thread_cancel (lscp_thread_t *pThread); | |
| lscp_status_t lscp_thread_destroy (lscp_thread_t *pThread); | | lscp_status_t lscp_thread_destroy (lscp_thread_t *pThread); | |
| | | | |
| #if defined(WIN32) | | #if defined(WIN32) | |
| #define lscp_thread_exit() pthread_exit(NULL) | | #define lscp_thread_exit() pthread_exit(NULL) | |
| #else | | #else | |
| #define lscp_thread_exit() ExitThread(0) | | #define lscp_thread_exit() ExitThread(0) | |
| | | | |
End of changes. 6 change blocks. |
| 13 lines changed or deleted | | 24 lines changed or added | |
|