package Soundzero; use 5.008007; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use Soundzero ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); our $VERSION = '0.01'; require XSLoader; XSLoader::load('Soundzero', $VERSION); # Preloaded methods go here. sub new { my $ref = shift; my $class = ref ($ref) || $ref; my $params = shift || {}; my $self = bless ({ samplerate => 44100, bufferlen => 128, %{$params}, isrunning => 0 }, $class); pa_init ($self->{"samplerate"}, $self->{"bufferlen"}); if (exists ($self->{"callback"})) { $self->register ($self->{"callback"}); } return $self; } sub DESTROY { my $self = shift; if ($self->{"isrunning"}) { $self->stop; } pa_close (); } sub register { my $self = shift; my $cb = shift; $self->{"callback"} = $cb; registercb ($self->{"callback"}); return $self; } sub start { my $self = shift; if ($self->{"isrunning"}) { carp ("audio stream already running\n"); } else { pa_start (); $self->{"isrunning"} = 1; } return $self; } sub stop { my $self = shift; if ($self->{"isrunning"}) { pa_stop (); $self->{"isrunning"} = 0; } else { carp ("audio stream isn't running\n"); } return $self; } 1; __END__ # Below is stub documentation for your module. You'd better edit it! =head1 NAME Soundzero - Perl extension for blah blah blah =head1 SYNOPSIS use Soundzero; blah blah blah =head1 DESCRIPTION Stub documentation for Soundzero, created by h2xs. It looks like the author of the extension was negligent enough to leave the stub unedited. Blah blah blah. =head2 EXPORT None by default. =head1 SEE ALSO Mention other useful documentation such as the documentation of related modules or operating system documentation (such as man pages in UNIX), or any relevant external documentation such as RFCs or standards. If you have a mailing list set up for your module, mention it here. If you have a web site set up for your module, mention it here. =head1 AUTHOR A. U. Thor, Ea.u.thor@a.galaxy.far.far.awayE =head1 COPYRIGHT AND LICENSE Copyright (C) 2005 by A. U. Thor This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available. =cut