Ejemplo n.º 1
0
        bool SeekToTrack(Element playbin, int track)
        {
            Format format = Format.Undefined;
            Element cdda_src = null;
            State state, pending;

            format = Util.FormatGetByNick ("track");
            if (format == Format.Undefined) {
                return false;
            }

            playbin.GetState (out state, out pending, 0);
            if (state < State.Paused) {
                // We can only seek if the pipeline is playing or paused, otherwise
                // we just allow playbin to do its thing, which will re-start the
                // device and start at the desired track
                return false;
            }

            cdda_src = GetCddaSource (playbin);
            if (cdda_src == null) {
                return false;
            }

            if (playbin.Seek (1.0, format, SeekFlags.Flush,
                SeekType.Set, track - 1, SeekType.None, -1)) {
                Log.DebugFormat ("cdda: seeking to track {0}, avoiding playbin", track);
                return true;
            }

            return false;
        }
Ejemplo n.º 2
0
    public void TestBusCallback(bool use_AddWatch)
    {
        pipeline = new Pipeline();
        Assert.IsNotNull (pipeline, "Could not create pipeline");

        Element src = ElementFactory.Make ("fakesrc");
        Assert.IsNotNull (src, "Could not create fakesrc");
        Element sink = ElementFactory.Make ("fakesink");
        Assert.IsNotNull (sink, "Could not create fakesink");

        Bin bin = (Bin) pipeline;
        bin.Add (src, sink);
        Assert.IsTrue (src.Link (sink), "Could not link between src and sink");

        if (use_AddWatch)
          pipeline.Bus.AddWatch (new BusFunc (MessageReceived));
        else {
          pipeline.Bus.AddSignalWatch();
          pipeline.Bus.Message += delegate (object o, MessageArgs args) {
        MessageReceived (null, args.Message);
          };
        }
        Assert.AreEqual (pipeline.SetState (State.Playing), StateChangeReturn.Async);

        loop = new GLib.MainLoop();
        loop.Run();

        Assert.AreEqual (pipeline.SetState (State.Null), StateChangeReturn.Success);
        State current, pending;
        Assert.AreEqual (pipeline.GetState (out current, out pending, Clock.TimeNone), StateChangeReturn.Success);
        Assert.AreEqual (current, State.Null, "state is not NULL but " + current);
    }