mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-06 03:49:56 +02:00
Move process kill to stream function
This commit is contained in:
parent
422d4bf260
commit
d53527378b
4 changed files with 20 additions and 18 deletions
|
@ -472,7 +472,7 @@ class Channel extends database_object implements media, library_item
|
||||||
fclose($this->transcoder['stderr']);
|
fclose($this->transcoder['stderr']);
|
||||||
}
|
}
|
||||||
fclose($this->transcoder['handle']);
|
fclose($this->transcoder['handle']);
|
||||||
proc_terminate($this->transcoder['process']);
|
Stream::kill_process($this->$transcoder);
|
||||||
|
|
||||||
$this->media = null;
|
$this->media = null;
|
||||||
$this->transcoder = null;
|
$this->transcoder = null;
|
||||||
|
|
|
@ -256,8 +256,7 @@ class Stream
|
||||||
// Windows doesn't like to provide stderr as a pipe
|
// Windows doesn't like to provide stderr as a pipe
|
||||||
$descriptors[2] = array('pipe', 'w');
|
$descriptors[2] = array('pipe', 'w');
|
||||||
$cmdPrefix = "exec ";
|
$cmdPrefix = "exec ";
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
$cmdPrefix = "start /B ";
|
$cmdPrefix = "start /B ";
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,6 +276,21 @@ class Stream
|
||||||
return array_merge($parray, $settings);
|
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
|
* validate_bitrate
|
||||||
* this function takes a bitrate and returns a valid one
|
* this function takes a bitrate and returns a valid one
|
||||||
|
|
|
@ -111,7 +111,8 @@ class Waveform
|
||||||
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
fclose($tfp);
|
fclose($tfp);
|
||||||
proc_terminate($transcoder['process']);
|
|
||||||
|
Stream::kill_process($transcoder);
|
||||||
|
|
||||||
$waveform = self::create_waveform($tmpfile);
|
$waveform = self::create_waveform($tmpfile);
|
||||||
//$waveform = self::create_waveform("C:\\tmp\\test.wav");
|
//$waveform = self::create_waveform("C:\\tmp\\test.wav");
|
||||||
|
|
|
@ -678,20 +678,7 @@ if ($bytes_streamed < $stream_size && (connection_status() == 0)) {
|
||||||
if ($transcode && isset($transcoder)) {
|
if ($transcode && isset($transcoder)) {
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
|
||||||
function kill($pid){
|
Stream::kill_process($transcoder);
|
||||||
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']);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue