Skip to content

Commit

Permalink
Merge branch 'public/8.5' into public/9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mherger committed Apr 2, 2024
2 parents 2c3a90a + 59e159e commit 61c0332
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
13 changes: 8 additions & 5 deletions Slim/Player/Protocols/HTTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ sub response {

# re-parse the request string as it might have been overloaded by subclasses
my $request_object = HTTP::Request->parse($request);
my ($first) = $self->contentRange =~ /(\d+)-/;

# do we have the range we requested
if ($request_object->header('Range') =~ /^bytes=(\d+)-/ &&
$1 != ($self->contentRange =~ /(\d+)-/)) {
if ($request_object->header('Range') =~ /^bytes=(\d+)-/ && $first != $1) {
${*$self}{'_skip'} = $1;
$first = $1;
$log->info("range request not served, skipping $1 bytes");
}

Expand All @@ -112,7 +113,6 @@ sub response {
$request_object->uri("$proto://$host" . ($port ? ":$port" : '') . $uri);
}

my ($first) = $self->contentRange =~ /(\d+)-/;
my $length = $self->contentLength;

${*$self}{'_enhanced'} = {
Expand Down Expand Up @@ -601,13 +601,16 @@ sub _sysread {
return CORE::sysread($_[0], $_[1], $_[2], $_[3]) unless ${*$self}{'_skip'};

# skip what we need until done or EOF
my $bytes = CORE::sysread($_[0], $_[1], min(${*$self}{'_skip'}, $_[2]), $_[3]);
my $bytes = CORE::sysread($_[0], my $scratch, min(${*$self}{'_skip'}, 32768));
return $bytes if defined $bytes && !$bytes;

# pretend we don't have received anything until we've skipped all
${*$self}{'_skip'} -= $bytes if $bytes;
main::INFOLOG && $log->info("Done skipping bytes") unless ${*$self}{'_skip'};

# we should use EINTR (see S::P::Source) but this is too slow when skipping - will fix in 9.0
$_[1]= '';
$! = EINTR;
$! = EWOULDBLOCK;
return undef;
}

Expand Down
21 changes: 20 additions & 1 deletion Slim/Player/Protocols/HTTPS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package Slim::Player::Protocols::HTTPS;

use base qw(IO::Socket::SSL Slim::Player::Protocols::HTTP);

use List::Util qw(min);

use Slim::Utils::Errno;
use Slim::Utils::Log;
use Slim::Utils::Prefs;
Expand Down Expand Up @@ -103,7 +105,24 @@ sub slimprotoFlags {
# object's parent, not the package's parent
# see http://modernperlbooks.com/mt/2009/09/when-super-isnt.html
sub _sysread {
my $readLength = $_[0]->SUPER::sysread($_[1], $_[2], $_[3]);
my $self = $_[0];

# skip what we need until done or EOF
if ( ${*$self}{'_skip'} ) {
my $bytes = $self->SUPER::sysread(my $scratch, min(${*$self}{'_skip'}, 32768));
return $bytes if defined $bytes && !$bytes;

# pretend we don't have received anything until we've skipped all
${*$self}{'_skip'} -= $bytes if $bytes;
main::INFOLOG && $log->info("Done skipping bytes") unless ${*$self}{'_skip'};

# we should use EINTR (see S::P::Source) but this is too slow when skipping - will fix in 9.0
$_[1]= '';
$! = EWOULDBLOCK;
return undef;
}

my $readLength = $self->SUPER::sysread($_[1], $_[2], $_[3]);

if (main::ISWINDOWS && !$readLength) {
$! = EINTR;
Expand Down
4 changes: 2 additions & 2 deletions Slim/Utils/Scanner/Remote.pm
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ sub parseWavAifHeader {
}

$track->samplerate($info->{samplerate});
$track->samplesize($info->{samplesize});
$track->samplesize($info->{bits_per_sample});
$track->channels($info->{channels});
$track->endian($type eq 'wav' || $info->{compression_type} eq 'swot' ? 0 : 1);

Expand All @@ -996,7 +996,7 @@ sub parseWavAifHeader {

if ( main::DEBUGLOG && $log->is_debug ) {
$log->debug( sprintf( "$type: %dHz, %dBits, %dch => bitrate: %dkbps (ofs: %d, len: %d)",
$info->{samplerate}, $info->{samplesize}, $info->{channels}, int( $info->{bitrate} / 1000 ),
$info->{samplerate}, $info->{bits_per_sample}, $info->{channels}, int( $info->{bitrate} / 1000 ),
$track->audio_offset, $track->audio_size ) );
}

Expand Down

0 comments on commit 61c0332

Please sign in to comment.