Merge pull request #2342 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-12-14 16:01:33 -05:00 committed by GitHub
commit 4cc15a8919
19 changed files with 66 additions and 154 deletions

View file

@ -125,15 +125,15 @@ namespace Emby.Common.Implementations.Net
try try
{ {
#if NETSTANDARD1_3 #if NET46
// The ExclusiveAddressUse socket option is a Windows-specific option that, when set to "true," tells Windows not to allow another socket to use the same local address as this socket retVal.ExclusiveAddressUse = false;
// See https://github.com/dotnet/corefx/pull/11509 for more details #else
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) // The ExclusiveAddressUse socket option is a Windows-specific option that, when set to "true," tells Windows not to allow another socket to use the same local address as this socket
// See https://github.com/dotnet/corefx/pull/11509 for more details
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
{ {
retVal.ExclusiveAddressUse = false; retVal.ExclusiveAddressUse = false;
} }
#else
retVal.ExclusiveAddressUse = false;
#endif #endif
//retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

View file

@ -245,7 +245,7 @@ namespace Emby.Common.Implementations.Networking
//} //}
return ipProperties.UnicastAddresses return ipProperties.UnicastAddresses
.Where(i => i.IsDnsEligible) //.Where(i => i.IsDnsEligible)
.Select(i => i.Address) .Select(i => i.Address)
.Where(i => i.AddressFamily == AddressFamily.InterNetwork) .Where(i => i.AddressFamily == AddressFamily.InterNetwork)
.ToList(); .ToList();

View file

@ -98,6 +98,9 @@ namespace Emby.Dlna.ContentDirectory
if (string.Equals(methodName, "Search", StringComparison.OrdinalIgnoreCase)) if (string.Equals(methodName, "Search", StringComparison.OrdinalIgnoreCase))
return HandleSearch(methodParams, user, deviceId).Result; return HandleSearch(methodParams, user, deviceId).Result;
if (string.Equals(methodName, "X_BrowseByLetter", StringComparison.OrdinalIgnoreCase))
return HandleX_BrowseByLetter(methodParams, user, deviceId).Result;
throw new ResourceNotFoundException("Unexpected control request name: " + methodName); throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
} }
@ -118,7 +121,7 @@ namespace Emby.Dlna.ContentDirectory
_userDataManager.SaveUserData(user.Id, item, userdata, UserDataSaveReason.TogglePlayed, _userDataManager.SaveUserData(user.Id, item, userdata, UserDataSaveReason.TogglePlayed,
CancellationToken.None); CancellationToken.None);
return new Dictionary<string,string>(StringComparer.OrdinalIgnoreCase); return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
} }
private IEnumerable<KeyValuePair<string, string>> HandleGetSearchCapabilities() private IEnumerable<KeyValuePair<string, string>> HandleGetSearchCapabilities()
@ -147,7 +150,7 @@ namespace Emby.Dlna.ContentDirectory
private IEnumerable<KeyValuePair<string, string>> HandleGetSystemUpdateID() private IEnumerable<KeyValuePair<string, string>> HandleGetSystemUpdateID()
{ {
var headers = new Dictionary<string,string>(StringComparer.OrdinalIgnoreCase); var headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
headers.Add("Id", _systemUpdateId.ToString(_usCulture)); headers.Add("Id", _systemUpdateId.ToString(_usCulture));
return headers; return headers;
} }
@ -309,6 +312,12 @@ namespace Emby.Dlna.ContentDirectory
}; };
} }
private Task<IEnumerable<KeyValuePair<string, string>>> HandleX_BrowseByLetter(IDictionary<string, string> sparams, User user, string deviceId)
{
// TODO: Implement this method
return HandleSearch(sparams, user, deviceId);
}
private async Task<IEnumerable<KeyValuePair<string, string>>> HandleSearch(IDictionary<string, string> sparams, User user, string deviceId) private async Task<IEnumerable<KeyValuePair<string, string>>> HandleSearch(IDictionary<string, string> sparams, User user, string deviceId)
{ {
var searchCriteria = new SearchCriteria(GetValueOrDefault(sparams, "SearchCriteria", "")); var searchCriteria = new SearchCriteria(GetValueOrDefault(sparams, "SearchCriteria", ""));
@ -553,20 +562,6 @@ namespace Emby.Dlna.ContentDirectory
return result; return result;
} }
private bool EnablePeopleDisplay(BaseItem item)
{
if (_libraryManager.GetPeopleNames(new InternalPeopleQuery
{
ItemId = item.Id
}).Count > 0)
{
return item is Movie;
}
return false;
}
private ServerItem GetItemFromObjectId(string id, User user) private ServerItem GetItemFromObjectId(string id, User user)
{ {
return DidlBuilder.IsIdRoot(id) return DidlBuilder.IsIdRoot(id)

View file

@ -207,8 +207,7 @@ namespace Emby.Dlna.Didl
streamInfo.TargetVideoStreamCount, streamInfo.TargetVideoStreamCount,
streamInfo.TargetAudioStreamCount, streamInfo.TargetAudioStreamCount,
streamInfo.TargetVideoCodecTag, streamInfo.TargetVideoCodecTag,
streamInfo.IsTargetAVC, streamInfo.IsTargetAVC);
streamInfo.AllAudioCodecs);
foreach (var contentFeature in contentFeatureList) foreach (var contentFeature in contentFeatureList)
{ {
@ -348,8 +347,7 @@ namespace Emby.Dlna.Didl
streamInfo.TargetVideoStreamCount, streamInfo.TargetVideoStreamCount,
streamInfo.TargetAudioStreamCount, streamInfo.TargetAudioStreamCount,
streamInfo.TargetVideoCodecTag, streamInfo.TargetVideoCodecTag,
streamInfo.IsTargetAVC, streamInfo.IsTargetAVC);
streamInfo.AllAudioCodecs);
var filename = url.Substring(0, url.IndexOf('?')); var filename = url.Substring(0, url.IndexOf('?'));

