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.

130 lines
3.5KB

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