Opened 13 years ago

Closed 12 years ago

#4877 closed defect (fixed)

Eject button on DVD drive disabled

Reported by: Robin Gilks <g8ecj@…> Owned by: Nigel
Priority: minor Milestone: unknown
Component: mythtv Version: 0.21-fixes
Severity: low Keywords:
Cc: Ticket locked: no


Not having played a DVD since Xmas, I'm not sure when this was introduced (and its on my production box so I can't do a binary chop to find the culprit).

Main issue is that the eject button on the DVD drive no longer works. This is a major WAF problem, especially for playing audio CDs.

This wouldn't be so bad but when I navigate to Videos, Eject, the disk is ejected and grabbed straight back again (only one disk scratched so far) for the first 2 times after a frontend restart. After that it is OK (but still no button operation).

I have Autoplay enabled for DVD and Audio CDs, and Monitor and Use New Media both on.

Using r16374 on a Via Epia SP13000 frontend with a 2.6.23 Gentoo kernel

Attachments (6)

mythfrontend.log.1.gz (11.2 KB) - added by Robin Gilks <g8ecj@…> 13 years ago.
-v media log
mythfrontend.log.1.2.gz (3.1 KB) - added by Robin Gilks <g8ecj@…> 13 years ago.
-v media with DVD autoplay off
umount-eject.patch (583 bytes) - added by Nigel 13 years ago.
0-21-fixes patch
CDefficiency.svn.patch (4.0 KB) - added by Nigel 12 years ago.
SVN checkMedia optimisation
CDefficiency.fixes.patch (17.7 KB) - added by Nigel 12 years ago.
0-21 fixes checkMedia optimisation
gallery-eject.patch (1.4 KB) - added by Nigel 12 years ago.
Patch to enable eject in MythGallery 0.21-fixes

Download all attachments as: .zip

Change History (34)

comment:1 Changed 13 years ago by Nigel

Status: newinfoneeded_new

I will need -v media output, and would like to see how turning media monitor off changes the behavior.

comment:2 Changed 13 years ago by Matt S <skd5aner@…>

comment:3 in reply to:  2 Changed 13 years ago by Matt S <skd5aner@…>

Replying to Matt S <>:

Related or dupe of #4205?

Sorry, meant #4025.

comment:4 Changed 13 years ago by skamithi

(In [17446]) Refs #4877. resolves eject dvd button may not work. Noticed that external subtitle code uses an fopen but exits the function without an fclose. if it accesses /dev/sr0 it can cause the dvd eject button to stop working until you restart mythfrontend.

Changed 13 years ago by Robin Gilks <g8ecj@…>

Attachment: mythfrontend.log.1.gz added

-v media log

comment:5 Changed 13 years ago by Robin Gilks <g8ecj@…>

This may be a little too complex a log. The intention was that I'd restart the frontend with a DVD in the drive so it would be detected immediately, then eject and put in a picture CD and eject that and put in an audio CD.

The problem of the tray being closed on its own is now worse - it was doing it every time I used the Video/Eject? navigation to eject the disk. This means that there are several instances of the DVD and Gallery plugins being loaded. Note that to change disks I knocked the disk out during the 1/2 second the tray was open and allowed it to close empty. Bit of a pain not having an eject function in the Gallery plugin...

After removing a DVD it just went back (and stayed) at the main menu whereas removing a picture CD caused it to re-enter the Gallery plugin which then complained about missing media!!

Using the button on the drive only works when the drive is empty or contains an audio CD.

Currently using: $ mythfrontend --version Please include all output in bug reports. MythTV Version : 17639M MythTV Branch : branches/release-0-21-fixes Library API : 0.21.20080304-1 Network Protocol : 40 Options compiled in:

linux release using_oss using_alsa using_backend using_dvb using_frontend using_ivtv using_joystick_menu using_lirc using_v4l using_x11 using_xrandr using_xv using_xvmc using_xvmcw using_xvmc_vld using_bindings_perl using_bindings_python using_opengl using_ffmpeg_threads

with the following modification from the skamithi patch above from trunk: Index: libs/libmythtv/textsubtitleparser.cpp =================================================================== --- libs/libmythtv/textsubtitleparser.cpp (revision 17639) +++ libs/libmythtv/textsubtitleparser.cpp (working copy) @@ -112,7 +112,10 @@

subtitle_t *loaded_subs = sub_read_file(&sub_data); if (!loaded_subs)

  • return false;

+ { + fclose(sub_data.file_ptr); + return false; + }

comment:6 Changed 13 years ago by Robin Gilks <g8ecj@…>


Having restarted the frontend *without* the '-v media' switch I no longer get the tray going back in on its own...

