Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Slim/Music/Info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,14 @@ sub isContainer {
return 0;
}

sub isLossy {
my $type = shift;

if (defined $type && $type =~ /mp3|aac|ogg|ops/) {
return 1;
}
}

# Return a list of valid extensions for a particular type as listed in types.conf
sub validTypeExtensions {
my $findTypes = shift || 'list|audio';
Expand Down
18 changes: 9 additions & 9 deletions Slim/Player/Song.pm
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,18 @@ sub open {
last if $transcoder;
}

if (! $transcoder) {
if (!$transcoder) {
logError("Couldn't create command line for $format playback for [$url]");
return (undef, ($error || 'PROBLEM_CONVERT_FILE'), $url);
} elsif (main::INFOLOG && $log->is_info) {
$log->info("Transcoder: streamMode=", $transcoder->{'streamMode'}, ", streamformat=", $transcoder->{'streamformat'});
$log->info("Transcoder: ", Data::Dump::dump($transcoder));
}

# Init song's sample rate and sample size before any transcoding
$self->samplerate($transcoder->{'sampleRate'});
$self->samplesize($transcoder->{'sampleSize'});
if (!Slim::Music::Info::isLossy($transcoder->{'streamformat'})) { # Only set sample size for lossless
$self->samplesize($transcoder->{'sampleSize'});
}

if ($wantTranscoderSeek && (grep(/T/, @{$transcoder->{'usedCapabilities'}}))) {
$transcoder->{'start'} = $self->startOffset($self->seekdata()->{'timeOffset'});
Expand Down Expand Up @@ -625,16 +627,14 @@ sub open {

$self->_transcoded(1);

main::INFOLOG && $log->info("Transcoder: ", Data::Dump::dump($transcoder));

my $streamformat = $transcoder->{'streamformat'};
$self->_streamFormat($streamformat);

my $bitrate;
my $sampleSize;
my $sampleRate;

if ($streamformat =~ /mp3|aac/) {
if (Slim::Music::Info::isLossy($streamformat)) {
$bitrate = $transcoder->{'rateLimit'}; # bitrate limit
$self->samplesize(""); # clear samplesize for lossy formats
$self->samplerate( min($transcoder->{'sampleRate'}, $transcoder->{'samplerateLimit'}) );
Expand Down Expand Up @@ -714,7 +714,7 @@ sub guessBitrateFromFormat {
$sampleSize //= 16;
$sampleRate //= 44_100;

if ($format =~ /mp3|aac/) {
if (Slim::Music::Info::isLossy($format)) {
return ($bitrate || 320) * 1000;
} elsif ($format =~ /wav|aif|pcm/) {
# Just assume standard rate
Expand Down