[Rejected] MyMusic - album folder openning speed up (1 Viewer)

quba54

Portal Member
November 24, 2007
17
0
Warsaw
Home Country
Poland Poland
When music player is run and entering music folder it took too long time (there is sleep(100ms) for every music file in Pictures.cs).
This sleep was added to give main mediaportal thread more time for processing but in this case main thread calls this method.

This is not good solution for task management - it should be done by changing background threads priority to lower.

I add simple checking if calling thread is "MPMain" and skip waiting in that case.
 

Attachments

  • mymusic.patch
    864 bytes

jameson_uk

Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    The code does look like it needs fixing but could you please clarify where this speeds up loading music folder?

    I had a quick look and only place I could see that this code gets used in music is from CreateThumbnail but that only seems to be called via the album art grabber (which is not called when loading a folder)
     

    quba54

    Portal Member
    November 24, 2007
    17
    0
    Warsaw
    Home Country
    Poland Poland
    All my music files are tagged (I use MPTagThat) with embedded album picture. Every album folder contains also 'folder.jpg'.

    When opening album folder call stack looks like:

    Code:
    >	Core.dll!MediaPortal.Util.Picture.SaveThumbnail(string aThumbTargetPath = "C:\\Users\\Andy\\AppData\\Local\\Temp\\xyz3aeex.1kf", System.Drawing.Image myImage = {System.Drawing.Bitmap}) Line 963 + 0xa bytes	C#
     	Core.dll!MediaPortal.TagReader.Utils.GetImageFile(byte[] imgBytes = {byte[13017]}, string fileSavePath = "C:\\Users\\Andy\\AppData\\Local\\Temp\\xyz3aeex.1kf") Line 593 + 0xb bytes	C#
     	Core.dll!MediaPortal.TagReader.MusicTag.CoverArtFile.get() Line 395 + 0x12 bytes	C#
     	WindowPlugins.dll!MediaPortal.GUI.Music.GUIMusicBaseWindow.GetCoverArt(bool isfolder = false, string filename = "D:\\Muzyka\\VA - Polskie Drogi Rocka (2008) (3CD) [FLAC] [rjk]\\CD 1 - Drogi do wolności\\04 - Perfect - Autobiografia.flac", MediaPortal.TagReader.MusicTag tag = {MediaPortal.TagReader.MusicTag}) Line 954 + 0xa bytes	C#
     	WindowPlugins.dll!MediaPortal.GUI.Music.GUIMusicBaseWindow.OnRetrieveCoverArt(MediaPortal.GUI.Library.GUIListItem item = {MediaPortal.GUI.Library.GUIListItem}) Line 861 + 0x28 bytes	C#
     	WindowPlugins.dll!MediaPortal.GUI.Music.GUIMusicFiles.OnRetrieveCoverArt(MediaPortal.GUI.Library.GUIListItem item = {MediaPortal.GUI.Library.GUIListItem}) Line 950 + 0xb bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIListItem.DoRetrieveArt() Line 579 + 0x11 bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIListItem.HasIcon.get() Line 300 + 0x8 bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIListControl.RenderIcon(float timePassed = 0.0859375, int buttonNr = 4, int x = 282, int y = 246, bool gotFocus = false) Line 485 + 0xa bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIListControl.Render(float timePassed = 0.0859375) Line 1003 + 0x24 bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIControl.DoRender(float timePassed = 0.0859375, uint currentTime = 72241) Line 298 + 0xb bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIFacadeControl.Render(float timePassed = 0.0859375) Line 295 + 0xe bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIControl.DoRender(float timePassed = 0.0859375, uint currentTime = 72241) Line 298 + 0xb bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIGroup.Render(float timePassed = 0.0859375) Line 99 + 0xe bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIControl.DoRender(float timePassed = 0.0859375, uint currentTime = 72241) Line 298 + 0xb bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIWindow.Render(float timePassed = 0.0859375) Line 1330 + 0xe bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUIWindowManager.Render(float timePassed = 0.0859375) Line 1235 + 0xe bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUILayerRenderer.RenderLayer(float timePassed = 0.0859375) Line 41 + 0x8 bytes	C#
     	Core.dll!MediaPortal.GUI.Library.GUILayerManager.Render(float timePassed = 0.0859375) Line 97 + 0x26 bytes	C#
     	MediaPortal.exe!MediaPortalApp.Render(float timePassed = 0.0859375) Line 1985 + 0x8 bytes	C#
     	MediaPortal.exe!MediaPortal.D3DApp.FullRender() Line 1453 + 0x28 bytes	C#
     	MediaPortal.exe!MediaPortal.D3DApp.Application_Idle(object sender = {System.Threading.Thread}, System.EventArgs e = {System.EventArgs}) Line 2774 + 0x8 bytes	C#

    Maybe I have something wrong configured in music database but as you can see there is possibility to call SaveThumbnail() from main thread which causes waiting 100ms for every file in folder. So this piece of code requires fixing for instance as I did in patch or by changing background thread priorities and removing this "sleeps".
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    Thanks, I will look at this later (probably tomorrow morning)

    just to clarify are you browsing in database views or shares (or is it the same stack with both ?)
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    The problem is that we should not be loading thumbs in the main thread and a little careless coding on my part has caused this tpo happen. I will change the code that loads embedded artwork so it does not cause this problem.

    Thanks for highlighting the issue but I will mark the patch as rejected as I will sort this issue in a different way.
     

    Users who are viewing this thread

    Top Bottom