1.14.0 ACTION_EJECTCD doesn't work (1 Viewer)

tony72

MP Donator
  • Premium Supporter
  • August 15, 2009
    180
    61
    Home Country
    England England
    MediaPortal 1.14 Final. I have an HP MCE remote, and have the Use generic HID device" option ticked. Via the remote->HID->Mapping GUI, I mapped the "Eject" button on the remote to the "Ejectcd" action. It does not work, as in I cannot eject a disc or open the drive tray by pressing the eject button.

    I know the button works, because I can map it to other actions, and they work.

    I know that the drive works, and can be ejected by software, because in MediaPortal I can go to Videos, select the disc, and eject it via the context menu.

    So by elimination, there seems to be a problem with the Ejectcd action itself, or the way it is handled.

    As I recall, this was discussed in the forums, and the general consensus was that this action used to work, but stopped working in some previous version, so it is probably not a new bug.

    In the period of the attached logs, I started MediaPortal, pressed the Eject button a few times to try to open the drive, then manually opened the drive, inserted a disc, played and then stopped it, then pressed eject a few more times, then exited MediaPortal with the disc still inserted.
     

    Attachments

    • Generic-HID.xml
      18.6 KB

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Hi

    First, thanks for the report.
    Could you please collect log files again, but this time enable the "extended logging" option in MP Configuration -> remotes and input devices section -> HID tab. Without that option enabled, the log files don't show which buttons you press.

    Regards,
    mm
     

    tony72

    MP Donator
  • Premium Supporter
  • August 15, 2009
    180
    61
    Home Country
    England England
    Thanks for the reply. Sure thing, sorry I didn't notice that option before; new log files are attached with HID extended logging enabled. I had mad a mistake in the mapping yesterday which would have muddied the waters anyway, so I've attached today's mappings also. The logs were collected with the same sequence of events as before.
     

    Attachments

    • Generic-HID.xml
      18.7 KB

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Right, so according to the log files your eject button is generating the following entries:
    [2016-05-21 12:11:43,181] [Log ] [MPMain ] [INFO ] - HID: try mapping usage 0034

    0034 is the code, which can also be written as 0x34.
    Based on this the name of the code is Ext2:
    https://sharplibhid.codeplex.com/SourceControl/latest#Hid/HidUsageTables.cs
    Code:
                /// <summary>
                /// First press action: Generates EXTn HID message in the Media Center Vendor Specific
                /// Collection (page 0xFFBC, usage 0x88).
                /// <para />
                /// Second press action: Repeats message.
                /// <para />
                /// Auto-repeat: No
                /// <para />
                /// Notably sent by the 'Eject' button of HP Windows Media Center Remote (TSGH-IR08).
                /// Also interpreted as 'Eject' action by SoundGraph iMON Manager in MCE mode (OrigenAE VF310).
                /// </summary>
                Ext2 = 0x34,

    In MediaPortal's HID mapping it's known as "HpEject":
    https://github.com/MediaPortal/Medi...ults/InputDeviceMappings/Generic-HID.xml#L281
    Code:
    <button name="HpEject" code="Ext2" />

    ...not the standard eject as you might expect. I think that's due to the type of remote you have.
    If you map "HpEject" to the eject action then your remote eject button should start working.
     

    tony72

    MP Donator
  • Premium Supporter
  • August 15, 2009
    180
    61
    Home Country
    England England
    Thanks, but unfortunately that's not the case. I had already figured out that I should be using HpEject (that was the mapping error I alluded to with yesterday's test, I should have spelled that out), and that's the button I mapped the Ejectcd action to today, but it still doesn't work. I also subsequently tried mapping Ejectcd to other unambiguous buttons, and it still doesn't work. So there definitely seems to be a problem with the action itself.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Okay, thanks guys. Looking at the code, this may have been broken since 2013. :eek::oops::whistle:
    Please try the attached patch with both your remote and the eject/load context menu entries.
     

    Attachments

    • Core [1.14 fix eject].zip
      1 MB

    CyberSimian

    Test Group
  • Team MediaPortal
  • June 10, 2013
    2,849
    1,771
    Southampton
    Home Country
    United Kingdom United Kingdom
    Please try the attached patch with both your remote and the eject/load context menu entries.
    I have downloaded the fix and tested it, but I am not sure how relevant my results are. I used my WMC RC6 remote, with the "Aspect Ratio" button defined to perform the EJECTCD function.

    My production system is MP 1.12, and as only one DLL is affected, I thought that I would try the fix on MP 1.12. Unfortunately, MP refused to start (the log file shows a missing reference).

    My test partition currently has MP 1.15 pre with Stéphane's changes for the consolidated HID. I installed the modified DLL on that. These are the results:

    (1) MP would not display my "Videos" folders -- the panel was empty. Since that is where I expected to see the entry for the CD/DVD drive, that was a non-starter. :(

    (2) I then tried the "Music" section, and that did list both the CD/DVD drive and my "Music" folder. So I tested there. :)

    (3) With an empty CD drive, the EJECT button on my remote would open the CD drawer :), but not close it. :(

    (4) With an empty CD drive, the context menu item would close the CD drawer :), but not open it. :(

    (5) With a CD loaded but not playing, the context menu item would open the CD drawer and close it. :) However, it resulted in the list of entries on the panel being duplicated, so that I ended up with the following (where "O:" is my optical drive):

    (O: ) CD/DVD
    Music
    (O: ) CD/DVD
    Music

    So, some success, but the incorrect behaviour might be due to some mismatch between the fix (for MP 1.14) and my test system (MP 1.15). :unsure:

    -- from CyberSimian in the UK
     

    tony72

    MP Donator
  • Premium Supporter
  • August 15, 2009
    180
    61
    Home Country
    England England
    I just tested the patch; on my system it seems to work, as in both the eject button on the remote and the "Eject" context menu item in Videos now eject the drive tray (y). Thanks!

    I didn't recall that the Ejectcd action ever did close the tray if it's open, I think I could only ever eject the tray via the remote, so it didn't cross my mind to test that until I saw the post above. It doesn't, if that's an issue. There does seem to be a slight inconsistency with the context menus; as CyberSimian says, in Music, the Eject context menu item will indeed close the tray if its open, but in Videos it does not.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Thanks for testing guys, and for your detailed reports - much appreciated. (y)

    Let me try to cover off all of the points you've raised. Apologies in advance for the length. Please bear with me.

    I used my WMC RC6 remote, with the "Aspect Ratio" button defined to perform the EJECTCD function.
    That's fine.

    My production system is MP 1.12, and as only one DLL is affected, I thought that I would try the fix on MP 1.12. Unfortunately, MP refused to start (the log file shows a missing reference).
    Yeah, that DLL won't work with 1.12 - sorry. I knew choosing the right version to build would be a bit of a trick. For myself, I still have MP 1.7.1 so I currently can't test anything I build either.

    My test partition currently has MP 1.15 pre with Stéphane's changes for the consolidated HID. I installed the modified DLL on that. These are the results:

    (1) MP would not display my "Videos" folders -- the panel was empty. Since that is where I expected to see the entry for the CD/DVD drive, that was a non-starter. :(
    I think this may well be a side-effect of the mismatching builds. 1.15 PR would be close enough to 1.14 in most cases, though some things may not work. The addition of Stéphane's changes throws an extra spanner in the works. I'll see if I can build a 1.12 version for your production system, and maybe throw in a 1.15 PR version as optional. I won't be able to include Stéphane's changes - too time consuming.

    (3) With an empty CD drive, the EJECT button on my remote would open the CD drawer :), but not close it. :(
    From the code, this is expected:
    https://github.com/MediaPortal/Medi.../MediaPortal.Application/MediaPortal.cs#L4170

    Please be aware that it's difficult if not impossible to detect the difference between empty drive and open tray. Thus writing logic to always open and close the tray appropriately with only one button is tricky... and that's not even considering drives that don't even have a tray. It may be possible to implement some kind of improvement in future but for me and for now I'm strictly limiting scope to fixing bugs without causing any regressions.

    (4) With an empty CD drive, the context menu item would close the CD drawer :), but not open it. :(
    I confirm that I can reproduce with MP 1.7.1. <sigh> :(
    The relevant code:
    Code:
    case 654: // Eject
      if (item != null && Util.Utils.getDriveType(item.Path) != 5)
      {
        Util.Utils.EjectCDROM();
      }
      else
      {
        if (item != null && item.Path != null)
        {
          var driveInfo = new DriveInfo(Path.GetPathRoot(item.Path));
    
          if (!driveInfo.IsReady)
          {
            Util.Utils.CloseCDROM(Path.GetPathRoot(item.Path));
          }
          else
          {
            Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
          }
        }
      }
      LoadDirectory(string.Empty);

    First clause says if the drive is not a CD/DVD/BR drive (removable USB???), just eject [the first/default CD/DVD/BR drive]. To be honest this makes no sense to me, but what the hey. Maybe's it's catch-all code.
    The second clause is the relevant clause. It says: if a disc is not loaded in the drive (ie. tray is open OR tray is closed with no disc), close the tray... but if a disc is loaded, eject it.

    Obviously the first part of the second clause is the problem. Once again it comes down to the fact that it's difficult/impossible to distinguish between those two scenarios. Quite frankly though, I don't understand why there needs to be any logic there in the first place. The person has selected the "eject" menu item. Therefore shouldn't MP just open the tray? Any objections or flaws in my logic?

    P.S.: the same bug applies to the pictures plugin/section, but the video plugin/section does exactly what I have proposed. Yay for code duplication and people that don't check all the similar code when they fix bugs! :(

    (5) With a CD loaded but not playing, the context menu item would open the CD drawer and close it. :)
    This is the expected result given the dissection above. However as previously indicated, due to the difficulty in distinguishing closed empty tray from open tray, I think we should modify this so that eject only ejects and load only loads. It would be nice to be smart, but functional is the ultimate priority.

    However, it resulted in the list of entries on the panel being duplicated, so that I ended up with the following (where "O:" is my optical drive):

    (O: ) CD/DVD
    Music
    (O: ) CD/DVD
    Music

    So, some success, but the incorrect behaviour might be due to some mismatch between the fix (for MP 1.14) and my test system (MP 1.15). :unsure:
    Hmmm, I can't reproduce with 1.7.1.
    Using either the load or eject ( :rolleyes: ) menu items to close the tray containing an audio CD does not give me duplicates. Furthermore, when the tray is closed, my item text changes from "(Z:) CD/DVD" to "(Z:) Audio CD". That's with shares view in the music section.
    Can you reproduce this @tony72 ?

    I just tested the patch; on my system it seems to work, as in both the eject button on the remote and the "Eject" context menu item in Videos now eject the drive tray (y). Thanks!
    You're very welcome, but really it should be me thanking you and CyberSimian for bringing this to our attention and taking the time to test the fix. Again, it's very much appreciated. :notworthy:

    I didn't recall that the Ejectcd action ever did close the tray if it's open, I think I could only ever eject the tray via the remote, so it didn't cross my mind to test that until I saw the post above. It doesn't, if that's an issue. There does seem to be a slight inconsistency with the context menus; as CyberSimian says, in Music, the Eject context menu item will indeed close the tray if its open, but in Videos it does not.
    I think my comments above should cover both of these points. Briefly:
    1. Your memory is correct. The eject button has never closed the tray, and I don't intend to change that.
    2. I think we should fix the inconsistency with the context menu by having the "eject" item only eject/open... and that would solve the problem of not being able to open an empty drive using the context menu.

    Hopefully I've answered all the questions. All that remains to be mentioned are the attached patches for 1.12, 1.14 and 1.15 PR. Please test as you're able, and be sure to cover the videos, music and pictures sections. As far as I can tell those are all the places that use the same eject/load functions.
     

    Attachments

    • 1.15 PR eject fixes v2.zip
      1.1 MB
    • 1.12 eject fixes v2.zip
      1.1 MB
    • 1.14 eject fixes v2.zip
      1.1 MB

    Users who are viewing this thread

    Top Bottom