/[svn]/liblscp/trunk/src/client.c
ViewVC logotype

Diff of /liblscp/trunk/src/client.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 177 by capela, Tue Jul 6 14:06:17 2004 UTC revision 378 by capela, Sun Feb 13 17:20:46 2005 UTC
# Line 2  Line 2 
2  //  //
3  /****************************************************************************  /****************************************************************************
4     liblscp - LinuxSampler Control Protocol API     liblscp - LinuxSampler Control Protocol API
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved.
6    
7     This library is free software; you can redistribute it and/or     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public     modify it under the terms of the GNU Lesser General Public
# Line 111  static void _lscp_client_evt_proc ( void Line 111  static void _lscp_client_evt_proc ( void
111              }              }
112          }   // Check if select has in error.          }   // Check if select has in error.
113          else if (iSelect < 0) {          else if (iSelect < 0) {
114              lscp_socket_perror("_lscp_client_call: select");              lscp_socket_perror("_lscp_client_evt_proc: select");
115              pClient->evt.iState = 0;              pClient->evt.iState = 0;
116          }          }
117                    
# Line 398  lscp_status_t lscp_client_destroy ( lscp Line 398  lscp_status_t lscp_client_destroy ( lscp
398      lscp_mutex_lock(pClient->mutex);      lscp_mutex_lock(pClient->mutex);
399            
400      // Free up all cached members.      // Free up all cached members.
401      lscp_channel_info_reset(&(pClient->channel_info));      lscp_channel_info_free(&(pClient->channel_info));
402      lscp_engine_info_reset(&(pClient->engine_info));      lscp_engine_info_free(&(pClient->engine_info));
403      lscp_param_info_reset(&(pClient->midi_port_param_info));      lscp_param_info_free(&(pClient->midi_port_param_info));
404      lscp_param_info_reset(&(pClient->audio_channel_param_info));      lscp_param_info_free(&(pClient->audio_channel_param_info));
405      lscp_device_port_info_reset(&(pClient->midi_port_info));      lscp_device_port_info_free(&(pClient->midi_port_info));
406      lscp_device_port_info_reset(&(pClient->audio_channel_info));      lscp_device_port_info_free(&(pClient->audio_channel_info));
407      lscp_param_info_reset(&(pClient->midi_param_info));      lscp_param_info_free(&(pClient->midi_param_info));
408      lscp_param_info_reset(&(pClient->audio_param_info));      lscp_param_info_free(&(pClient->audio_param_info));
409      lscp_device_info_reset(&(pClient->midi_device_info));      lscp_device_info_free(&(pClient->midi_device_info));
410      lscp_device_info_reset(&(pClient->audio_device_info));      lscp_device_info_free(&(pClient->audio_device_info));
411      lscp_driver_info_reset(&(pClient->midi_driver_info));      lscp_driver_info_free(&(pClient->midi_driver_info));
412      lscp_driver_info_reset(&(pClient->audio_driver_info));      lscp_driver_info_free(&(pClient->audio_driver_info));
413      // Free available engine table.      // Free available engine table.
414      lscp_szsplit_destroy(pClient->audio_drivers);      lscp_szsplit_destroy(pClient->audio_drivers);
415      lscp_szsplit_destroy(pClient->midi_drivers);      lscp_szsplit_destroy(pClient->midi_drivers);
# Line 641  lscp_status_t lscp_client_unsubscribe ( Line 641  lscp_status_t lscp_client_unsubscribe (
641  }  }
642    
643    
644    /**
645     *  Getting current subscribed events.
646     *
647     *  @param pClient  Pointer to client instance structure.
648     *
649     *  @returns The current subscrived bit-wise OR'ed event flags.
650     */
651    lscp_event_t lscp_client_get_events ( lscp_client_t *pClient )
652    {
653        if (pClient == NULL)
654            return LSCP_EVENT_NONE;
655    
656        return pClient->events;
657    }
658    
659    
660  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
661  // Client command protocol functions.  // Client command protocol functions.
662    
# Line 887  lscp_engine_info_t *lscp_get_engine_info Line 903  lscp_engine_info_t *lscp_get_engine_info
903              if (strcasecmp(pszToken, "DESCRIPTION") == 0) {              if (strcasecmp(pszToken, "DESCRIPTION") == 0) {
904                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
905                  if (pszToken)                  if (pszToken)
906                      pEngineInfo->description = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pEngineInfo->description), &pszToken);
907              }              }
908              else if (strcasecmp(pszToken, "VERSION") == 0) {              else if (strcasecmp(pszToken, "VERSION") == 0) {
909                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
910                  if (pszToken)                  if (pszToken)
911                      pEngineInfo->version = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pEngineInfo->version), &pszToken);
912              }              }
913              pszToken = lscp_strtok(NULL, pszSeps, &(pch));              pszToken = lscp_strtok(NULL, pszSeps, &(pch));
914          }          }
# Line 943  lscp_channel_info_t *lscp_get_channel_in Line 959  lscp_channel_info_t *lscp_get_channel_in
959              if (strcasecmp(pszToken, "ENGINE_NAME") == 0) {              if (strcasecmp(pszToken, "ENGINE_NAME") == 0) {
960                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
961                  if (pszToken)                  if (pszToken)
962                      pChannelInfo->engine_name = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pChannelInfo->engine_name), &pszToken);
963              }              }
964              else if (strcasecmp(pszToken, "AUDIO_OUTPUT_DEVICE") == 0) {              else if (strcasecmp(pszToken, "AUDIO_OUTPUT_DEVICE") == 0) {
965                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
# Line 957  lscp_channel_info_t *lscp_get_channel_in Line 973  lscp_channel_info_t *lscp_get_channel_in
973              }              }
974              else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) {              else if (strcasecmp(pszToken, "AUDIO_OUTPUT_ROUTING") == 0) {
975                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
976                  if (pszToken)                  if (pszToken) {
977                        if (pChannelInfo->audio_routing)
978                            lscp_szsplit_destroy(pChannelInfo->audio_routing);
979                      pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ",");                      pChannelInfo->audio_routing = lscp_szsplit_create(pszToken, ",");
980                    }
981              }              }
982              else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) {              else if (strcasecmp(pszToken, "INSTRUMENT_FILE") == 0) {
983                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
984                  if (pszToken)                  if (pszToken)
985                      pChannelInfo->instrument_file = lscp_unquote(&pszToken, 1);                      lscp_unquote_dup(&(pChannelInfo->instrument_file), &pszToken);
986              }              }
987              else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) {              else if (strcasecmp(pszToken, "INSTRUMENT_NR") == 0) {
988                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
989                  if (pszToken)                  if (pszToken)
990                      pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken));                      pChannelInfo->instrument_nr = atoi(lscp_ltrim(pszToken));
991              }              }
992                else if (strcasecmp(pszToken, "INSTRUMENT_NAME") == 0) {
993                    pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
994                    if (pszToken)
995                        lscp_unquote_dup(&(pChannelInfo->instrument_name), &pszToken);
996                }
997              else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) {              else if (strcasecmp(pszToken, "INSTRUMENT_STATUS") == 0) {
998                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
999                  if (pszToken)                  if (pszToken)
# Line 987  lscp_channel_info_t *lscp_get_channel_in Line 1011  lscp_channel_info_t *lscp_get_channel_in
1011              }              }
1012              else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) {              else if (strcasecmp(pszToken, "MIDI_INPUT_CHANNEL") == 0) {
1013                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
1014                  if (pszToken)                  if (pszToken) {
1015                      pChannelInfo->midi_channel = atoi(lscp_ltrim(pszToken));                      pszToken = lscp_ltrim(pszToken);
1016                        if (strcasecmp(pszToken, "ALL") == 0)
1017                            pChannelInfo->midi_channel = LSCP_MIDI_CHANNEL_ALL;
1018                        else
1019                            pChannelInfo->midi_channel = atoi(pszToken);
1020                    }
1021              }              }
1022              else if (strcasecmp(pszToken, "VOLUME") == 0) {              else if (strcasecmp(pszToken, "VOLUME") == 0) {
1023                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));                  pszToken = lscp_strtok(NULL, pszCrlf, &(pch));
# Line 1258  lscp_status_t lscp_set_channel_audio_cha Line 1287  lscp_status_t lscp_set_channel_audio_cha
1287      if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0)      if (iSamplerChannel < 0 || iAudioOut < 0 || iAudioIn < 0)
1288          return LSCP_FAILED;          return LSCP_FAILED;
1289    
1290      sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_CHANNELS %d %d %d\r\n", iSamplerChannel, iAudioOut, iAudioIn);      sprintf(szQuery, "SET CHANNEL AUDIO_OUTPUT_CHANNEL %d %d %d\r\n", iSamplerChannel, iAudioOut, iAudioIn);
1291      return lscp_client_query(pClient, szQuery);      return lscp_client_query(pClient, szQuery);
1292  }  }
1293    
# Line 1333  lscp_status_t lscp_set_channel_midi_port Line 1362  lscp_status_t lscp_set_channel_midi_port
1362   *   *
1363   *  @param pClient          Pointer to client instance structure.   *  @param pClient          Pointer to client instance structure.
1364   *  @param iSamplerChannel  Sampler channel number.   *  @param iSamplerChannel  Sampler channel number.
1365   *  @param iMidiChannel     MIDI channel number to listen (1-16) or   *  @param iMidiChannel     MIDI channel address number to listen (0-15) or
1366   *                          zero (0) to listen on all channels.   *                          LSCP_MIDI_CHANNEL_ALL (16) to listen on all channels.
1367   *   *
1368   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.   *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1369   */   */
# Line 1345  lscp_status_t lscp_set_channel_midi_chan Line 1374  lscp_status_t lscp_set_channel_midi_chan
1374      if (iSamplerChannel < 0 || iMidiChannel < 0 || iMidiChannel > 16)      if (iSamplerChannel < 0 || iMidiChannel < 0 || iMidiChannel > 16)
1375          return LSCP_FAILED;          return LSCP_FAILED;
1376    
1377      if (iMidiChannel > 0)      if (iMidiChannel == LSCP_MIDI_CHANNEL_ALL)
         sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel);  
     else  
1378          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel);          sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d ALL\r\n", iSamplerChannel);
1379        else
1380            sprintf(szQuery, "SET CHANNEL MIDI_INPUT_CHANNEL %d %d\r\n", iSamplerChannel, iMidiChannel);
1381      return lscp_client_query(pClient, szQuery);      return lscp_client_query(pClient, szQuery);
1382  }  }
1383    
# Line 1398  lscp_status_t lscp_reset_channel ( lscp_ Line 1427  lscp_status_t lscp_reset_channel ( lscp_
1427  }  }
1428    
1429    
1430    /**
1431     *  Resetting the sampler:
1432     *  RESET
1433     *
1434     *  @param pClient  Pointer to client instance structure.
1435     *
1436     *  @returns LSCP_OK on success, LSCP_FAILED otherwise.
1437     */
1438    lscp_status_t lscp_reset_sampler ( lscp_client_t *pClient )
1439    {
1440        return lscp_client_query(pClient, "RESET\r\n");
1441    }
1442    
1443    
1444  // end of client.c  // end of client.c

Legend:
Removed from v.177  
changed lines
  Added in v.378

  ViewVC Help
Powered by ViewVC