Something to do with my slow CPU (1.3GHz Via Epia) and NFS mounted root filesystem?

comment:7 Changed 13 years ago by Nigel

Thanks for the log. I am still digesting it, but will try making one of my boxes the same version, disabling pmount/punmount, and comparing more exactly.
P.S. You can't easily add an eject button to MythGallery, but you can add it up one level in the main menu?

comment:8 Changed 13 years ago by Nigel

OK, the problem is here:

2008-06-30 18:50:11.775 Posting MediaEvent (MEDIATYPE_DVD, MEDIASTAT_NOTMOUNTED -> MEDIASTAT_OPEN)
2008-06-30 18:50:11.775 MythVideo: Forgetting existing DVD /dev/cdrom
2008-06-30 18:50:11.799 TV: Attempting to change from None to WatchingPreRecorded
libdvdread: Using libdvdcss version 1.2.9 for DVD access
libdvdnav: Using dvdnav version 0.1.10-xine from

The MythVideo? plugin is getting a message to forget about that drive, it says it is forgetting about it, but 10 seconds later something is playing or ripping the DVD.
I assume MythVideo? is set to either Play DVD or Rip DVD on insertion? Try changing it to Do nothing, for now, and if that behaviour differs, please provide -v media logging again.

comment:9 Changed 13 years ago by Robin Gilks <g8ecj@…>

No difference in behaviour with MythVideo? set to 'Do Nothing'. Even after a restart, the frontend still has the drive mounted and a file open for some reason.

# lsof -n | grep hdc mythfront 13032 mythtv 23r BLK 22,0 790 /dev/hdc

# mount /dev/ROOT on / type ext3 (rw,noatime) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec) udev on /dev type tmpfs (rw,nosuid) devpts on /dev/pts type devpts (rw,nosuid,noexec) none on /dev/shm type tmpfs (rw) usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85) securityfs on /sys/kernel/security type securityfs (rw,noexec,nosuid,nodev) zeus:/mnt/videos on /mnt/videos type nfs (rw,rsize=8192,wsize=8192,hard,intr,nfsvers=3,addr= ... /dev/hdc on /mnt/cdrom type udf (ro,noexec,nosuid,nodev,user=mythtv)

comment:10 Changed 13 years ago by Nigel

Well, the frontend will often have the drive open if it is monitoring it. Is it convenient to get the -v media log from just before, and during invoking the eject function?

Changed 13 years ago by Robin Gilks <g8ecj@…>

Attachment: mythfrontend.log.1.2.gz added

-v media with DVD autoplay off

comment:11 Changed 13 years ago by Robin Gilks <g8ecj@…>

Are we on the same page here Nigel? If the drive is mounted then surely the eject button will NEVER work - I am talking about the little plastic button on the drive here, not the menu item that I have to use with the current s/w.

comment:12 Changed 13 years ago by Nigel

Same page? Probably not. I'm in Australia, so I'm looking at the page from Down Under(neath :-)
Adding a setting to allow the hardware button to eject (for DVDs and VCDs) will take a several days for me to play with, but I wanted to explore a problem that your first log showed - for DVDs, when you used the frontend eject function, sometimes it tries to play/rip the disk during the middle of ejection.
Thanks for the second log. It doesn't seem to display that fault. (which is curious, but if it is a timing thing, not unexpected)

Changed 13 years ago by Nigel

Attachment: umount-eject.patch added

0-21-fixes patch

comment:13 Changed 12 years ago by Nigel

(In [18090]) Apply [17446] to fixes. External subtitle code left a file on the DVD open, which can mess with the DVD eject. See #4877.

comment:14 Changed 12 years ago by Nigel

(In [18091]) Once we have worked out that a drive is a DVD or VCD, unmount it so that the physical eject button has more chance or working. Refs #4877

comment:15 Changed 12 years ago by Nigel

That last change has introduced an inefficiency - the unmounted media causes MythCDROMLinux::checkMedia() to always call isMounted(). The state transitions now can jump back from USEABLE to UNMOUNTED. This extra check helps, but it probably needs an extra state?

Index: libs/libmyth/mythcdrom-linux.cpp
--- libs/libmyth/mythcdrom-linux.cpp    (revision 18089)
+++ libs/libmyth/mythcdrom-linux.cpp    (working copy)
@@ -377,11 +377,16 @@
                 VERBOSE(VB_MEDIA, getDevicePath() + " Disk OK, type = "
                                   + MediaTypeString(m_MediaType) );
                 // 1. Audio CDs are not mounted
