mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	Fix MediaStreamSelector
This commit is contained in:
		
							parent
							
								
									8b2556adba
								
							
						
					
					
						commit
						dbd7be091d
					
				@ -17,7 +17,12 @@ namespace Emby.Server.Implementations.Library
 | 
			
		||||
 | 
			
		||||
            if (preferDefaultTrack)
 | 
			
		||||
            {
 | 
			
		||||
                return sortedStreams.FirstOrDefault(i => i.IsDefault)?.Index;
 | 
			
		||||
                var defaultStream = streams.FirstOrDefault(i => i.IsDefault);
 | 
			
		||||
 | 
			
		||||
                if (defaultStream != null)
 | 
			
		||||
                {
 | 
			
		||||
                    return defaultStream.Index;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return sortedStreams.FirstOrDefault()?.Index;
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,30 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Emby.Server.Implementations.Library;
 | 
			
		||||
using MediaBrowser.Model.Entities;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace Jellyfin.Server.Implementations.Tests.Library;
 | 
			
		||||
 | 
			
		||||
public class MediaStreamSelectorTests
 | 
			
		||||
{
 | 
			
		||||
    [Theory]
 | 
			
		||||
    [InlineData(true)]
 | 
			
		||||
    [InlineData(false)]
 | 
			
		||||
    public void GetDefaultAudioStreamIndex_EmptyStreams_Null(bool preferDefaultTrack)
 | 
			
		||||
    {
 | 
			
		||||
        Assert.Null(MediaStreamSelector.GetDefaultAudioStreamIndex(Array.Empty<MediaStream>(), Array.Empty<string>(), preferDefaultTrack));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Theory]
 | 
			
		||||
    [InlineData(true)]
 | 
			
		||||
    [InlineData(false)]
 | 
			
		||||
    public void GetDefaultAudioStreamIndex_WithoutDefault_NotNull(bool preferDefaultTrack)
 | 
			
		||||
    {
 | 
			
		||||
        var streams = new[]
 | 
			
		||||
        {
 | 
			
		||||
            new MediaStream()
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        Assert.NotNull(MediaStreamSelector.GetDefaultAudioStreamIndex(streams, Array.Empty<string>(), preferDefaultTrack));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user