BassPlayer: Adding WASAPI support (1 Viewer)

hwahrmann

Development Group
  • Team MediaPortal
  • September 15, 2004
    4,542
    2,333
    Vienna, Austria
    Austria Austria
    Country flag
    @BassFan @hwahrmann I still fighting an issue with the Mixer in shared mode. While in all other cases the stream end is handled correctly (DirectSound, WASAPI exclusive), the shared mode doesn't seem stop playback.
    I tried to attach handlers for Stream end like:
    Bass.BASS_ChannelSetSync(stream.Handle, BASSSync.BASS_SYNC_FREE | BASSSync.BASS_SYNC_MIXTIME, 0, OnPlaybackEnd,...
    But this doesn't work in current code: no callback happens and mixer will be read after finish. How do I get noticed of playback end in this case?
    A Mixer stream is always active, unless you initalize it to stop, when nothing is fed into it.
    So when you add a song to the mixer you need to set a SyncPos to "current mixer position + length of song just added".
    This will then signal and you know that the song has ended, and you can add the next siong from the playlistz or stop playback, if it was the last song.

    THat's the SetSyncPos in MP1 MixerStream.cs line 385
     

    hwahrmann

    Development Group
  • Team MediaPortal
  • September 15, 2004
    4,542
    2,333
    Vienna, Austria
    Austria Austria
    Country flag
    Helios61 said: ↑
    1. Multichannel files with samplingrate >48 KHz will be resampled to 48 KHz. It's odd, playback of 2ch/24bit/96KHz is working fine! Log is attached (Client.rar).
    I have same result here: although bass tells me this is a supported format, Init() call will fail Then it switches back to shared mode.
    [2014-03-29 08:35:19,668] [26701 ] [BassPlay ] [DEBUG] - BassPlayer: BASS: Try to init WASAPI with a samplerate of 96000 and 6 channels
    [2014-03-29 08:35:19,677] [26710 ] [BassPlay ] [WARN ] - BassPlayer: BASS: Failed to initialize WASAPI exclusive mode for samplerate of 96000 and 6 channels. Trying fallback to shared mode.
    [2014-03-29 08:35:19,677] [26710 ] [BassPlay ] [DEBUG] - BassPlayer: BASS: Init WASAPI shared mode with Event driven system enabled.
    [2014-03-29 08:35:19,677] [26710 ] [BassPlay ] [DEBUG] - BassPlayer: BASS: Try to init WASAPI with a samplerate of 96000 and 6 channels
    [2014-03-29 08:35:19,685] [26718 ] [BassPlay ] [DEBUG] - BassPlayer: Collecting device info
    [2014-03-29 08:35:19,691] [26724 ] [BassPlay ] [DEBUG] - BassPlayer: WASAPI device info: Name="Lautsprecher (Realtek High Definition Audio)", Driver="WASAPI", Channels=6, MinRate=48000, MaxRate=48000, Latency=0ms
    Is "Lautsprecher (Realtek High Definition Audio)" the right device?
    For that special case, which i fixed in MP1, you need to have a Mixer Matrix, which assigns the channels correctly

    See MixerStream.cs line 676
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,487
    7,019
    Germany Germany
    Country flag
    • Thread starter
    • Moderator
    • #23
    A Mixer stream is always active, unless you initalize it to stop, when nothing is fed into it.
    So when you add a song to the mixer you need to set a SyncPos to "current mixer position + length of song just added".
    This will then signal and you know that the song has ended, and you can add the next siong from the playlistz or stop playback, if it was the last song.

    THat's the SetSyncPos in MP1 MixerStream.cs line 385
    I've added this code already, but it doesn't work. When I debugged it, the duration of input was "0", so maybe this is the root cause?

    I will cleanup my working copy and push it, could you check it please?

    The channel mixing I will do as last step, because this changes the "processing chain" (although the current classes are only pass through stubs)
     

    mrj

    Portal Pro
    January 27, 2012
    252
    100
    Country flag
    Hi morpheus_xx
    Maybe you need to set the BASS_MIXER_END flag for the mixer stream as discussed here
    /mrj

    //Edit
    Also discussed here
    /mrj
     
    Last edited:

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,487
    7,019
    Germany Germany
    Country flag
    • Thread starter
    • Moderator
    • #26
    Thanks for all answers. I finally found the cause: When I registered on "PlaybackEnd", I always got a crash from unmanaged side. The problem was a implicit delegate creation, so callback was already GCed.
    (a thread to similar problem explained it here http://stackoverflow.com/questions/4855513/callbackoncollecteddelegate-was-detected)

    Only known issue is the channel mapping. Before touching this, I will try this build on my HTPC :D

    Testbuild in 1st post!
     

    Holzi

    Super Moderator
  • Team MediaPortal
  • April 21, 2010
    7,930
    2,234
    Ba-Wü
    Germany Germany
    Country flag
    Testing this and it works fine if only one player is active. As soon as there are more players (especially video and music file) there are problems like freezing video while start playing music concurrently and being unable to change audio streams between players. :)
    Changing back to DirectSound solved these issues.
    Thanks!
     

    morpheus_xx

    Lead Dev MP2
  • Team MediaPortal
  • March 24, 2007
    11,487
    7,019
    Germany Germany
    Country flag
    • Thread starter
    • Moderator
    • #28
    Testing this and it works fine if only one player is active. As soon as there are more players (especially video and music file) there are problems like freezing video while start playing music concurrently and being unable to change audio streams between players. :)
    Changing back to DirectSound solved these issues.
    Thanks!
    Can you check this in Wasapi shared mode? (in settings uncheck "exclusive") I guess it would also work if different audio devices are selected for audio and video.
    I'm afraid it might need more changes in player management to support switching input of exclusive opened audio devices.
     

    Holzi

    Super Moderator
  • Team MediaPortal
  • April 21, 2010
    7,930
    2,234
    Ba-Wü
    Germany Germany
    Country flag
    In shared mode the video doesn't freeze if you start playing audio concurrently but you can't change to the audio stream of the other player. Furthermore you are unable to mute (happens also in exclusive mode).
    If the music (mp3 file) ends the audio stream from the video is played on. (correct behaviour :)).

    Screenshot:
    1.png
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    Top Bottom