View file

@ -541,8 +541,7 @@ namespace Emby.Dlna.PlayTo
streamInfo.TargetVideoStreamCount, streamInfo.TargetVideoStreamCount,
streamInfo.TargetAudioStreamCount, streamInfo.TargetAudioStreamCount,
streamInfo.TargetVideoCodecTag, streamInfo.TargetVideoCodecTag,
streamInfo.IsTargetAVC, streamInfo.IsTargetAVC);
streamInfo.AllAudioCodecs);
return list.FirstOrDefault(); return list.FirstOrDefault();
} }

View file

@ -102,11 +102,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
/// <returns>Task.</returns> /// <returns>Task.</returns>
public Task SendAsync(byte[] bytes, bool endOfMessage, CancellationToken cancellationToken) public Task SendAsync(byte[] bytes, bool endOfMessage, CancellationToken cancellationToken)
{ {
var completionSource = new TaskCompletionSource<bool>(); return WebSocket.SendAsync(bytes);
WebSocket.SendAsync(bytes, res => completionSource.TrySetResult(true));
return completionSource.Task;
} }
/// <summary> /// <summary>
@ -118,11 +114,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
/// <returns>Task.</returns> /// <returns>Task.</returns>
public Task SendAsync(string text, bool endOfMessage, CancellationToken cancellationToken) public Task SendAsync(string text, bool endOfMessage, CancellationToken cancellationToken)
{ {
var completionSource = new TaskCompletionSource<bool>(); return WebSocket.SendAsync(text);
WebSocket.SendAsync(text, res => completionSource.TrySetResult(true));
return completionSource.Task;
} }
/// <summary> /// <summary>

View file

@ -151,9 +151,10 @@ namespace MediaBrowser.Api
} }
if (client.IndexOf("web", StringComparison.OrdinalIgnoreCase) == -1 && if (client.IndexOf("web", StringComparison.OrdinalIgnoreCase) == -1 &&
// covers both emby mobile and emby for android mobile
client.IndexOf("mobile", StringComparison.OrdinalIgnoreCase) == -1 && client.IndexOf("mobile", StringComparison.OrdinalIgnoreCase) == -1 &&
client.IndexOf("ios", StringComparison.OrdinalIgnoreCase) == -1 && client.IndexOf("ios", StringComparison.OrdinalIgnoreCase) == -1 &&
client.IndexOf("android", StringComparison.OrdinalIgnoreCase) == -1 &&
client.IndexOf("theater", StringComparison.OrdinalIgnoreCase) == -1) client.IndexOf("theater", StringComparison.OrdinalIgnoreCase) == -1)
{ {
options.Fields.Add(Model.Querying.ItemFields.ChildCount); options.Fields.Add(Model.Querying.ItemFields.ChildCount);

View file

@ -2358,8 +2358,7 @@ namespace MediaBrowser.Api.Playback
state.TargetVideoStreamCount, state.TargetVideoStreamCount,
state.TargetAudioStreamCount, state.TargetAudioStreamCount,
state.TargetVideoCodecTag, state.TargetVideoCodecTag,
state.IsTargetAVC, state.IsTargetAVC);
state.AllAudioCodecs);
if (mediaProfile != null) if (mediaProfile != null)
{ {
@ -2581,8 +2580,7 @@ namespace MediaBrowser.Api.Playback
state.TargetVideoStreamCount, state.TargetVideoStreamCount,
state.TargetAudioStreamCount, state.TargetAudioStreamCount,
state.TargetVideoCodecTag, state.TargetVideoCodecTag,
state.IsTargetAVC, state.IsTargetAVC
state.AllAudioCodecs
).FirstOrDefault() ?? string.Empty; ).FirstOrDefault() ?? string.Empty;
} }

