1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Move process kill to stream function

This commit is contained in:
Afterster 2015-05-31 23:54:18 +02:00
parent 422d4bf260
commit d53527378b
4 changed files with 20 additions and 18 deletions

View file

@ -472,7 +472,7 @@ class Channel extends database_object implements media, library_item
fclose($this->transcoder['stderr']);
}
fclose($this->transcoder['handle']);
proc_terminate($this->transcoder['process']);
Stream::kill_process($this->$transcoder);
$this->media = null;
$this->transcoder = null;

View file

@ -256,8 +256,7 @@ class Stream
// Windows doesn't like to provide stderr as a pipe
$descriptors[2] = array('pipe', 'w');
$cmdPrefix = "exec ";
}
else
} else
$cmdPrefix = "start /B ";
@ -277,6 +276,21 @@ class Stream
return array_merge($parray, $settings);
}
public static function kill_process($transcoder)
{
$status = proc_get_status($transcoder['process']);
if ($status['running'] == true) {
$pid = $status['pid'];
debug_event('stream', 'Stream process about to be killed. pid:' . $pid, 1);
(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') ? exec("taskkill /F /T /PID $pid") : exec("kill -9 $pid");
proc_close($transcoder['process']);
} else {
debug_event('stream', 'Process is not running, kill skipped.', 5);
}
}
/**
* validate_bitrate
* this function takes a bitrate and returns a valid one

View file

@ -111,7 +111,8 @@ class Waveform
fclose($fp);
fclose($tfp);
proc_terminate($transcoder['process']);
Stream::kill_process($transcoder);
$waveform = self::create_waveform($tmpfile);
//$waveform = self::create_waveform("C:\\tmp\\test.wav");

View file

@ -678,20 +678,7 @@ if ($bytes_streamed < $stream_size && (connection_status() == 0)) {
if ($transcode && isset($transcoder)) {
fclose($fp);
function kill($pid){
return stripos(php_uname('s'), 'win')>-1 ? exec("taskkill /F /T /PID $pid") : exec("kill -9 $pid");
}
$status = proc_get_status($transcoder['process']);
if($status['running'] == true)
{
$pid = $status['pid'];
debug_event('play', 'Stream process about to be killed. pid:'.$pid, 1);
kill($pid);
proc_close($transcoder['process']);
}
Stream::kill_process($transcoder);
} else {
fclose($fp);
}