-                // 2. If we don't know the media type yet,
+                // 2. After we glean their type, DVDs and VCDs are unmounted
+                // 3. If we don't know the media type yet,
                 //    test the disk after this switch exits
                 if (m_MediaType == MEDIATYPE_AUDIO ||
                     m_MediaType == MEDIATYPE_UNKNOWN)
+                if (m_Status == MEDIASTAT_USEABLE &&
+                    (m_MediaType == MEDIATYPE_DVD ||
+                     m_MediaType == MEDIATYPE_VCD) )
+                    break;                 // If we have tried to mount and failed, don't keep trying:
                 if (m_Status == MEDIASTAT_ERROR)                     return m_Status;

Changed 12 years ago by Nigel

Attachment: CDefficiency.svn.patch added

SVN checkMedia optimisation

Changed 12 years ago by Nigel

Attachment: CDefficiency.fixes.patch added

0-21 fixes checkMedia optimisation

comment:16 Changed 12 years ago by Nigel

Robin, if you have time/motivation, feel free to:

cd libs/libmyth
svn revert mythcdrom-linux.cpp
patch < CDefficiency.fixes.patch
make && sudo make install

and observe behaviour when media manually. I'm hoping this might reduce any race conditions (unless there is some other process on the system polling the CD, in which case, I'm stuck, and maybe we need a ps -ef). If anyone else also has time to test, please do!

comment:17 Changed 12 years ago by Robin Gilks <g8ecj@…>

Currently running -fixes r18271 and I have nothing to revert. I've applied the patch anyway and I'll report back on what occurs.

comment:18 Changed 12 years ago by stuartm

Milestone: unknown

Robin, any updates?

comment:19 Changed 12 years ago by Robin Gilks <g8ecj@…>

To recap, the behavior with version r18745 0.21-fixes is as follows:

  • insert DVD, plays OK. ESC to top level menu & press button on drive - ejects OK
  • insert CD, plays OK. ESC to top level menu & press button on drive - ejects OK
  • insert picture CD, plays OK. ESC to top level menu & press button on drive - does not eject.

Use of video submenu Eject menu item ejects disk OK. Reinsert disk and the pictures again display OK. Navigate to video Eject menu item (drive button not operative at top level again) and the drive ejects and then immediately pulls the disk back in. Use Eject menu item and flip disk out before it pulls back in so an empty tray goes in. Gallery complains that it cannot mount /mnt/cdrom

Applied CDefficiency.fixes.patch to r18745 and CD and DVD behavior is the same. Picture CD still won't eject from the drive button having exited Gallery and returned to the top level menu. The pulling back in of the tray no longer occurs so the unable to mount error has gone! At least I can get a picture CD out now using either the video or music Eject menu items.

Any more info I can provide?

comment:20 Changed 12 years ago by Nigel

(In [19114]) CD monitoring efficiency fixes from trunk [19113]. Refs #4877. Basically, don't call unlock() each time the monitoring loop does its checks, and if the disk is useable and unchanged, simplify the status checking.

Changed 12 years ago by Nigel

Attachment: gallery-eject.patch added

Patch to enable eject in MythGallery 0.21-fixes

comment:21 Changed 12 years ago by Nigel

(In [19159]) Add an Eject option to the File Menu. See #4877.

comment:22 Changed 12 years ago by Nigel

I added a new Eject item near the top of the File menu because I think it is more likely to be used than some of the other items :-) Feel free to complain if that is stupid, otherwise I will commit a similar change to fixes next week.

comment:23 Changed 12 years ago by Robin Gilks <g8ecj@…>

So I enter the Gallery, look at a PhotoCD, exit the Gallery plugin and 3 days later I press the eject button on the drive and it doesn't work because the drive is still mounted. I don't 'get' why Gallery can't just unmount the drive when it exits.

comment:24 Changed 12 years ago by Anduin Withers

Component: mythvideomythtv
Owner: changed from Anduin Withers to Isaac Richards
Status: infoneeded_newnew

comment:25 Changed 12 years ago by Anduin Withers

Owner: changed from Isaac Richards to Nigel
Status: newassigned

comment:26 Changed 12 years ago by Anduin Withers

Status: assignedinfoneeded

comment:27 Changed 12 years ago by danielk

Status: infoneededassigned

Looks like this was reflagged as info neede on a ticket ownership change even though the submitter had just replied with additional info.

comment:28 Changed 12 years ago by Nigel

Resolution: fixed
Status: assignedclosed

(In [20581]) Backport [19159] from trunk. Closes #4877 (because I can't work our how to make plugins easily unmount CDs/DVDs after they are finished using them). I'm still working on letting plugins

Note: See TracTickets for help on using tickets.