Mercurial > epgrec.yaz
comparison recorder.php @ 165:3d4df1fe4166
merged with upstream
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 08 Apr 2010 04:22:20 +0900 |
parents | b3095425e613 |
children | 68f6b36e7c01 |
comparison
equal
deleted
inserted
replaced
160:47a3acf19870 | 165:3d4df1fe4166 |
---|---|
12 | 12 |
13 if( ! defined( RECORDER_CMD ) ) { | 13 if( ! defined( RECORDER_CMD ) ) { |
14 define( "RECORDER_CMD", INSTALL_PATH . "/recorder.php" ); | 14 define( "RECORDER_CMD", INSTALL_PATH . "/recorder.php" ); |
15 } | 15 } |
16 | 16 |
17 $settings = Settings::factory(); | |
18 $reserve_id = $argv[1]; | |
19 $msgh_r = null; // 受信用メッセージハンドラ | |
20 $msgh_w = null; // 送信用メッセージハンドラ | |
21 | |
17 | 22 |
18 // ノンブロッキングメッセージ受信 | 23 // ノンブロッキングメッセージ受信 |
19 | 24 |
20 function epgrec_get_message() { | 25 function epgrec_get_message() { |
21 global $msgh_r, $reserve_id; | 26 global $msgh_r, $reserve_id; |
52 // こういうやり方しかないのか? | 57 // こういうやり方しかないのか? |
53 // | 58 // |
54 function epgrec_childproc( $p ) | 59 function epgrec_childproc( $p ) |
55 { | 60 { |
56 $st = proc_get_status( $p ); | 61 $st = proc_get_status( $p ); |
57 $cpids = epgrec_childproc( $st['pid'] ); | 62 $ppid = $st['pid']; |
58 | 63 |
59 // ps を実行する | 64 // ps を実行する |
60 $d = array( | 65 $d = array( |
61 0 => array( 'file','/dev/null','r' ), | 66 0 => array( 'file','/dev/null','r' ), |
62 1 => array( 'pipe','w' ), | 67 1 => array( 'pipe','w' ), |
102 return true; // 保証できない | 107 return true; // 保証できない |
103 } | 108 } |
104 | 109 |
105 ////// ここから本編 | 110 ////// ここから本編 |
106 | 111 |
107 $settings = Settings::factory(); | |
108 $reserve_id = $argv[1]; | |
109 $msgh_r = null; // 受信用メッセージハンドラ | |
110 $msgh_w = null; // 送信用メッセージハンドラ | |
111 | 112 |
112 // メッセージハンドラを得る | 113 // メッセージハンドラを得る |
113 $ipc_key = ftok( RECORDER_CMD, "R" ); | 114 $ipc_key = ftok( RECORDER_CMD, "R" ); |
114 $msgh_r = msg_get_queue( $ipc_key ); | 115 $msgh_r = msg_get_queue( $ipc_key ); |
115 | 116 |
153 | 154 |
154 // 録画開始 | 155 // 録画開始 |
155 | 156 |
156 $proch = false; | 157 $proch = false; |
157 if( ( $proch = epgrec_exec(DO_RECORD) ) !== false ) { | 158 if( ( $proch = epgrec_exec(DO_RECORD) ) !== false ) { |
159 reclog("recorder:: 録画ID".$rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画開始" ); | |
158 // 録画完了待ち | 160 // 録画完了待ち |
159 $rec_cont = true; | 161 $rec_cont = true; |
160 while( $rec_cont ){ | 162 while( $rec_cont ){ |
161 $st = proc_get_status($proch); | 163 $st = proc_get_status($proch); |
162 if(! $st['running'] ) $rec_cont = false; // 録画完了 | 164 if(! $st['running'] ) $rec_cont = false; // 録画完了 |
169 reclog( "録画コマンドを停止できません", EPGREC_WARN ); | 171 reclog( "録画コマンドを停止できません", EPGREC_WARN ); |
170 } | 172 } |
171 else { | 173 else { |
172 epgrec_send_message("success"); | 174 epgrec_send_message("success"); |
173 reclog("recorder:: 録画ID".$rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画が中断された" ); | 175 reclog("recorder:: 録画ID".$rrec->id .":".$rrec->type.$rrec->channel.$rrec->title."の録画が中断された" ); |
176 $rec_cont = false; | |
174 } | 177 } |
175 break; | 178 break; |
176 | 179 |
177 case "stat": | 180 case "stat": |
178 epgrec_send_message("alive"); | 181 epgrec_send_message("alive"); |
191 $rrec->complete = 1; // 終わったことにする | 194 $rrec->complete = 1; // 終わったことにする |
192 throw new RecException("recorder:: 録画コマンドの実行に失敗した", EPGREC_ERROR ); | 195 throw new RecException("recorder:: 録画コマンドの実行に失敗した", EPGREC_ERROR ); |
193 } | 196 } |
194 | 197 |
195 // 予定より短いようなら終了時間を現在に書き換える | 198 // 予定より短いようなら終了時間を現在に書き換える |
196 | |
197 if( time() < $endtime ) { | 199 if( time() < $endtime ) { |
198 $rrec->endtime = toDatetime( time() ); | 200 $rrec->endtime = toDatetime( time() ); |
199 } | 201 } |
200 | 202 |
201 // 完了フラグを立てておく | 203 // 完了フラグを立てておく |