From 258e4fcdf22745ce2b119df63458790461a6fbf0 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 29 Jul 2007 04:58:22 +0000 Subject: fixed downsampling, renamed to transcoding default or always are now the options --- lib/class/song.class.php | 37 +++++++++++++++++-------------------- lib/class/user.class.php | 2 -- lib/preferences.php | 9 ++++----- lib/stream.lib.php | 17 ++++++----------- 4 files changed, 27 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 1dd7aa20..9e2e5da2 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -789,20 +789,19 @@ class Song { } // get_url - /*! - @function native_stream - @discussion returns true if the $song->type streams ok, false if it must be transcoded to stream - */ - function native_stream() { + /** + * native_stream + * This returns true/false if this can be nativly streamed + */ + public function native_stream() { if ($this->_transcode) { return false; } $conf_var = 'transcode_' . $this->type; $conf_type = 'transcode_' . $this->type . '_target'; - + if (Config::get($conf_var)) { $this->_transcode = true; - $this->format_type(Config::get($conf_type)); debug_event('auto_transcode','Transcoding to ' . $this->type,'5'); return false; } @@ -820,21 +819,19 @@ class Song { */ function stream_cmd() { - $parts = pathinfo($this->file); + // Find the target for this transcode + $conf_type = 'transcode_' . $this->type . '_target'; + $this->format_type(Config::get($conf_type)); + $stream_cmd = 'transcode_cmd_' . $this->type; + if (Config::get($stream_cmd)) { + return $stream_cmd; + } + else { + debug_event('Downsample','Error: Transcode ' . $stream_cmd . ' for ' . $this->type . ' not found, using downsample','2'); + } - - if (!$this->native_stream()) { - $stream_cmd = 'stream_cmd_' . $parts['extension']; - if (conf($stream_cmd)) { - return $stream_cmd; - } - else { - debug_event('Downsample','Error: Stream command for ' . $parts['extension'] . ' not found, using downsample','2'); - } - } // end if not native_stream - - return 'downsample_cmd'; + return false; } // end stream_cmd diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 5924eec1..5867a4bb 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -397,11 +397,9 @@ class User { if (empty($data['username'])) { Error::add('username',_('Error Username Required')); -echo "WOO"; } if ($data['password1'] != $data['password2'] AND !empty($data['password1'])) { -echo "WOO"; Error::add('password',_("Error Passwords don't match")); } diff --git a/lib/preferences.php b/lib/preferences.php index 18b88057..a2dc0afe 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -248,8 +248,7 @@ function create_preference_input($name,$value) { echo "\n"; break; case 'play_type': - if ($value == 'downsample') { $is_down = 'selected="selected"'; } - elseif ($value == 'localplay') { $is_local = 'selected="selected"'; } + if ($value == 'localplay') { $is_local = 'selected="selected"'; } elseif ($value == 'democratic') { $is_vote = 'selected="selected"'; } elseif ($value == 'xspf_player') { $is_xspf_player = 'selected="selected"'; } else { $is_stream = "selected=\"selected\""; } @@ -347,10 +346,10 @@ function create_preference_input($name,$value) { echo "\n"; break; case 'transcode': + ${$value} = ' selected="selected"'; echo "\n"; break; default: diff --git a/lib/stream.lib.php b/lib/stream.lib.php index 6ec5c3df..9b9b19c1 100644 --- a/lib/stream.lib.php +++ b/lib/stream.lib.php @@ -125,20 +125,16 @@ function check_lock_songs($song_id) { * start_downsample * This is a rather complext function that starts the downsampling of a song and returns the * opened file handled - * @package General - * @catagory Downsample - * @param $song The Song Object */ function start_downsample($song,$now_playing_id=0,$song_name=0) { /* Check to see if bitrates are set if so let's go ahead and optomize! */ - $max_bitrate = conf('max_bit_rate'); - $min_bitrate = conf('min_bit_rate'); + $max_bitrate = Config::get('max_bit_rate'); + $min_bitrate = Config::get('min_bit_rate'); $time = time(); - $dbh = dbh(); $user_sample_rate = $GLOBALS['user']->prefs['sample_rate']; $browser = new Browser(); - + if (!$song_name) { $song_name = $song->f_artist_full . " - " . $song->title . "." . $song->type; } @@ -149,13 +145,12 @@ function start_downsample($song,$now_playing_id=0,$song_name=0) { $sql = "SELECT COUNT(*) FROM now_playing, user_preference, preferences " . "WHERE preferences.name = 'play_type' AND user_preference.preference = preferences.id " . "AND now_playing.user = user_preference.user AND user_preference.value='downsample'"; - $db_results = mysql_query($sql,$dbh); - $results = mysql_fetch_row($db_results); + $db_results = Dba::query($sql); + $results = Dba::fetch_row($db_results); // Current number of active streams (current is already in now playing) $active_streams = $results[0]; - /* If only one user, they'll get all available. Otherwise split up equally. */ $sample_rate = floor($max_bitrate/$active_streams); @@ -217,7 +212,7 @@ function start_downsample($song,$now_playing_id=0,$song_name=0) { $song_file = escapeshellarg($song->file); /* Replace Variables */ - $downsample_command = conf($song->stream_cmd()); + $downsample_command = Config::get($song->stream_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); -- cgit