Beispiel #1
0
static void
test_bt_machine_state_bypass_no_sideeffects (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "gen", "audiotestsrc", 0L,
          NULL));
  BtMachine *proc =
      BT_MACHINE (bt_processor_machine_new (song, "vol", "volume", 0L, NULL));
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "sink", NULL));
  bt_wire_new (song, src, proc, NULL);
  bt_wire_new (song, proc, sink, NULL);

  GST_INFO ("-- act --");
  g_object_set (proc, "state", BT_MACHINE_STATE_BYPASS, NULL);

  GST_INFO ("-- assert --");
  ck_assert_gobject_guint_eq (src, "state", BT_MACHINE_STATE_NORMAL);
  ck_assert_gobject_guint_eq (proc, "state", BT_MACHINE_STATE_BYPASS);
  ck_assert_gobject_guint_eq (sink, "state", BT_MACHINE_STATE_NORMAL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Beispiel #2
0
/*
 * activate the input level meter in a connected machine
 */
static void
test_bt_machine_enable_input_level2 (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine1 =
      BT_MACHINE (bt_processor_machine_new (song, "vol1", "volume", 0, NULL));
  BtMachine *machine2 =
      BT_MACHINE (bt_processor_machine_new (song, "vol2", "volume", 0, NULL));
  bt_wire_new (song, machine1, machine2, NULL);

  GST_INFO ("-- act --");
  gboolean res = bt_machine_enable_input_pre_level (machine2);

  GST_INFO ("-- assert --");
  fail_unless (res == TRUE, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Beispiel #3
0
/*
 * check if we can disconnect a processor machine from a src and sink while
 * playing
 */
static void
test_bt_setup_dynamic_rem_proc (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSetup *setup =
      (BtSetup *) check_gobject_get_object_property (song, "setup");
  BtSequence *sequence =
      (BtSequence *) check_gobject_get_object_property (song, "sequence");
  BtMachine *sink = BT_MACHINE (bt_sink_machine_new (song, "master", NULL));
  BtMachine *gen1 =
      BT_MACHINE (bt_source_machine_new (song, "gen1", "audiotestsrc", 0L,
          NULL));
  BtMachine *proc =
      BT_MACHINE (bt_processor_machine_new (song, "proc", "volume", 0, NULL));
  bt_wire_new (song, gen1, sink, NULL);
  BtWire *wire2 = bt_wire_new (song, gen1, proc, NULL);
  BtWire *wire3 = bt_wire_new (song, proc, sink, NULL);
  GstElement *element1 =
      (GstElement *) check_gobject_get_object_property (gen1, "machine");

  g_object_set (sequence, "length", 64L, "loop", TRUE, NULL);
  bt_sequence_add_track (sequence, gen1, -1);
  g_object_set (element1, "wave", /* silence */ 4, NULL);
  bt_machine_set_param_defaults (gen1);
  mark_point ();

  /* play the song */
  if (bt_song_play (song)) {
    mark_point ();
    check_run_main_loop_until_playing_or_error (song);
    GST_DEBUG ("song plays");

    /* unlink machines */
    bt_setup_remove_wire (setup, wire2);
    GST_DEBUG ("wire 2 removed");

    bt_setup_remove_wire (setup, wire3);
    GST_DEBUG ("wire 3 removed");

    g_usleep (G_USEC_PER_SEC / 10);

    /* stop the song */
    bt_song_stop (song);
  } else {
    fail ("playing song failed");
  }

  GST_INFO ("-- cleanup --");
  g_object_unref (setup);
  g_object_unref (sequence);
  BT_TEST_END;
}
Beispiel #4
0
/*
 * activate the output gain control in an unconnected machine
 */
static void
test_bt_machine_enable_output_gain1 (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *machine =
      BT_MACHINE (bt_processor_machine_new (song, "vol", "volume", 0, NULL));

  GST_INFO ("-- act --");
  gboolean res = bt_machine_enable_output_gain (machine);

  GST_INFO ("-- assert --");
  fail_unless (res == TRUE, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Beispiel #5
0
static BtPersistence *
bt_processor_machine_persistence_load (const GType type,
    const BtPersistence * const persistence, xmlNodePtr node, GError ** err,
    va_list var_args)
{
  BtProcessorMachine *self;
  BtPersistence *result;
  BtPersistenceInterface *parent_iface;
  gulong voices;

  GST_DEBUG ("PERSISTENCE::processor_machine");
  g_assert (node);

  xmlChar *const id = xmlGetProp (node, XML_CHAR_PTR ("id"));
  xmlChar *const plugin_name = xmlGetProp (node, XML_CHAR_PTR ("plugin-name"));
  xmlChar *const voices_str = xmlGetProp (node, XML_CHAR_PTR ("voices"));
  voices = voices_str ? atol ((char *) voices_str) : 0;

  if (!persistence) {
    BtSong *song = NULL;
    gchar *param_name;
    va_list va;

    G_VA_COPY (va, var_args);
    // we need to get parameters from var_args (need to handle all baseclass params
    param_name = va_arg (va, gchar *);
    while (param_name) {
      if (!strcmp (param_name, "song")) {
        song = va_arg (va, gpointer);
      } else {
        GST_WARNING ("unhandled argument: %s", param_name);
        break;
      }
      param_name = va_arg (va, gchar *);
    }
    // TODO(ensonic): we also need the parameters the parent-class would parse
    // as a a quick hack copied the code from the parent class into the subclasses
    // see : http://www.buzztrax.org/index.php/Gobject_serialisation#Dealing_with_inheritance

    self =
        bt_processor_machine_new (song, (gchar *) id, (gchar *) plugin_name,
        voices, err);
    result = BT_PERSISTENCE (self);
    va_end (va);
  } else {
/* create a machine which is a sink machine and not a processor machine */
static void
test_bt_processor_machine_wrong_type (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");

  /*act */
  GError *err = NULL;
  BtProcessorMachine *machine =
      bt_processor_machine_new (song, "id", "autoaudiosink", 1, &err);

  GST_INFO ("-- assert --");
  fail_unless (machine != NULL, NULL);
  fail_unless (err != NULL, NULL);

  GST_INFO ("-- cleanup --");
  g_error_free (err);
  BT_TEST_END;
}
Beispiel #7
0
static void
test_bt_wire_pretty_name (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "audiotestsrc", "audiotestsrc",
          0L, NULL));
  BtMachine *proc = BT_MACHINE (bt_processor_machine_new (song, "volume",
          "volume", 0L, NULL));
  BtWire *wire = bt_wire_new (song, src, proc, NULL);

  GST_INFO ("-- act --");

  GST_INFO ("-- assert --");
  ck_assert_gobject_str_eq (wire, "pretty-name", "audiotestsrc -> volume");

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}
Beispiel #8
0
static void
test_bt_wire_persistence (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtMachine *src =
      BT_MACHINE (bt_source_machine_new (song, "audiotestsrc", "audiotestsrc",
          0L, NULL));
  BtMachine *proc = BT_MACHINE (bt_processor_machine_new (song, "volume",
          "volume", 0L, NULL));
  BtWire *wire = bt_wire_new (song, src, proc, NULL);

  GST_INFO ("-- act --");
  xmlNodePtr parent = xmlNewNode (NULL, XML_CHAR_PTR ("buzztrax"));
  xmlNodePtr node = bt_persistence_save (BT_PERSISTENCE (wire), parent);

  GST_INFO ("-- assert --");
  fail_unless (node != NULL, NULL);
  ck_assert_str_eq ((gchar *) node->name, "wire");
  fail_unless (node->children != NULL, NULL);

  GST_INFO ("-- cleanup --");
  BT_TEST_END;
}