Music Player Rework | Page 20

Discussion in 'Area 51 - Testing Area' started by hwahrmann, September 15, 2012.

Thread Status:
Not open for further replies.
  1. elliottmc
    • Team MediaPortal

    elliottmc Retired Team Member

    Joined:
    August 7, 2005
    Messages:
    14,927
    Likes Received:
    4,011
    Gender:
    Male
    Location:
    Cardiff, UK
    Ratings:
    +5,503 / 13
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    How separate are the fixes? Is it possible to have individual GIT branches for stuff without WASAPI so we can test and potentially merge that lot, and then have WASAPI merged later (hopefully still 1.4.0)?


     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. seco
    • Team MediaPortal

    seco Development Group

    Joined:
    August 7, 2007
    Messages:
    1,579
    Likes Received:
    897
    Gender:
    Male
    Ratings:
    +1,234 / 4
    Home Country:
    Finland Finland
    Show System Specs
    @hwahrmann

    I started to investigate why Rockstar does not work with these changes.

    1) Bass.Net.dll version has changed so Rockstar fails to load this DLL, this is easy to fix

    2) I can only play one song in Rockstar. When playback is stopped, I cannot play any more songs until MP is restarted. I'm not sure why this is, this could have something to do with Bass.Net.dll changes but do you have any pointers where to look what has changed?

    I don't use Bass.NET stuff from MediaPortal, only direct calls to Bass.BASS* except when playback is started I do:

    Code (Text):
    1. if (BassMusicPlayer.BassFreed)
    2.   BassMusicPlayer.Player.InitBass();
    3.  
    EDIT:

    Calling Bass.BASS_ChannelPlay(currentStream, false) second time gives me:

    BASS: Play() channelPlay() failed: BASS_ERROR_HANDLE

    This has worked fine before so something has changed in Bass.Net..

    If have three different kind of "currentStream":

    a) Bass.BASS_StreamCreate(44100, 2, BASSFlag.BASS_DEFAULT, streamproc, IntPtr.Zero); (Spotify)
    b) Bass.BASS_StreamCreateURL(strFile, 0, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero); (Grooveshark)
    c) Bass.BASS_StreamCreateFile(strFile, 0, 0, BASSFlag.BASS_DEFAULT); (for Local MP3 in MP Music Database)

    Problem is that playback of c) works multiple times, a) and b) only works once. After playback of a) or b) none of a) b) or c) works..
     
    Last edited: April 4, 2013
  4. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,495
    Likes Received:
    1,638
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,264 / 1
    Home Country:
    Austria Austria
    Nope. It is impossible to separate them.
    Either all or nothing.
     
    • Like Like x 1
  5. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,495
    Likes Received:
    1,638
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,264 / 1
    Home Country:
    Austria Austria
    Interesting. There shouldn't be any changes which would cause problems like this. BASS_ERROR_HANDLE simply means that the handle is no longer valid. This could be because you have freed BASS itself or the handle.

    For use case b) and c) you could even use the MP Music Player framework. No need for you to handle that on your own. This would give you the ability to use WASAPI and ASIO.
    Don't know how your streamproc for spotify looks like, guess that is decoding some stuff.

    Is there any chance that i can debug this here?
     
  6. seco
    • Team MediaPortal

    seco Development Group

    Joined:
    August 7, 2007
    Messages:
    1,579
    Likes Received:
    897
    Gender:
    Male
    Ratings:
    +1,234 / 4
    Home Country:
    Finland Finland
    Show System Specs
    Can you spot any obvious problem in this code?

    Code (Text):
    1. namespace Rockstar.Mediaportal
    2. {
    3.     public abstract partial class BassPlayer : IPlayer
    4.     {
    5.         protected static Logger logger = LogManager.GetCurrentClassLogger();
    6.  
    7.         private readonly SYNCPROC PlaybackEndProcDelegate;
    8.  
    9.         private int currentStream;
    10.  
    11.         private string filePath;
    12.  
    13.         public override string CurrentFile
    14.         {
    15.             get { return filePath; }
    16.         }
    17.  
    18.         public override bool Playing
    19.         {
    20.             get { return State == PlayerState.Playing || State == PlayerState.Paused; }
    21.         }
    22.  
    23.         public override bool Stopped
    24.         {
    25.             get { return State == PlayerState.Stopped; }
    26.         }
    27.  
    28.         public override bool Paused
    29.         {
    30.             get { return State == PlayerState.Paused; }
    31.         }
    32.  
    33.         public override bool Initializing
    34.         {
    35.             get { return State == PlayerState.Stopped; }
    36.         }
    37.  
    38.         public override bool SupportsReplay
    39.         {
    40.             // Do not support replay since we use two player instances
    41.             get { return false; }
    42.         }
    43.  
    44.         public override int PlaybackType
    45.         {
    46.             // NORMAL = 0
    47.             get { return 0; }
    48.         }
    49.  
    50.         public override bool IsRadio
    51.         {
    52.             // Do not act as a radio - otherwise TV Clients will go ballistic
    53.             get { return false; }
    54.         }
    55.  
    56.         protected abstract int CreateBassStream(string strFile);
    57.  
    58.         public override bool Play(string strFile)
    59.         {
    60.             filePath = strFile;
    61.  
    62.             // We should initialize if MP has not initialized
    63.             if (BassMusicPlayer.BassFreed)
    64.                 BassMusicPlayer.Player.InitBass();
    65.  
    66.             currentStream = CreateBassStream(strFile);
    67.  
    68.             if (Bass.BASS_ChannelPlay(currentStream, false))
    69.             {
    70.                 RegisterPlaybackEndEvent(currentStream);
    71.  
    72.                 CurrentPlayingItem = CurrentItem;
    73.                 State = PlayerState.Playing;
    74.             }
    75.  
    76.             // Always return true no matter of result
    77.             return true;
    78.         }
    79.  
    80.         public override void Stop()
    81.         {
    82.             if (State == PlayerState.Stopped)
    83.                 return;
    84.  
    85.             goNextTrack = false;
    86.  
    87.             bool stopped = Bass.BASS_ChannelStop(currentStream);
    88.  
    89.             Bass.BASS_StreamFree(currentStream);
    90.  
    91.             if (stopped)
    92.             {
    93.                 State = PlayerState.Stopped;
    94.                 OnPlaybackStopped(CurrentTrack);
    95.             }
    96.  
    97.             if (g_Player.Factory != playerFactory)
    98.             {
    99.                 // Playback is not starting in Rockstar -> stop streaming
    100.                 client.AbortStreaming();
    101.             }
    102.         }
    103.  
    104.         public override void Pause()
    105.         {
    106.             if (State == PlayerState.Stopped)
    107.                 return;
    108.  
    109.             if (State == PlayerState.Paused)
    110.             {
    111.                 State = PlayerState.Playing;
    112.  
    113.                 Bass.BASS_ChannelPlay(currentStream, false);
    114.             }
    115.             else
    116.             {
    117.                 State = PlayerState.Paused;
    118.  
    119.                 Bass.BASS_ChannelPause(currentStream);
    120.             }
    121.         }
    122.  
    123.         public override void Dispose()
    124.         {
    125.             // Do nothing
    126.         }
    127.  
    128.         public override double CurrentPosition
    129.         {
    130.             get
    131.             {
    132.                 if (currentStream == 0)
    133.                 {
    134.                     return 0;
    135.                 }
    136.  
    137.                 return Bass.BASS_ChannelBytes2Seconds(currentStream,
    138.                                                       Bass.BASS_ChannelGetPosition(currentStream));
    139.             }
    140.         }
    141.  
    142.         public override double Duration
    143.         {
    144.             get
    145.             {
    146.                 if (CurrentPlayingItem != null)
    147.                     return CurrentPlayingItem.Track.Length;            
    148.  
    149.                 return base.Duration;
    150.             }
    151.         }
    152.  
    153.         private void PlaybackEndProc(int handle, int stream, int data, IntPtr userData)
    154.         {
    155.             Bass.BASS_ChannelRemoveSync(stream, handle);
    156.  
    157.             OnPlaybackGoNext();
    158.         }
    159.  
    160.         private int RegisterPlaybackEndEvent(int stream)
    161.         {
    162.             return Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END,
    163.                                             0, PlaybackEndProcDelegate, IntPtr.Zero);
    164.         }
    165.     }
    166. }
    167.  
    CreateBassStream creates one of a), b) or c) and I think b) is something that should work out of the box
     
    Last edited: April 4, 2013
  7. sleepycol

    sleepycol Portal Pro

    Joined:
    June 2, 2006
    Messages:
    514
    Likes Received:
    24
    Ratings:
    +33 / 1
    Home Country:
    United Kingdom United Kingdom
    Hi Music Section developers,

    I have mentioned a few times about this issue and I believe it really impacts on the useability of the music player a lot, especially when browsing. It would be nice to know if it is being looked at and if not I will stop mentioning it. I think its a real shame about this sort order problem...

    Could it at least be added to a "to do" list so that the issue doesn't get lost?

    I know you guys do a great job and have lots to do and look at but I just wanted to ask if this will get looked into at some stage?

    Cheers,
    Colin
     
    Last edited: April 4, 2013
  8. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,495
    Likes Received:
    1,638
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,264 / 1
    Home Country:
    Austria Austria
    Hi Colin,

    i fully understand your concerns, but this is the Rework of the Player and has nothing to do with how Songs are displayed n the GUI.
    It is totally unrelated.

    We might look at it in a later stage.

    thanks,

    Helmut
     
  9. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,495
    Likes Received:
    1,638
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,264 / 1
    Home Country:
    Austria Austria
    The code looks absolutely ok. I can't see any problem.
    Only problem could be that for some reason the stream can't be created.

    I guess i would need a Spotify or Groveshark account to debug that. Right?
     
  10. seco
    • Team MediaPortal

    seco Development Group

    Joined:
    August 7, 2007
    Messages:
    1,579
    Likes Received:
    897
    Gender:
    Male
    Ratings:
    +1,234 / 4
    Home Country:
    Finland Finland
    Show System Specs
    Not sure how I should debug this even by myself. The problem should not be specific to my plugin since all is just generic BASS stuff.

    Only thing I can suspect is that BassMusicPlayer.Player.InitBass() has changed so that it has some effect on this. But I should be able to test this by initializing the BASS directly in my plugin instead of InitBass() call. With this test there should be no MP BASS related code used in my plugin at all.
     
  11. seco
    • Team MediaPortal

    seco Development Group

    Joined:
    August 7, 2007
    Messages:
    1,579
    Likes Received:
    897
    Gender:
    Male
    Ratings:
    +1,234 / 4
    Home Country:
    Finland Finland
    Show System Specs
    @hwahrmann

    1) I have pinpointed the code which is causing trouble with Rockstar

    BassAudioEngine.Initialize() calling Bass.BASS_Init(0, 48000, 0, IntPtr.Zero, Guid.Empty)
    BassAudioEngine.InitBass() calling Bass.BASS_Init(0, 48000, 0, IntPtr.Zero, Guid.Empty

    If either of these lines are executed, Rockstar is only able to play one song until MP is restarted. I'm not sure why this is but it would be nice to get this properly fixed.

    EDIT: More progress

    After first playback starts, Bass.BASS_GetDevice() returns "1" which is correct device and everything works fine. But when playback is stopped, GetDevice returns "0" which is the "no sound device" initialized by above and the second playback won't work.

    Then, if I use Bass.BASS_SetDevice(1) before playback, everything works fine. The problem with this is that this is an ugly hack and I don't actually know which device should be used (which device is actually the initialized one).

    I'm not sure why switch to "0 no sound device" is done and where. Also I'm not sure why this no sound device should be initialized at all in MediaPortal?

    2) Current BassAudioEngine code has few glitches
    - Bug: if (Config.SoundDevice == "Default Sound Device") should be "Default DirectSound Device" at least in my system
    - BassRegistration.BassRegistration.Register(); is called twice
    - _initialized = true; is called twice (not sure if this is a bug)
     
    Last edited: April 5, 2013
    • Like Like x 1
Loading...
Thread Status:
Not open for further replies.

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!