Guest User

Fixing play optical disk entry (#10340)

a guest
Feb 20th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.39 KB | None | 0 0
  1. diff --git a/mythtv/libs/libmythtv/bdringbuffer.cpp b/mythtv/libs/libmythtv/bdringbuffer.cpp
  2. index 8028527..142e352 100644
  3. --- a/mythtv/libs/libmythtv/bdringbuffer.cpp
  4. +++ b/mythtv/libs/libmythtv/bdringbuffer.cpp
  5. @@ -272,8 +272,15 @@ void BDRingBuffer::ProgressUpdate(void)
  6.  
  7. bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
  8. {
  9. - safefilename = lfilename;
  10. - filename = lfilename;
  11. + // clean path filename
  12. + QString filename = QDir(QDir::cleanPath(lfilename)).canonicalPath();
  13. + if (filename.isEmpty())
  14. + {
  15. + LOG(VB_GENERAL, LOG_ERR, LOC +
  16. + QString("%1 nonexistent").arg(lfilename));
  17. + filename = lfilename;
  18. + }
  19. + safefilename = filename;
  20.  
  21. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Opened BDRingBuffer device at %1")
  22. .arg(filename.toLatin1().data()));
  23. diff --git a/mythtv/libs/libmythtv/ringbuffer.cpp b/mythtv/libs/libmythtv/ringbuffer.cpp
  24. index 6940300..7ca602d 100644
  25. --- a/mythtv/libs/libmythtv/ringbuffer.cpp
  26. +++ b/mythtv/libs/libmythtv/ringbuffer.cpp
  27. @@ -113,6 +113,7 @@ RingBuffer *RingBuffer::Create(
  28. bool dvdurl = lower.startsWith("dvd:");
  29. bool dvdext = lower.endsWith(".img") || lower.endsWith(".iso");
  30.  
  31. + LOG(VB_GENERAL, LOG_ERR, QString("filename2 =%1").arg(xfilename));
  32. if (httpurl)
  33. return new StreamingRingBuffer(lfilename);
  34.  
  35. @@ -154,11 +155,10 @@ RingBuffer *RingBuffer::Create(
  36. }
  37. else if (!stream_only && (bdurl || bddir))
  38. {
  39. - if (lfilename.left(5) == "bd://") // 'Play DVD' sends "bd:/" + dev
  40. - lfilename.remove(0,4); // e.g. "bd://dev/sda"
  41. - else if (lfilename.left(4) == "bd:/") // Less correct URI "bd:" + path
  42. + if (lfilename.left(3) == "bd:") // Less correct URI "bd:" + path
  43. lfilename.remove(0,3); // e.g. "bd:/videos/ET"
  44.  
  45. + LOG(VB_GENERAL, LOG_ERR, QString("lfilename =%1").arg(lfilename));
  46. if (mythurl || QFile::exists(lfilename))
  47. LOG(VB_PLAYBACK, LOG_INFO, "Trying BD at " + lfilename);
  48. else
  49. diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp
  50. index da7e267..8b67945 100644
  51. --- a/mythtv/programs/mythfrontend/main.cpp
  52. +++ b/mythtv/programs/mythfrontend/main.cpp
  53. @@ -655,89 +655,84 @@ static void jumpScreenVideoDefault() { RunVideoScreen(VideoDialog::DLG_DEFAULT,
  54.  
  55. QString gDVDdevice;
  56.  
  57. +static QString preparePlayCommand(QString command, QString replacement)
  58. +{
  59. + if ((command.indexOf("internal", 0, Qt::CaseInsensitive) > -1) ||
  60. + (command.length() < 1))
  61. + {
  62. + return "Internal";
  63. + }
  64. + if (command.contains("%d"))
  65. + {
  66. + //
  67. + // Need to do device substitution
  68. + //
  69. + command.replace(QRegExp("%d"), replacement);
  70. + }
  71. + return command;
  72. +}
  73. +
  74. static void playDisc()
  75. {
  76. //
  77. - // Get the command string to play a DVD
  78. + // Get the command string to play a DVD / BluRay
  79. //
  80.  
  81. - bool isBD = false;
  82. + QString dvd_device = gDVDdevice;
  83. + QString bd_device = QDir(
  84. + QDir::cleanPath(gCoreContext->GetSetting("BluRayMountpoint",
  85. + "/media/cdrom")))
  86. + .canonicalPath();
  87. + QDir bdtest(bd_device + "/BDMV");
  88.  
  89. - QString command_string =
  90. - gCoreContext->GetSetting("mythdvd.DVDPlayerCommand");
  91. - QString bluray_mountpoint =
  92. - gCoreContext->GetSetting("BluRayMountpoint", "/media/cdrom");
  93. - QDir bdtest(bluray_mountpoint + "/BDMV");
  94. + bool isBD = QDir(bd_device + "/BDMV").exists();
  95.  
  96. - if (bdtest.exists())
  97. - isBD = true;
  98. + if (dvd_device.isEmpty())
  99. + dvd_device = MediaMonitor::defaultDVDdevice();
  100. + if (!isBD && dvd_device.isEmpty())
  101. + return; // User cancelled in the Popup
  102.  
  103. - if (isBD)
  104. - {
  105. - GetMythUI()->AddCurrentLocation("playdisc");
  106. -
  107. - QString filename = QString("bd:/%1/").arg(bluray_mountpoint);
  108. + QString filename = isBD ? QString("bd:%1").arg(bd_device) : dvd_device;
  109. + QString command_string =
  110. + preparePlayCommand(gCoreContext->GetSetting("mythdvd.DVDPlayerCommand"),
  111. + filename);
  112.  
  113. - GetMythMainWindow()->HandleMedia("Internal", filename, "", "", "", "",
  114. - 0, 0, "", 0, "", "", true);
  115. + GetMythUI()->AddCurrentLocation("playdisc");
  116.  
  117. - GetMythUI()->RemoveCurrentLocation();
  118. - }
  119. - else
  120. + if (command_string == "Internal")
  121. {
  122. - QString dvd_device = gDVDdevice;
  123. -
  124. - if (dvd_device.isEmpty())
  125. - dvd_device = MediaMonitor::defaultDVDdevice();
  126. -
  127. - if (dvd_device.isEmpty())
  128. - return; // User cancelled in the Popup
  129. -
  130. - GetMythUI()->AddCurrentLocation("playdisc");
  131. -
  132. - if ((command_string.indexOf("internal", 0, Qt::CaseInsensitive) > -1) ||
  133. - (command_string.length() < 1))
  134. + if (!isBD)
  135. {
  136. #ifdef Q_OS_MAC
  137. // Convert a BSD 'leaf' name into a raw device path
  138. - QString filename = "dvd://dev/r"; // e.g. 'dvd://dev/rdisk2'
  139. + QString prefix = "dvd://dev/r"; // e.g. 'dvd://dev/rdisk2'
  140. #elif USING_MINGW
  141. - QString filename = "dvd:"; // e.g. 'dvd:E\\'
  142. + QString prefix = "dvd:"; // e.g. 'dvd:E\\'
  143. #else
  144. - QString filename = "dvd:/"; // e.g. 'dvd://dev/sda'
  145. + QString prefix = "dvd:/"; // e.g. 'dvd://dev/sda'
  146. #endif
  147. - filename += dvd_device;
  148. -
  149. - command_string = "Internal";
  150. - GetMythMainWindow()->HandleMedia(command_string, filename, "", "",
  151. - "", "", 0, 0, "", 0, "", "", true);
  152. - GetMythUI()->RemoveCurrentLocation();
  153. -
  154. - return;
  155. + filename = prefix + filename;
  156. }
  157. - else
  158. +
  159. + GetMythMainWindow()->HandleMedia("Internal", filename, "", "", "", "",
  160. + 0, 0, "", 0, "", "", true);
  161. + }
  162. + else
  163. + {
  164. + LOG(VB_MEDIA, LOG_INFO, QString("Called external command %1")
  165. + .arg(command_string));
  166. + sendPlaybackStart();
  167. + myth_system(command_string);
  168. + sendPlaybackEnd();
  169. + if (GetMythMainWindow())
  170. {
  171. - if (command_string.contains("%d"))
  172. - {
  173. - //
  174. - // Need to do device substitution
  175. - //
  176. - command_string =
  177. - command_string.replace(QRegExp("%d"), dvd_device);
  178. - }
  179. - sendPlaybackStart();
  180. - myth_system(command_string);
  181. - sendPlaybackEnd();
  182. - if (GetMythMainWindow())
  183. - {
  184. - GetMythMainWindow()->raise();
  185. - GetMythMainWindow()->activateWindow();
  186. - if (GetMythMainWindow()->currentWidget())
  187. - GetMythMainWindow()->currentWidget()->setFocus();
  188. - }
  189. + GetMythMainWindow()->raise();
  190. + GetMythMainWindow()->activateWindow();
  191. + if (GetMythMainWindow()->currentWidget())
  192. + GetMythMainWindow()->currentWidget()->setFocus();
  193. }
  194. - GetMythUI()->RemoveCurrentLocation();
  195. }
  196. + GetMythUI()->RemoveCurrentLocation();
  197. }
  198.  
  199. /////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment