Ticket #7212: 7212-v1.patch
File 7212-v1.patch, 2.8 KB (added by , 16 years ago) |
---|
-
mythvideo/mtd/dvdprobe.cpp
47 47 } 48 48 } 49 49 50 #define LOC_ERR QString("dvdprobe.cpp, Error: ") 51 #define LOC_WARN QString("dvdprobe.cpp, Warning: ") 52 #define LOC QString("dvdprobe.cpp: ") 53 50 54 DVDSubTitle::DVDSubTitle(int subtitle_id, const QString &a_language) : 51 55 id(subtitle_id), language(a_language.toUtf8()) 52 56 { … … 431 435 // Before touching libdvdread stuff 432 436 // (below), see if there's actually 433 437 // a drive with media in it 434 QFile dvdDevice(device);435 if (!dvdDevice.exists())436 438 { 437 // Device doesn't exist. Silly user 438 Reset(); 439 return false; 439 QFile dvdDevice(device); 440 if (!dvdDevice.exists()) 441 { 442 // Device doesn't exist. Silly user 443 Reset(); 444 return false; 445 } 440 446 } 441 447 442 if (!dvdDevice.open(QIODevice::ReadOnly)) 448 // On UNIX like file systems O_NONBLOCK should be used to 449 // indicate we don't want to do reading or writing, we 450 // just want to issue some ioctls. This will prevent the 451 // OS from helping out and shearing the fingers off any 452 // person's attempting to place a DVD in the drive when 453 // we call open. 454 int flags = O_RDONLY; 455 #ifdef O_NONBLOCK 456 flags |= O_NONBLOCK; 457 #endif 458 459 // Ideally we can open with exclusive flag. 460 #ifdef O_EXCL 461 flags |= O_EXCL; 462 #endif 463 464 int drive_handle = open(device.toLocal8Bit().constData(), flags); 465 466 #ifdef O_EXCL 467 // If this failed with exclusive, try without. 468 if (drive_handle < 0) 443 469 { 444 // Can't open device. 445 Reset(); 446 return false; 470 flags &= ~O_EXCL; 471 drive_handle = open(device.toLocal8Bit().constData(), flags); 447 472 } 473 #endif 448 474 449 int drive_handle = dvdDevice.handle(); 450 451 if (drive_handle == -1) 475 if (drive_handle < 0) 452 476 { 477 VERBOSE(VB_IMPORTANT, LOC + 478 "Failed to open file descriptor for DVD." + ENO); 453 479 Reset(); 454 480 return false; 455 481 } … … 470 496 if (status < 0) 471 497 { 472 498 Reset(); 499 close(drive_handle); 473 500 return false; 474 501 } 475 502 … … 483 510 // 3 = not ready 484 511 // 485 512 Reset(); 513 close(drive_handle); 486 514 return false; 487 515 } 488 516 … … 493 521 // the disc has not changed. but if this is our 494 522 // first time running, we still need to check it 495 523 // so return whatever we returned before 524 close(drive_handle); 496 525 return titles.size(); 497 526 } 498 527 #endif 499 528 500 dvdDevice.close(); 529 close(drive_handle); 530 drive_handle = -1; 501 531 502 532 // 503 533 // Try to open the disc