Re: Callbacks with GStreamer1



Hi,
In case you still haven't found the solution, adding this line before the add_watch fixes the error :
$bus->add_signal_watch;

On Sat, Jun 20, 2015 at 5:31 PM, Timm Murray <tmurray wumpus-cave net> wrote:
I'm trying to pass along a code reference to add_watch() (from of GstBus).  My attempt, which is based on the examples in the old GStreamer module, is below.  It fails with the message:

    Not a CODE reference at hello_callback.pl line 17.

Which is the "$loop->run" line.  Is there some incantation that needs to run on GStreamer1 for the callback reference to be accepted?

Thanks,
Timm Murray

#!perl
use v5.12;
use warnings;
use GStreamer1;
use Glib qw( TRUE FALSE );

my $URI = shift || die "Need URI to play\n";

my $loop = Glib::MainLoop->new( undef, FALSE );
GStreamer1::init([ $0, @ARGV ]);
my $pipeline = GStreamer1::parse_launch( "playbin uri=$URI" );

my $bus = $pipeline->get_bus;
$bus->add_watch( \&bus_callback, $loop );

$pipeline->set_state( "playing" );
$loop->run;
$pipeline->set_state( "null" );


sub bus_callback
{
    my ($bus, $message, $loop) = @_;

    if( $message->type & "error" ) {
        warn $message->error;
        $loop->quit;
    }
    elsif( $message->type & "eos" ) {
        $loop->quit;
    }

    return TRUE;
}

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]