View file

@ -245,17 +245,6 @@ namespace MediaBrowser.Api.Playback
public int? OutputAudioBitrate; public int? OutputAudioBitrate;
public int? OutputVideoBitrate; public int? OutputVideoBitrate;
public List<string> AllAudioCodecs
{
get
{
return MediaSource.MediaStreams.Where(i => i.Type == MediaStreamType.Audio)
.Select(i => i.Codec)
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToList();
}
}
public string ActualOutputVideoCodec public string ActualOutputVideoCodec
{ {
get get

View file

@ -118,17 +118,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
} }
} }
public List<string> AllAudioCodecs
{
get
{
return MediaSource.MediaStreams.Where(i => i.Type == MediaStreamType.Audio)
.Select(i => i.Codec)
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToList();
}
}
private void DisposeIsoMount() private void DisposeIsoMount()
{ {
if (IsoMount != null) if (IsoMount != null)

View file

@ -846,8 +846,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
state.TargetVideoStreamCount, state.TargetVideoStreamCount,
state.TargetAudioStreamCount, state.TargetAudioStreamCount,
state.TargetVideoCodecTag, state.TargetVideoCodecTag,
state.IsTargetAVC, state.IsTargetAVC);
state.AllAudioCodecs);
if (mediaProfile != null) if (mediaProfile != null)
{ {

View file

@ -24,15 +24,12 @@ namespace MediaBrowser.Model.Dlna
int? numVideoStreams, int? numVideoStreams,
int? numAudioStreams, int? numAudioStreams,
string videoCodecTag, string videoCodecTag,
bool? isAvc, bool? isAvc )
List<string> allAudioCodecs )
{ {
switch (condition.Property) switch (condition.Property)
{ {
case ProfileConditionValue.IsAnamorphic: case ProfileConditionValue.IsAnamorphic:
return IsConditionSatisfied(condition, isAnamorphic); return IsConditionSatisfied(condition, isAnamorphic);
case ProfileConditionValue.HasAudioCodec:
return IsHasAudioCodecConditionSatisfied(condition, allAudioCodecs);
case ProfileConditionValue.IsAvc: case ProfileConditionValue.IsAvc:
return IsConditionSatisfied(condition, isAvc); return IsConditionSatisfied(condition, isAvc);
case ProfileConditionValue.VideoFramerate: case ProfileConditionValue.VideoFramerate:
@ -167,25 +164,6 @@ namespace MediaBrowser.Model.Dlna
} }
} }
private bool IsHasAudioCodecConditionSatisfied(ProfileCondition condition, List<string> allAudioCodecs)
{
if (allAudioCodecs.Count == 0)
{
// If the value is unknown, it satisfies if not marked as required
return !condition.IsRequired;
}
switch (condition.Condition)
{
case ProfileConditionType.Equals:
return allAudioCodecs.Contains(condition.Value, StringComparer.Ordinal);
case ProfileConditionType.NotEquals:
return !allAudioCodecs.Contains(condition.Value, StringComparer.Ordinal);
default:
throw new InvalidOperationException("Unexpected ProfileConditionType");
}
}
private bool IsConditionSatisfied(ProfileCondition condition, bool? currentValue) private bool IsConditionSatisfied(ProfileCondition condition, bool? currentValue)
{ {
if (!currentValue.HasValue) if (!currentValue.HasValue)

View file

@ -119,8 +119,7 @@ namespace MediaBrowser.Model.Dlna
int? numVideoStreams, int? numVideoStreams,
int? numAudioStreams, int? numAudioStreams,
string videoCodecTag, string videoCodecTag,
bool? isAvc, bool? isAvc)
List<string> allAudioCodecs)
{ {
// first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none // first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none
string orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetOrgOpValue(runtimeTicks.HasValue, isDirectStream, transcodeSeekInfo); string orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetOrgOpValue(runtimeTicks.HasValue, isDirectStream, transcodeSeekInfo);
@ -162,8 +161,7 @@ namespace MediaBrowser.Model.Dlna
numVideoStreams, numVideoStreams,
numAudioStreams, numAudioStreams,
videoCodecTag, videoCodecTag,
isAvc, isAvc);
allAudioCodecs);
List<string> orgPnValues = new List<string>(); List<string> orgPnValues = new List<string>();

