Mercurial > epgrec.yaz
comparison Reservation.class.php @ 161:84220382fea8
mod: 録画中のキャンセルを可能にした(動作確認、まだ不完全かも)
author | epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp> |
---|---|
date | Sun, 04 Apr 2010 17:10:17 +0900 |
parents | 5b192e94f49d |
children | 3d4df1fe4166 e379552d084c |
comparison
equal
deleted
inserted
replaced
157:00b5ed67d792 | 161:84220382fea8 |
---|---|
2 include_once('config.php'); | 2 include_once('config.php'); |
3 include_once( INSTALL_PATH . "/DBRecord.class.php" ); | 3 include_once( INSTALL_PATH . "/DBRecord.class.php" ); |
4 include_once( INSTALL_PATH . "/reclib.php" ); | 4 include_once( INSTALL_PATH . "/reclib.php" ); |
5 include_once( INSTALL_PATH . "/Settings.class.php" ); | 5 include_once( INSTALL_PATH . "/Settings.class.php" ); |
6 include_once( INSTALL_PATH . "/recLog.inc.php" ); | 6 include_once( INSTALL_PATH . "/recLog.inc.php" ); |
7 | |
8 // 緇剛 | |
9 if( !defined( "RECORDER_CMD" ) ) { | |
10 define( "RECORDER_CMD", INSTALL_PATH."/recorder.php" ); | |
11 } | |
7 | 12 |
8 | 13 |
9 // 篋膣 | 14 // 篋膣 |
10 | 15 |
11 class Reservation { | 16 class Reservation { |
286 ); | 291 ); |
287 | 292 |
288 // ATт膣 | 293 // ATт膣 |
289 $process = proc_open( $cmdline , $descriptor, $pipes, INSTALL_PATH.$settings->spool, $env ); | 294 $process = proc_open( $cmdline , $descriptor, $pipes, INSTALL_PATH.$settings->spool, $env ); |
290 if( is_resource( $process ) ) { | 295 if( is_resource( $process ) ) { |
291 fwrite($pipes[0], $settings->sleep." ".$sleep_time."\n" ); | 296 fwrite($pipes[0], RECORDER_CMD." ".$rrec->id."\n" ); |
292 fwrite($pipes[0], DO_RECORD . "\n" ); | |
293 fwrite($pipes[0], COMPLETE_CMD." ".$rrec->id."\n" ); | |
294 if( $settings->use_thumbs == 1 ) { | |
295 fwrite($pipes[0], $gen_thumbnail."\n" ); | |
296 } | |
297 fclose($pipes[0]); | 297 fclose($pipes[0]); |
298 // 罔羣若 | 298 // 罔羣若 |
299 $rstring = stream_get_contents( $pipes[2]); | 299 $rstring = stream_get_contents($pipes[2]); |
300 | 300 |
301 fclose( $pipes[2] ); | 301 fclose( $pipes[2] ); |
302 fclose( $pipes[1] ); | |
302 proc_close( $process ); | 303 proc_close( $process ); |
303 } | 304 } |
304 else { | 305 else { |
305 $rrec->delete(); | 306 $rrec->delete(); |
306 reclog( "Reservation::custom at絎茵紊掩罔≧", EPGREC_ERROR); | 307 reclog( "Reservation::custom at絎茵紊掩罔≧", EPGREC_ERROR); |
352 } | 353 } |
353 if( $rec == null ) { | 354 if( $rec == null ) { |
354 throw new Exception("ID絎≦鴻с"); | 355 throw new Exception("ID絎≦鴻с"); |
355 } | 356 } |
356 if( ! $rec->complete ) { | 357 if( ! $rec->complete ) { |
357 // 絎茵篋膣с | |
358 if( toTimestamp($rec->starttime) < (time() + PADDING_TIME + $settings->former_time) ) { | 358 if( toTimestamp($rec->starttime) < (time() + PADDING_TIME + $settings->former_time) ) { |
359 reclog("Reservation::cancel 絎茵篋膣羔絎茵", EPGREC_ERROR ); | 359 reclog("Reservation::cancel 絎茵筝篋膣ID".$rec->id."羔絎茵" ); |
360 throw new Exception("絎茵篋膣с"); | 360 |
361 } | 361 // recorder篆<荅帥 |
362 exec( $settings->atrm . " " . $rec->job ); | 362 $ipc_key = ftok( RECORDER_CMD, "R" ); |
363 reclog("Reservation::cancel 吾с".$rec->job.""); | 363 |
364 } | 364 /* php 5.3篁ラmsg_queue_exists篏帥 |
365 $rec->delete(); | 365 if( ! msg_queue_exists( $ipc_key ) ) { |
366 // <祉若吾ャ若 | |
367 reclog( "Reservation::cancel 絎茵筝ィ羝篋膣".$rec->id."絎茵", EPGREC_ERROR ); | |
368 $rec->complete = 1; | |
369 throw new RecException( "Reserve:: 絎茵筝ィ羝篋膣絎茵障綺ゃ荅帥", EPGREC_ERROR ); | |
370 } | |
371 else { | |
372 */ | |
373 $msgh_r = msg_get_queue( $ipc_key ); | |
374 $ipc_key = ftok( RECORDER_CMD, "W" ); | |
375 $msgh_w = msg_get_queue( $ipc_key ); | |
376 | |
377 // 腟篋腓 | |
378 msg_send( $msgh_r, (int)$rec->id, "terminate" ); | |
379 sleep(1); | |
380 for( $i = 0; $i < 60; $i++ ) { | |
381 $r = msg_receive($msgh_w, (int)$rec->id , $msgtype, 1024, $message, TRUE, MSG_IPC_NOWAIT | MSG_NOERROR); | |
382 if( $r ) { | |
383 if( $message == "success" ) { | |
384 reclog( "Reserve:: 絎茵筝篋膣ID".$rec->id."羔罔≧" ); | |
385 break; | |
386 } | |
387 else if( $message == "error" ){ | |
388 reclog( "Reserve:: 絎茵筝篋膣ID".$rec->id."羔紊掩", EPGREC_ERROR ); | |
389 throw new RecException("絎茵筝篋膣羔紊掩障違綺羔", EPGREC_ERROR ); | |
390 } | |
391 // 篁ュ<祉若吾∴緇 | |
392 } | |
393 sleep(1); | |
394 } | |
395 if( $i >= 60 ) throw new RecException("絎茵筝篋膣羔紊掩障違綺羔", EPGREC_ERROR ); | |
396 // } | |
397 } | |
398 else { | |
399 // 障絎茵篋膣atゃ | |
400 exec( $settings->atrm . " " . $rec->job ); | |
401 reclog("Reservation::cancel 吾с".$rec->job.""); | |
402 $rec->delete(); | |
403 } | |
404 } | |
405 else { | |
406 // 牙紙推膣羔 | |
407 $rec->delete(); | |
408 } | |
366 } | 409 } |
367 catch( Exception $e ) { | 410 catch( Exception $e ) { |
368 reclog("Reservation::cancel 篋膣c潟祉DB・膓障≪祉鴻紊掩罔≧", EPGREC_ERROR ); | 411 reclog("Reservation::cancel 篋膣c潟祉DB・膓障≪祉鴻紊掩罔≧", EPGREC_ERROR ); |
369 throw $e; | 412 throw $e; |
370 } | 413 } |