Skip to content

Commit

Permalink
Fixed issues with path seperators when server is running under linux;…
Browse files Browse the repository at this point in the history
… Client code audio rest would crash app
  • Loading branch information
TWhidden committed Sep 25, 2018
1 parent 54d980b commit 8a813c1
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 25 deletions.
3 changes: 3 additions & 0 deletions Docker/Client/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ echo "STARTING HOLIDAY SHOW CLIENT CORE..."
# reference: https://www.raspberrypi.org/documentation/configuration/audio-config.md
amixer cset numid=3 1

# set the volume level of the PCM device to 100%
amixer set PCM 100%

./HolidayShowClient.Core -s "$SERVER" -p $PORT -d $DEVICEID -a "$STORAGE"
2 changes: 1 addition & 1 deletion HolidayShowEditor/ViewModels/AudioFilesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private async void OnCommandScanDirectory()
double nanoseconds;
double.TryParse(so.Properties.System.Media.Duration.Value.ToString(),
out nanoseconds);
Console.WriteLine(@"NanaoSeconds: {0}", nanoseconds);
Console.WriteLine(@"NanoSeconds: {0}", nanoseconds);
if (nanoseconds > 0)
{
int milliseconds = (int)Convert100NanosecondsToMilliseconds(nanoseconds) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ public void SetMediaElement(MediaElement mediaElement)

public async void StopPlayback()
{
Console.WriteLine($"StopPlayback() called for {_currentRequest.FileName}");

#if CORE
_externalPlayerProcess?.Close();
_externalPlayerProcess?.Dispose();

#else
Console.WriteLine($"StopPlayback() called for {_currentRequest.FileName}");
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() =>
{
Expand Down
6 changes: 3 additions & 3 deletions HolidayShowServer.Core/HolidayShowServer.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<Authors>Travis Whidden</Authors>
<Company>None</Company>
<AssemblyName>holidayshowserver.core</AssemblyName>
<AssemblyVersion>2.18.0917.0</AssemblyVersion>
<FileVersion>2.18.0917.0</FileVersion>
<AssemblyVersion>2.18.0924.0</AssemblyVersion>
<FileVersion>2.18.0924.0</FileVersion>
<Configurations>Debug;Release;ReleaseCore</Configurations>
<Version>2.18.0917</Version>
<Version>2.18.0924</Version>
<PackageReleaseNotes>Reduced Database calls to reduce CPU. Code cleanup</PackageReleaseNotes>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion HolidayShowServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static void ConfigureServices(IServiceCollection services)
}
#endif

static void LogMessage(string message, bool persistMessage = false)
public static void LogMessage(string message, bool persistMessage = false)
{
lock (LogMessages)
{
Expand Down
15 changes: 10 additions & 5 deletions HolidayShowServer/RemoteClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,28 @@ public override async void ProcessPacket(byte[] bytes, ParserProtocolContainer p
using (var dc = new EfHolidayContext(Program.ConnectionString))
{
var basePathSetting = await dc.Settings.Where(x=> x.SettingName == SettingKeys.FileBasePath).FirstOrDefaultAsync();
if (basePathSetting == null || String.IsNullOrWhiteSpace(basePathSetting.ValueString) || !Directory.Exists(basePathSetting.ValueString))
if (basePathSetting == null || string.IsNullOrWhiteSpace(basePathSetting.ValueString) || !Directory.Exists(basePathSetting.ValueString))
{
Console.WriteLine("System Setting {0} does not exist in settings table. Must be set to support file transfers", SettingKeys.FileBasePath);
Program.LogMessage($"System Setting {SettingKeys.FileBasePath} does not exist in settings table. Must be set to support file transfers");
BeginSend(new ProtocolMessage(MessageTypeIdEnum.RequestFailed));
return;
}

var fileRequested = message.MessageParts[ProtocolMessage.FILEDOWNLOAD];

Console.WriteLine("File Requested {0}", fileRequested);
Program.LogMessage($"File Requested {fileRequested}");

var combinedPath = Path.Combine(basePathSetting.ValueString, fileRequested);
var fileRequestedModified = fileRequested.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);

Program.LogMessage($"Modified File Requested {fileRequestedModified}");

// Modify the path separators based on if the server is in linux or windows.
var combinedPath = Path.Combine(basePathSetting.ValueString, fileRequestedModified);

// See if the requested file exists
if (!File.Exists(combinedPath))
{
Console.WriteLine("File Requsted does not exist at path {0}", combinedPath);
Program.LogMessage($"File Requested does not exist at path {combinedPath}");
BeginSend(new ProtocolMessage(MessageTypeIdEnum.RequestFailed));
return;
}
Expand Down
1 change: 0 additions & 1 deletion docker-compose-client.override.yml

This file was deleted.

8 changes: 0 additions & 8 deletions docker-compose-client.yml

This file was deleted.

4 changes: 0 additions & 4 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
<ProjectGuid>9cba41e6-bd68-4687-be20-a41d0f231f7d</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose-client.override.yml">
<DependentUpon>docker-compose-client.yml</DependentUpon>
</None>
<None Include="docker-compose-client.yml" />
<None Include=".dockerignore" />
<None Include="docker-compose.yml" />
</ItemGroup>
Expand Down

0 comments on commit 8a813c1

Please sign in to comment.