Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.3KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "LASH_Client.H"
  19. #include <lash/lash.h>
  20. #define _client (static_cast<lash_client_t*>(_void))
  21. #include "debug.h"
  22. LASH_Client::LASH_Client ( )
  23. {
  24. _void = NULL;
  25. }
  26. LASH_Client::~LASH_Client ( )
  27. {
  28. /* TODO: anything? */
  29. }
  30. bool
  31. LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv )
  32. {
  33. MESSAGE( "Initializing LASH" );
  34. if ( ! ( _void = lash_init( lash_extract_args( argc, argv ), jack_name,
  35. LASH_Config_File, LASH_PROTOCOL( 2, 0 ) ) ) )
  36. return false;
  37. /* register name */
  38. lash_jack_client_name( _client, jack_name );
  39. lash_event_t *e = lash_event_new_with_type( LASH_Client_Name );
  40. lash_event_set_string( e, long_name );
  41. lash_send_event( _client, e );
  42. return true;
  43. }
  44. /** process any queued events */
  45. void
  46. LASH_Client::poll ( void )
  47. {
  48. lash_event_t *e;
  49. while ( ( e = lash_get_event( _client ) ) )
  50. {
  51. const char *name = lash_event_get_string( e );
  52. switch ( lash_event_get_type( e ) )
  53. {
  54. case LASH_Save_File:
  55. {
  56. MESSAGE( "LASH wants us to save \"%s\"", name );
  57. handle_save_file( name );
  58. lash_send_event( _client, lash_event_new_with_type( LASH_Save_File ) );
  59. break;
  60. }
  61. case LASH_Restore_File:
  62. {
  63. MESSAGE( "LASH wants us to load \"%s\"", name );
  64. if ( ! handle_load_file( name ) )
  65. /* FIXME: should we tell lash that we couldn't load the song? */;
  66. lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) );
  67. break;
  68. }
  69. case LASH_Quit:
  70. MESSAGE( "LASH wants us to quit" );
  71. handle_quit();
  72. break;
  73. default:
  74. WARNING( "unhandled LASH event" );
  75. }
  76. lash_event_destroy( e );
  77. }
  78. }