[Slim-Checkins] r10275 - in /branches/6.5/server:
Slim/Player/Source.pm Slim/Player/Squeezebox.pm strings.txt
andy at svn.slimdevices.com
andy at svn.slimdevices.com
Tue Oct 10 14:03:51 PDT 2006
Author: andy
Date: Tue Oct 10 14:03:49 2006
New Revision: 10275
URL: http://svn.slimdevices.com?rev=10275&view=rev
Log:
Stream rebuffering: If a stream drops to 1% buffer fullness, pause and wait for the stream to rebuffer instead of letting the audio stutter
Modified:
branches/6.5/server/Slim/Player/Source.pm
branches/6.5/server/Slim/Player/Squeezebox.pm
branches/6.5/server/strings.txt
Modified: branches/6.5/server/Slim/Player/Source.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Player/Source.pm?rev=10275&r1=10274&r2=10275&view=diff
==============================================================================
--- branches/6.5/server/Slim/Player/Source.pm (original)
+++ branches/6.5/server/Slim/Player/Source.pm Tue Oct 10 14:03:49 2006
@@ -56,6 +56,7 @@
Slim::Networking::Slimproto::setEventCallback('STMu', \&underrun);
Slim::Networking::Slimproto::setEventCallback('STMd', \&decoderUnderrun);
Slim::Networking::Slimproto::setEventCallback('STMs', \&trackStartEvent);
+ Slim::Networking::Slimproto::setEventCallback('STMt', \&checkFullness);
Slim::Networking::Slimproto::setEventCallback('STMn', \¬Supported);
}
@@ -623,6 +624,30 @@
# use execute callback...
# Slim::Control::Command::executeCallback($client, ['stop']);
Slim::Control::Request::notifyFromArray($client, ['stop']);
+ }
+}
+
+sub checkFullness {
+ my $client = shift || return;
+
+ # If a stream falls to below 1% buffer fullness and we
+ # have played at least 10 seconds, rebuffer the stream
+ my $fullness = int( Slim::Networking::Slimproto::fullness($client) / $client->bufferSize() * 100);
+
+ my $songTime = songTime($client);
+
+ if ( $fullness <= 1 && $songTime > 10 ) {
+ $::d_source && msg("Buffer fullness dropped to $fullness%, pausing to rebuffer\n");
+
+ $client->pause();
+
+ # Use the quickstart timer to wait until we've rebuffered enough
+ Slim::Utils::Timers::setTimer(
+ $client,
+ Time::HiRes::time() + 0.125,
+ \&Slim::Player::Squeezebox::quickstart,
+ 5, # signals quickstart what percentage to rebuffer to
+ );
}
}
Modified: branches/6.5/server/Slim/Player/Squeezebox.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Player/Squeezebox.pm?rev=10275&r1=10274&r2=10275&view=diff
==============================================================================
--- branches/6.5/server/Slim/Player/Squeezebox.pm (original)
+++ branches/6.5/server/Slim/Player/Squeezebox.pm Tue Oct 10 14:03:49 2006
@@ -229,7 +229,8 @@
}
sub quickstart {
- my $client = shift;
+ my $client = shift;
+ my $rebuffer = shift || 0; # Are we rebuffering an existing stream?
my $url = Slim::Player::Playlist::url( $client, Slim::Player::Source::streamingSongIndex($client) );
@@ -244,6 +245,15 @@
if ( my $bitrate = Slim::Music::Info::getBitrate($url) ) {
my $bufferSecs = Slim::Utils::Prefs::get('bufferSecs') || 3;
$threshold = int($bitrate / 8) * $bufferSecs;
+ }
+
+ if ( $rebuffer ) {
+ # Change the threshold to a precentage of buffer size
+ $threshold = int( $client->bufferSize() * ( $rebuffer / 100 ) );
+ $::d_source && msg("Quickstart: Rebuffering to $rebuffer%... $fullness / $threshold\n");
+ }
+ else {
+ $::d_source && msg("Quickstart: Buffering... $fullness / $threshold\n");
}
# Resume if we've hit the threshold, unless synced (sync unpauses all clients together)
@@ -272,7 +282,8 @@
$status = $client->string('WAITING_TO_SYNC');
}
else {
- $status = $client->string('BUFFERING') . ' ' . $percent . '%';
+ my $string = $rebuffer ? 'REBUFFERING' : 'BUFFERING';
+ $status = $client->string($string) . ' ' . $percent . '%';
}
$line1 = $client->string('NOW_PLAYING') . ' (' . $status . ')';
@@ -296,7 +307,7 @@
$client->showBriefly( $line1, $line2, 0.5 ) unless $client->display->sbName();
}
- Slim::Utils::Timers::setTimer( $client, Time::HiRes::time() + 0.125, \&quickstart );
+ Slim::Utils::Timers::setTimer( $client, Time::HiRes::time() + 0.125, \&quickstart, $rebuffer );
}
}
Modified: branches/6.5/server/strings.txt
URL: http://svn.slimdevices.com/branches/6.5/server/strings.txt?rev=10275&r1=10274&r2=10275&view=diff
==============================================================================
--- branches/6.5/server/strings.txt (original)
+++ branches/6.5/server/strings.txt Tue Oct 10 14:03:49 2006
@@ -1546,6 +1546,9 @@
ES Llenando el buffer...
NL Bufferen
ZH_CN ç¼å²è£
è½½ä¸
+
+REBUFFERING
+ EN Rebuffering...
WAITING_TO_SYNC
DE Warte auf Synchronisierung...
More information about the checkins
mailing list