diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-15 06:50:58 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-07-15 06:50:58 +0000 |
commit | 0a3df5cbcfc10a0f18e9da311d887eb00fd6fbf1 (patch) | |
tree | 9774ec6174a3bcdf16a7e800aed718c7d4aefdaa /play/index.php | |
parent | 51b625a4463ab90f14cc85e589867903026e78ec (diff) | |
download | ampache-0a3df5cbcfc10a0f18e9da311d887eb00fd6fbf1.tar.gz ampache-0a3df5cbcfc10a0f18e9da311d887eb00fd6fbf1.tar.bz2 ampache-0a3df5cbcfc10a0f18e9da311d887eb00fd6fbf1.zip |
added on the fly bandwidth management for downsampled users
Diffstat (limited to 'play/index.php')
-rw-r--r-- | play/index.php | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/play/index.php b/play/index.php index 874de187..660ae9d4 100644 --- a/play/index.php +++ b/play/index.php @@ -138,6 +138,8 @@ if ( $catalog->catalog_type == 'remote' ) { header("Location: " . $song->file . $extra_info); if (conf('debug')) { log_event($user->username,' xmlrpc-stream ',"Start XML-RPC Stream - " . $song->file . $extra_info); } } + + else { if ($user->prefs['play_type'] == 'downsample') { $ds = $user->prefs['sample_rate']; @@ -150,16 +152,8 @@ else { gc_now_playing(); // If we are running in Legalize mode, don't play songs already playing - if (conf('lock_songs') == 'true') { - $sql = "SELECT COUNT(*) FROM now_playing" . - " WHERE song_id = '$song_id'"; - $db_result = mysql_query($sql, $dbh); - while ($r = mysql_fetch_row($db_result)) { - if ($r[0] == 1) { - // Song is already playing, so exit without returning song - exit; - } - } + if (conf('lock_songs')) { + if (!check_lock_songs($song->id)) { exit(); } } // Put this song in the now_playing table @@ -214,37 +208,11 @@ else { // Prevent the script from timing out set_time_limit(0); - if ($ds) { - $ds = $user->prefs['sample_rate']; - $dsratio = $ds/$song->bitrate*1024; - $browser->downloadHeaders($song_name, $song->mime, false,$dsratio*$song->size); - - /* Get Offset */ - $offset = ( $start*$song->time )/( $dsratio*$song->size ); - $offsetmm = floor($offset/60); - $offsetss = floor($offset-$offsetmm*60); - $offset = sprintf("%02d.%02d",$offsetmm,$offsetss); + if ($user->prefs['play_type'] == 'downsample') { - /* Get EOF */ - $eofmm = floor($song->time/60); - $eofss = floor($song->time-$eofmm*60); - $eof = sprintf("%02d.%02d",$eofmm,$eofss); - - /* Replace Variables */ - $downsample_command = conf('downsample_cmd'); - $downsample_command = str_replace("%FILE%",$song->file,$downsample_command); - $downsample_command = str_replace("%OFFSET%",$offset,$downsample_command); - $downsample_command = str_replace("%EOF%",$eof,$downsample_command); - $downsample_command = str_replace("%SAMPLE%",$ds,$downsample_command); - - // If we are debugging log this event - if (conf('debug')) { - $message = "Exec: $downsample_command"; - log_event($user->username,'downsample',$message); - } // if debug + $fp = start_downsample($song,$lastid,$song_name); - $fp = @popen($downsample_command, 'r'); - } // if downsampling + } // end if downsampling elseif ($start) { $browser->downloadHeaders($song_name, $song->mime, false, $song->size); @@ -282,7 +250,7 @@ else { delete_now_playing($lastid); /* Clean up any open ends */ - if ($ds) { + if ($user->prefs['play_type'] == 'downsample') { @pclose($fp); } else { |