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.

129 lines
3.4KB

  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. /* Handler based wrapper for LASH */
  19. #include "LASH_Client.H"
  20. #include "util/debug.h"
  21. LASH_Client::LASH_Client ( )
  22. {
  23. _void = 0;
  24. }
  25. LASH_Client::~LASH_Client ( )
  26. {
  27. /* TODO: anything? */
  28. }
  29. #ifdef HAVE_LASH
  30. #include <lash/lash.h>
  31. #define _client (static_cast<lash_client_t*>(_void))
  32. bool
  33. LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv )
  34. {
  35. if ( ! ( _void = lash_init( lash_extract_args( argc, argv ), jack_name,
  36. LASH_Config_File, LASH_PROTOCOL( 2, 0 ) ) ) )
  37. return false;
  38. /* register name */
  39. lash_jack_client_name( _client, jack_name );
  40. lash_event_t *e = lash_event_new_with_type( LASH_Client_Name );
  41. lash_event_set_string( e, long_name );
  42. lash_send_event( _client, e );
  43. return true;
  44. }
  45. bool
  46. LASH_Client::enabled ( void )
  47. {
  48. return lash_enabled( _client );
  49. }
  50. /** process any queued events */
  51. void
  52. LASH_Client::poll ( void )
  53. {
  54. if ( ! _client )
  55. return;
  56. lash_event_t *e;
  57. while ( ( e = lash_get_event( _client ) ) )
  58. {
  59. const char *name = lash_event_get_string( e );
  60. switch ( lash_event_get_type( e ) )
  61. {
  62. case LASH_Save_File:
  63. handle_save_file( name );
  64. lash_send_event( _client, lash_event_new_with_type( LASH_Save_File ) );
  65. break;
  66. case LASH_Restore_File:
  67. if ( ! handle_restore_file( name ) )
  68. /* FIXME: should we tell lash that we couldn't load the song? */;
  69. lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) );
  70. break;
  71. case LASH_Quit:
  72. handle_quit();
  73. break;
  74. default:
  75. WARNING( "unhandled LASH event" );
  76. break;
  77. }
  78. lash_event_destroy( e );
  79. }
  80. }
  81. #else
  82. bool
  83. LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv )
  84. {
  85. return true;
  86. }
  87. bool
  88. LASH_Client::enabled ( void )
  89. {
  90. return false;
  91. }
  92. void
  93. LASH_Client::poll ( void )
  94. {
  95. }
  96. #endif