View file

@ -297,8 +297,7 @@ namespace MediaBrowser.Model.Dlna
int? numVideoStreams, int? numVideoStreams,
int? numAudioStreams, int? numAudioStreams,
string videoCodecTag, string videoCodecTag,
bool? isAvc, bool? isAvc)
List<string> allAudioCodecs)
{ {
container = StringHelper.TrimStart(container ?? string.Empty, '.'); container = StringHelper.TrimStart(container ?? string.Empty, '.');
@ -332,7 +331,7 @@ namespace MediaBrowser.Model.Dlna
var anyOff = false; var anyOff = false;
foreach (ProfileCondition c in i.Conditions) foreach (ProfileCondition c in i.Conditions)
{ {
if (!conditionProcessor.IsVideoConditionSatisfied(GetModelProfileCondition(c), width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc, allAudioCodecs)) if (!conditionProcessor.IsVideoConditionSatisfied(GetModelProfileCondition(c), width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc))
{ {
anyOff = true; anyOff = true;
break; break;

View file

@ -21,7 +21,6 @@
NumVideoStreams = 17, NumVideoStreams = 17,
IsSecondaryAudio = 18, IsSecondaryAudio = 18,
VideoCodecTag = 19, VideoCodecTag = 19,
IsAvc = 20, IsAvc = 20
HasAudioCodec = 21
} }
} }

View file

@ -411,7 +411,6 @@ namespace MediaBrowser.Model.Dlna
} }
var allMediaStreams = item.MediaStreams; var allMediaStreams = item.MediaStreams;
var allAudioCodecs = allMediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
MediaStream videoStream = item.VideoStream; MediaStream videoStream = item.VideoStream;
@ -556,7 +555,7 @@ namespace MediaBrowser.Model.Dlna
int? numAudioStreams = item.GetStreamCount(MediaStreamType.Audio); int? numAudioStreams = item.GetStreamCount(MediaStreamType.Audio);
int? numVideoStreams = item.GetStreamCount(MediaStreamType.Video); int? numVideoStreams = item.GetStreamCount(MediaStreamType.Video);
if (!conditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc, allAudioCodecs)) if (!conditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc))
{ {
LogConditionFailure(options.Profile, "VideoCodecProfile", applyCondition, item); LogConditionFailure(options.Profile, "VideoCodecProfile", applyCondition, item);
applyConditions = false; applyConditions = false;
@ -739,12 +738,10 @@ namespace MediaBrowser.Model.Dlna
int? numAudioStreams = mediaSource.GetStreamCount(MediaStreamType.Audio); int? numAudioStreams = mediaSource.GetStreamCount(MediaStreamType.Audio);
int? numVideoStreams = mediaSource.GetStreamCount(MediaStreamType.Video); int? numVideoStreams = mediaSource.GetStreamCount(MediaStreamType.Video);
var allAudioCodecs = allMediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
// Check container conditions // Check container conditions
foreach (ProfileCondition i in conditions) foreach (ProfileCondition i in conditions)
{ {
if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc, allAudioCodecs)) if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc))
{ {
LogConditionFailure(profile, "VideoContainerProfile", i, mediaSource); LogConditionFailure(profile, "VideoContainerProfile", i, mediaSource);
@ -771,7 +768,7 @@ namespace MediaBrowser.Model.Dlna
bool applyConditions = true; bool applyConditions = true;
foreach (ProfileCondition applyCondition in i.ApplyConditions) foreach (ProfileCondition applyCondition in i.ApplyConditions)
{ {
if (!conditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc, allAudioCodecs)) if (!conditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc))
{ {
LogConditionFailure(profile, "VideoCodecProfile", applyCondition, mediaSource); LogConditionFailure(profile, "VideoCodecProfile", applyCondition, mediaSource);
applyConditions = false; applyConditions = false;
@ -791,7 +788,7 @@ namespace MediaBrowser.Model.Dlna
foreach (ProfileCondition i in conditions) foreach (ProfileCondition i in conditions)
{ {
if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc, allAudioCodecs)) if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc))
{ {
LogConditionFailure(profile, "VideoCodecProfile", i, mediaSource); LogConditionFailure(profile, "VideoCodecProfile", i, mediaSource);

View file

@ -413,17 +413,6 @@ namespace MediaBrowser.Model.Dlna
} }
} }
public List<string> AllAudioCodecs
{
get
{
return MediaSource.MediaStreams.Where(i => i.Type == MediaStreamType.Audio)
.Select(i => i.Codec)
.Where(i => !string.IsNullOrWhiteSpace(i))
.ToList();
}
}
/// <summary> /// <summary>
/// Returns the video stream that will be used /// Returns the video stream that will be used
/// </summary> /// </summary>

