Dynamically link multiple audio pipelines

I have issues with linking multiple audio pipelines dynamically during the PLAYING state.

First of all: My target architecture shall consist of multiple source pipelines (pipeline0), multiple intermediate pipelines (pipeline1) and a common output pipeline (pipeline2). The output pipeline will finally have an appsink instead of wasapisink as shown below.

Issue:
When linking the pipelines via static and dynamic pads as shown below, the audio flow interrupts suddenly and does not automatically resume afterwards as expected. The only thing which could solve the issue has been to flush the source pipeline after linking.
My questions are how shall I handle this dynamic linking appropriately in my C++ code and when do I have to flush pipelines explicitly?

#include <iostream>
#include <vector>
#include <thread>

#include <gst/gst.h>

int main(int arg, char* argv[])
{
  gst_init(&arg, &argv);

  GstElement* pipeline0 = gst_pipeline_new("pipeline");
  GstElement* audioSource0 = gst_element_factory_make("audiotestsrc", "audio_input0");
  GstElement* capsfilter0 = gst_element_factory_make("capsfilter", "capsfilter0");
  GstElement* tee0 = gst_element_factory_make("tee", "tee0");

  GstElement* pipeline1 = gst_pipeline_new("pipeline");
  GstElement* mixer1 = gst_element_factory_make("audiomixer", "mixer1");
  GstElement* audioconvert1 = gst_element_factory_make("audioconvert", "converter1");

  GstElement* pipeline2 = gst_pipeline_new("pipeline");
  GstElement* mixer2 = gst_element_factory_make("audiomixer", "mixer2");
  GstElement* wasapiSink2 = gst_element_factory_make("wasapisink", "wasapisink2");

  if (!pipeline0 || !audioSource0 || !capsfilter0 || !tee0 || !pipeline1 || !mixer1 || !audioconvert1 ||
      !pipeline2 || !mixer2 || !wasapiSink2)
  {
    std::cerr << "Not all GStreamer elements could be created." << std::endl;
    return false;
  }

  g_object_set(G_OBJECT(audioSource0), "wave", 3, nullptr);
  g_object_set(G_OBJECT(wasapiSink2), "device", "{0.0.0.00000000}.{3628a0e1-1925-49d1-a8d9-02234ffc1544}",
               nullptr);

  const unsigned samplerate{48000U};
  // The indices of all available output channels of the wasapi device.
  const unsigned numOutputChannels{2U};

  GstCaps* capsSource = gst_caps_new_simple("audio/x-raw", "format", G_TYPE_STRING, "F32LE", "channels",
                                            G_TYPE_INT, numOutputChannels, "rate", G_TYPE_INT, samplerate,
                                            "layout", G_TYPE_STRING, "interleaved", nullptr);
  g_object_set(G_OBJECT(capsfilter0), "caps", capsSource, nullptr);
  gst_caps_unref(capsSource);

  // Add elements to the pipeline0.
  gst_bin_add_many(GST_BIN(pipeline0), audioSource0, capsfilter0, tee0, nullptr);
  // Add elements to the pipeline1.
  gst_bin_add_many(GST_BIN(pipeline1), mixer1, audioconvert1, nullptr);
  // Add elements to the pipeline2.
  gst_bin_add_many(GST_BIN(pipeline2), mixer2, wasapiSink2, nullptr);

  // Link the elements.
  if (!gst_element_link(audioSource0, capsfilter0))
  {
    std::cerr << "Failed to link source0 and capsfilter0." << std::endl;
  }
  if (!gst_element_link(capsfilter0, tee0))
  {
    std::cerr << "Failed to link capsfilter0 and tee0." << std::endl;
  }
  if (!gst_element_link(mixer1, audioconvert1))
  {
    std::cerr << "Failed to link mixer1 and audioconvert1." << std::endl;
  }
  if (!gst_element_link(mixer2, wasapiSink2))
  {
    std::cerr << "Failed to link mixer2 and wasapiSink2." << std::endl;
  }

  GstStateChangeReturn ret0 = gst_element_set_state(pipeline0, GST_STATE_PLAYING);
  GstStateChangeReturn ret1 = gst_element_set_state(pipeline1, GST_STATE_PLAYING);
  GstStateChangeReturn ret2 = gst_element_set_state(pipeline2, GST_STATE_PLAYING);
  if (ret0 == GST_STATE_CHANGE_FAILURE || ret1 == GST_STATE_CHANGE_FAILURE ||
      ret2 == GST_STATE_CHANGE_FAILURE)
  {
    std::cerr << "Unable to set pipeline to PLAYING state." << std::endl;
    return 1;
  }
  else
    std::cout << "Playing..." << std::endl;

  // Link pipeline0 to pipeline1.
  auto sourcePad = gst_element_get_request_pad(tee0, "src_%u");
  auto sinkPad = gst_element_request_pad_simple(mixer1, "sink_%u");
  GstPadLinkReturn result0 = gst_pad_link_full(sourcePad, sinkPad, GST_PAD_LINK_CHECK_TEMPLATE_CAPS);

  // Link pipeline1 to pipeline2.
  sourcePad = gst_element_get_static_pad(audioconvert1, "src");
  sinkPad = gst_element_request_pad_simple(mixer2, "sink_%u");
  GstPadLinkReturn result1 = gst_pad_link_full(sourcePad, sinkPad, GST_PAD_LINK_CHECK_TEMPLATE_CAPS);

  gst_element_send_event(pipeline0, gst_event_new_flush_start());
  gst_element_send_event(pipeline0, gst_event_new_flush_stop(TRUE));

  if (result0 != GST_PAD_LINK_OK || result1 != GST_PAD_LINK_OK)
  {
    std::cerr << "Pad link result: " << gst_pad_link_get_name(result0) << std::endl;
    std::cerr << "Pad link result: " << gst_pad_link_get_name(result1) << std::endl;
    return 1;
  }

  while (true)
  {
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  }

  return 0;
}