/** * Start the audio playback and recording * * @param a Audio object * * @return 0 if success, otherwise errorcode */ int audio_start(struct audio *a) { int err; if (!a) return EINVAL; err = stream_start(a->strm); if (err) return err; /* Audio filter */ if (!a->filtl.head && !list_isempty(aufilt_list())) { err = aufilt_setup(a); if (err) return err; } /* configurable order of play/src start */ if (a->cfg.src_first) { err |= start_source(&a->tx, a); err |= start_player(&a->rx, a); } else { err |= start_player(&a->rx, a); err |= start_source(&a->tx, a); } return err; }
gint main (gint argc, gchar ** argv) { GError *error = NULL; gchar *uri = NULL; pid_t pid; init (&argc, &argv); if (argc < 2) { fprintf (stderr, "usage: %s [av-filename-or-url]\n", argv[0]); return 1; } if (!g_strstr_len (argv[1], -1, "://")) { uri = gst_filename_to_uri (argv[1], &error); } else { uri = g_strdup (argv[1]); } if (error) { fprintf (stderr, "usage: %s [av-filename-or-url]\n", argv[0]); g_clear_error (&error); return 1; } if (socketpair (AF_UNIX, SOCK_STREAM, 0, pipes)) { fprintf (stderr, "Error creating pipes: %s\n", strerror (errno)); return 2; } if (fcntl (pipes[0], F_SETFL, O_NONBLOCK) < 0 || fcntl (pipes[1], F_SETFL, O_NONBLOCK) < 0) { fprintf (stderr, "Error setting O_NONBLOCK on pipes: %s\n", strerror (errno)); return 2; } pid = fork (); if (pid < 0) { fprintf (stderr, "Error forking: %s\n", strerror (errno)); return 1; } else if (pid > 0) { setenv ("GST_DEBUG_FILE", "gstsrc.log", 1); gst_init (&argc, &argv); start_source (uri); } else { setenv ("GST_DEBUG_FILE", "gstsink.log", 1); gst_init (&argc, &argv); start_sink (); } g_free (uri); run (pid); return 0; }
/** * Start the audio playback and recording * * @param a Audio object * * @return 0 if success, otherwise errorcode */ int audio_start(struct audio *a) { int err; if (!a) return EINVAL; /* Audio filter */ if (!list_isempty(aufilt_list())) { err = aufilt_setup(a); if (err) return err; } /* configurable order of play/src start */ if (a->cfg.src_first) { err = start_source(&a->tx, a); err |= start_player(&a->rx, a); } else { err = start_player(&a->rx, a); err |= start_source(&a->tx, a); } if (err) return err; if (a->tx.ac && a->rx.ac) { if (!a->started) { info("%H%H", autx_print_pipeline, &a->tx, aurx_print_pipeline, &a->rx); } a->started = true; } return err; }