View file

@ -5,6 +5,7 @@ using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using SocketHttpListener.Net.WebSockets; using SocketHttpListener.Net.WebSockets;
@ -621,26 +622,22 @@ namespace SocketHttpListener
} }
} }
private void sendAsync(Opcode opcode, Stream stream, Action<bool> completed) private Task sendAsync(Opcode opcode, Stream stream)
{ {
Func<Opcode, Stream, bool> sender = send; var completionSource = new TaskCompletionSource<bool>();
sender.BeginInvoke( Task.Run(() =>
opcode, {
stream, try
ar => {
{ send(opcode, stream);
try completionSource.TrySetResult(true);
{ }
var sent = sender.EndInvoke(ar); catch (Exception ex)
if (completed != null) {
completed(sent); completionSource.TrySetException(ex);
} }
catch (Exception ex) });
{ return completionSource.Task;
error("An exception has occurred while callback.", ex);
}
},
null);
} }
// As server // As server
@ -833,22 +830,18 @@ namespace SocketHttpListener
/// <param name="data"> /// <param name="data">
/// An array of <see cref="byte"/> that represents the binary data to send. /// An array of <see cref="byte"/> that represents the binary data to send.
/// </param> /// </param>
/// <param name="completed">
/// An Action&lt;bool&gt; delegate that references the method(s) called when the send is /// An Action&lt;bool&gt; delegate that references the method(s) called when the send is
/// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is /// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// complete successfully; otherwise, <c>false</c>. /// complete successfully; otherwise, <c>false</c>.
/// </param> public Task SendAsync(byte[] data)
public void SendAsync(byte[] data, Action<bool> completed)
{ {
var msg = _readyState.CheckIfOpen() ?? data.CheckIfValidSendData(); var msg = _readyState.CheckIfOpen() ?? data.CheckIfValidSendData();
if (msg != null) if (msg != null)
{ {
error(msg); throw new Exception(msg);
return;
} }
sendAsync(Opcode.Binary, _memoryStreamFactory.CreateNew(data), completed); return sendAsync(Opcode.Binary, _memoryStreamFactory.CreateNew(data));
} }
/// <summary> /// <summary>
@ -860,22 +853,18 @@ namespace SocketHttpListener
/// <param name="data"> /// <param name="data">
/// A <see cref="string"/> that represents the text data to send. /// A <see cref="string"/> that represents the text data to send.
/// </param> /// </param>
/// <param name="completed">
/// An Action&lt;bool&gt; delegate that references the method(s) called when the send is /// An Action&lt;bool&gt; delegate that references the method(s) called when the send is
/// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is /// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// complete successfully; otherwise, <c>false</c>. /// complete successfully; otherwise, <c>false</c>.
/// </param> public Task SendAsync(string data)
public void SendAsync(string data, Action<bool> completed)
{ {
var msg = _readyState.CheckIfOpen() ?? data.CheckIfValidSendData(); var msg = _readyState.CheckIfOpen() ?? data.CheckIfValidSendData();
if (msg != null) if (msg != null)
{ {
error(msg); throw new Exception(msg);
return;
} }
sendAsync(Opcode.Text, _memoryStreamFactory.CreateNew(Encoding.UTF8.GetBytes(data)), completed); return sendAsync(Opcode.Text, _memoryStreamFactory.CreateNew(Encoding.UTF8.GetBytes(data)));
} }
#endregion #endregion

View file

@ -215,9 +215,12 @@ namespace Emby.Server
var initProgress = new Progress<double>(); var initProgress = new Progress<double>();
// Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | {
ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
}
var task = _appHost.Init(initProgress); var task = _appHost.Init(initProgress);
Task.WaitAll(task); Task.WaitAll(task);