Index: server/Slim/Player/Source.pm =================================================================== RCS file: /cvsroot/slim/server/Slim/Player/Source.pm,v retrieving revision 1.124 diff -u -r1.124 Source.pm --- server/Slim/Player/Source.pm 29 Nov 2004 19:26:49 -0000 1.124 +++ server/Slim/Player/Source.pm 2 Dec 2004 11:50:56 -0000 @@ -1015,7 +1015,7 @@ my ($command, $type, $format) = getConvertCommand($client, $fullpath); $::d_source && msg("openSong: this is an $type file: $fullpath\n"); - $::d_source && msg(" file type: $type format: $format inrate: $rate maxRate: $maxRate\n"); + $::d_source && msg(" file type: $type format: $format inrate: $rate maxRate: $maxRate sampleRate : $samplerate\n"); $::d_source && msg(" command: $command\n"); unless (defined($command)) { @@ -1182,6 +1182,33 @@ } +sub sampleRateHighEnough { + my $client = shift; + my $fullpath = shift; + my $type = shift; + + $type = Slim::Music::Info::contentType($fullpath) unless defined $type; + + # If we cannot find lame then currently we have no way to resample + return 1 if (!Slim::Utils::Misc::findbin('lame')); + + if (defined($type) && $type eq 'mp3') { + my $samplerate = Slim::Music::Info::samplerate($fullpath); + + # If we do not know the samplerate then assume it is high enough + # this may not be the right thing to do, but it follows the path + # of least surprise from the current behaviour + if ( !defined($samplerate) || $samplerate == 0 || $samplerate >= 44100 ) { + return 1; + } else { + return 0; + } + } + + # As for underMax just assume that we have 44100 raw PCM + return 1; +} + sub underMax { my $client = shift; my $fullpath = shift; @@ -1226,12 +1253,14 @@ my $audibleplayers = 0; my $undermax; + my $ratehighenough; if (defined($client)) { $player = $client->model(); $clientid = $client->id(); my @playergroup = ($client, Slim::Player::Sync::syncedWith($client)); $undermax = underMax($client,$fullpath,$type); - $::d_source && msg("undermax = $undermax, type = $type, $player = $clientid, lame = $lame\n"); + $ratehighenough = sampleRateHighEnough($client,$fullpath,$type); + $::d_source && msg("undermax = $undermax, ratehighenough = $ratehighenough,type = $type, $player = $clientid, lame = $lame\n"); # make sure we only test formats that are supported. foreach my $everyclient (@playergroup) { @@ -1277,7 +1306,7 @@ $format = $checkformat; # special case for mp3 to mp3 when input is higher than specified max bitrate. - if (defined $command && $command eq "-" && !$undermax && $type eq "mp3") { + if (defined $command && $command eq "-" && (!$undermax || !$ratehighenough) && $type eq "mp3") { $command = $commandTable{"$type-lame-*-*"}; $undermax = 1; } Index: server/Slim/Formats/MP3.pm =================================================================== RCS file: /cvsroot/slim/server/Slim/Formats/MP3.pm,v retrieving revision 1.12 diff -u -r1.12 MP3.pm --- server/Slim/Formats/MP3.pm 15 Nov 2004 18:58:39 -0000 1.12 +++ server/Slim/Formats/MP3.pm 2 Dec 2004 11:50:56 -0000 @@ -54,6 +54,7 @@ # bitrate is in bits per second, not kbits per second. $info->{'BITRATE'} = $info->{'BITRATE'} * 1000 if ($info->{'BITRATE'}); + $info->{'RATE'} = $info->{'FREQUENCY'} * 1000; close $fh;