Beispiel #1
0
gboolean idle_cb(gpointer data)
{
    lash_client_t *lash_client = (lash_client_t *)data;
    lash_event_t *event;
    lash_config_t *config;

    while ((event = lash_get_event(lash_client))) {
	if (lash_event_get_type(event) == LASH_Save_Data_Set) {
	    /* we can ignore this as timemachine has no state thats not on the
             * command line */
	} else if (lash_event_get_type(event) == LASH_Quit) {
	    cleanup();
	} else {
	    DEBUG(0, "unhandled LASH event: type %d, '%s''\n",
		   lash_event_get_type(event),
		   lash_event_get_string(event));
	}
    }

    while ((config = lash_get_config(lash_client))) {
	DEBUG(0, "got unexpected LASH config: %s\n",
	       lash_config_get_key(config));
    }

    usleep(10000);

    return TRUE;
}
Beispiel #2
0
static void *
fluid_lash_run (void * data)
{
  lash_event_t * event;
  lash_config_t * config;
  fluid_synth_t * synth;
  int done = 0;
  int err;
  int pending_restores = 0;

  synth = (fluid_synth_t *) data;

  while (!done)
    {
      while ( (event = lash_get_event (fluid_lash_client)) )
        {
          switch (lash_event_get_type (event))
            {
            case LASH_Save_Data_Set:
              fluid_lash_save (synth);
              lash_send_event (fluid_lash_client, event);
              break;
            case LASH_Restore_Data_Set:
              lash_event_destroy (event);
              break;
            case LASH_Quit:
	      err = kill (getpid(), SIGQUIT);
	      if (err)
		fprintf (stderr, "%s: error sending signal: %s",
			 __FUNCTION__, strerror (errno));
	      lash_event_destroy (event);
	      done = 1;
	      break;
	    case LASH_Server_Lost:
	      lash_event_destroy (event);
	      done = 1;
	      break;
            default:
              fprintf (stderr, "Recieved unknown LASH event of type %d\n", lash_event_get_type (event));
	      lash_event_destroy (event);
	      break;
            }
        }

      while ( (config = lash_get_config (fluid_lash_client)) )
        {
	  if (strcmp (lash_config_get_key (config), "soundfont count") == 0)
	      pending_restores = lash_config_get_value_int (config);
	  else
	    {
              fluid_lash_load (synth, lash_config_get_value_string (config));
	      pending_restores--;
	    }
          lash_config_destroy (config);

	  if (!pending_restores)
	    {
	      event = lash_event_new_with_type (LASH_Restore_Data_Set);
	      lash_send_event (fluid_lash_client, event);
	    }
        }

      usleep (10000);
    }

  return NULL;
}