[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnump3d-users] GNUMP3d 2.7-prerelease.
From: |
Mark Schouten |
Subject: |
Re: [Gnump3d-users] GNUMP3d 2.7-prerelease. |
Date: |
Tue, 23 Mar 2004 21:57:23 +0100 |
User-agent: |
Mutt/1.5.5.1+cvs20040105i |
On Tue, Mar 23, 2004 at 07:48:41PM +0000, Steve Kemp wrote:
> On Wed, Mar 24, 2004 at 08:39:29PM +0100, Mark Schouten wrote:
> >
> > this goes into 'sub streamAudioFile' somewhere in the start.
> >
> > + # Only downsample if this IP is in the right range.
> > + if ( &downsampleAddress( $connected_address ) )
> > + {
> > + print "Downsampling disabled for: $connected_address\n";
> > + &serveFile($data, $file);
> > + }
> > +
> >
>
> This is already in there .. isn't it?
Ehm. Yes. But there's a small difference. I removed the '!'. In you
2.7-version, there is an '!' which I misplaced. So please remove it. :)
> > You can put this anywhere within gnump3d
> >
> > + sub downsampleAddress( $ )
> > + {
> > + }
>
> Ditto for this...!
/me <- l-user
>
> > I only have to work on some code to clean the cache-dir..
> >
> > address@hidden:/tmp/gnump3d-2.6/bin$ du -chs /var/tmp/gnump3d/
> > 615M /var/tmp/gnump3d
> >
> > That could become a problem..
>
> I've added a weekly cronjob to cleaan this up for the Debian package,
> I guess that's a fair solution.
Well, how about this? (Untested code)
*** /tmp/gnump3d-2.7-orig Tue Mar 23 21:25:30 2004
--- /tmp/gnump3d-2.7-editted Tue Mar 23 21:53:17 2004
***************
*** 1729,1750 ****
my $pre_exit;
if (!(-e "$down_cachedir/$cacheFile.full" && open (SAMPLE,
"$down_cachedir/$cacheFile.full"))) {
! opendir(CACHECHECK, $down_cachedir);
! my $cachesize = 0;
! foreach(grep {!/^\.{1,2}/} readdir(CACHECHECK)) {
! $cachesize += -s $down_cachedir."/".$_;
! }
! close(CACHECHECK);
! if ($cachesize > ($down_cache_limit*1024*1024)) {
! print "Cache is too big. Write something to clean up!";
! print "Cache is $cachesize bytes. ".
$down_cache_limit*1024*1024 ." is allowed.\n";
! } else {
! print "Cache is $cachesize bytes. ".
$down_cache_limit*1024*1024 ." is allowed.\n";
! }
open( SAMPLE, "$cmd|" )
or die "Cannot run : '$cmd $file' : $!";
open( CACHING, "+>$down_cachedir/$cacheFile" );
! $writecache = 1;
}
while ($size = read(SAMPLE, $buff, 2048) )
--- 1729,1764 ----
my $pre_exit;
if (!(-e "$down_cachedir/$cacheFile.full" && open (SAMPLE,
"$down_cachedir/$cacheFile.full"))) {
! opendir(CACHECHECK, $down_cachedir);
! my $cachesize = 0;
! foreach(grep {!/^\.{1,2}/} readdir(CACHECHECK)) {
! $cachesize += -s $down_cachedir."/".$_;
! }
! close(CACHECHECK);
! if ($cachesize > ($down_cache_limit*1024*1024)) {
! opendir(CACHECLEANUP, "$down_cachedir");
! my @files;
! foreach(grep {!/^\.{1,2}/} readdir(CACHECLEANUP)) {
! my %fileinfo;
! $fileinfo{accesstime} =
(stat("$down_cachedir/$_"))[8];
! $fileinfo{size} =
(stat("$down_cachedir/$_"))[7];
! $fileinfo{path} = "$down_cachedir/$_";
! push @files, \%fileinfo;
! }
! @files = sort { $a->{accesstime} <=> $b->{accesstime} }
@files;
! foreach my $file (@files) {
! if ($cachesize > ($down_cache_limit*1024*1024))
{
! unlink($file->{path});
! $cachesize = $cachesize - $file->{size};
! }
! }
! } else {
! print "Cache is $cachesize bytes. ".
$down_cache_limit*1024*1024 ." is allowed.\n";
! }
open( SAMPLE, "$cmd|" )
or die "Cannot run : '$cmd $file' : $!";
open( CACHING, "+>$down_cachedir/$cacheFile" );
! $writecache = 1;
}
while ($size = read(SAMPLE, $buff, 2048) )
***************
*** 1767,1773 ****
}
close( SAMPLE );
close( CACHING ) if ($writecache == 1);
! rename("$down_cachedir/$cacheFile", "$down_cachedir/$cacheFile.full") if
($pre_exit == 0);
close( $data );
}
--- 1781,1791 ----
}
close( SAMPLE );
close( CACHING ) if ($writecache == 1);
! if ($pre_exit == 0) {
! rename("$down_cachedir/$cacheFile",
"$down_cachedir/$cacheFile.full");
! } else {
! unlink("$down_cachedir/$cacheFile");
! }
close( $data );
}
That should do it 'realtime'. And I don't think the delay is a problem.
If you're allready downsampling, you (at least I) am counting on some
delay.
> > Eh, yeah, well. It works, let's keep it that way. :P
>
> Such enthusiasm!
Yeay, that's my strong point! :)
Mark
--
Mark Schouten
Read my rules of email-engagement: http://prevented.net/email-rules.html