Skip to content

Commit

Permalink
Merge branch 'master' into ava-11
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed May 16, 2023
2 parents 3e48504 + 22202be commit 86499b0
Show file tree
Hide file tree
Showing 48 changed files with 774 additions and 591 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/build.yml
Expand Up @@ -27,6 +27,7 @@ jobs:
build:
name: ${{ matrix.OS_NAME }} (${{ matrix.configuration }})
runs-on: ${{ matrix.os }}
timeout-minutes: 35
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
Expand All @@ -38,7 +39,7 @@ jobs:
RELEASE_ZIP_OS_NAME: linux_x64

- os: macOS-latest
OS_NAME: MacOS x64
OS_NAME: macOS x64
DOTNET_RUNTIME_IDENTIFIER: osx-x64
RELEASE_ZIP_OS_NAME: osx_x64

Expand Down Expand Up @@ -68,15 +69,15 @@ jobs:

- name: Publish Ryujinx
run: dotnet publish -c "${{ matrix.configuration }}" -r "${{ matrix.DOTNET_RUNTIME_IDENTIFIER }}" -o ./publish -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:DebugType=embedded -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER src/Ryujinx --self-contained true
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'

- name: Publish Ryujinx.Headless.SDL2
run: dotnet publish -c "${{ matrix.configuration }}" -r "${{ matrix.DOTNET_RUNTIME_IDENTIFIER }}" -o ./publish_sdl2_headless -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:DebugType=embedded -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER src/Ryujinx.Headless.SDL2 --self-contained true
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'

- name: Publish Ryujinx.Ava
run: dotnet publish -c "${{ matrix.configuration }}" -r "${{ matrix.DOTNET_RUNTIME_IDENTIFIER }}" -o ./publish_ava -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:DebugType=embedded -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER src/Ryujinx.Ava --self-contained true
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'

- name: Set executable bit
run: |
Expand All @@ -90,25 +91,26 @@ jobs:
with:
name: ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.RELEASE_ZIP_OS_NAME }}
path: publish
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'

- name: Upload Ryujinx.Headless.SDL2 artifact
uses: actions/upload-artifact@v3
with:
name: sdl2-ryujinx-headless-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.RELEASE_ZIP_OS_NAME }}
path: publish_sdl2_headless
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'

- name: Upload Ryujinx.Ava artifact
uses: actions/upload-artifact@v3
with:
name: ava-ryujinx-${{ matrix.configuration }}-${{ env.RYUJINX_BASE_VERSION }}+${{ steps.git_short_hash.outputs.result }}-${{ matrix.RELEASE_ZIP_OS_NAME }}
path: publish_ava
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'

build_macos:
name: MacOS universal (${{ matrix.configuration }})
name: macOS Universal (${{ matrix.configuration }})
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
matrix:
configuration: [ Debug, Release ]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/flatpak.yml
Expand Up @@ -12,6 +12,7 @@ concurrency: flatpak-release

jobs:
release:
timeout-minutes: 35
runs-on: ubuntu-latest

env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly_pr_comment.yml
Expand Up @@ -7,6 +7,7 @@ jobs:
pr_comment:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
- uses: actions/github-script@v6
with:
Expand Down Expand Up @@ -65,4 +66,4 @@ jobs:
} else {
core.info(`Creating a comment`);
await github.rest.issues.createComment({repo, owner, issue_number, body});
}
}
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Expand Up @@ -46,6 +46,7 @@ jobs:
release:
name: Release ${{ matrix.OS_NAME }}
runs-on: ${{ matrix.os }}
timeout-minutes: 35
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
Expand Down Expand Up @@ -143,13 +144,14 @@ jobs:
macos_release:
name: Release MacOS universal
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
- uses: actions/checkout@v3

- uses: actions/setup-dotnet@v3
with:
global-json-file: global.json

- name: Setup LLVM 14
run: |
wget https://apt.llvm.org/llvm.sh
Expand Down Expand Up @@ -205,4 +207,4 @@ jobs:
needs: release
with:
ryujinx_version: "1.1.${{ github.run_number }}"
secrets: inherit
secrets: inherit
2 changes: 1 addition & 1 deletion Directory.Packages.props
Expand Up @@ -44,7 +44,7 @@
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
<PackageVersion Include="SPB" Version="0.0.4-build28" />
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.30.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.30.1" />
<PackageVersion Include="System.IO.Hashing" Version="7.0.0" />
<PackageVersion Include="System.Management" Version="7.0.1" />
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
Expand Down
4 changes: 2 additions & 2 deletions distribution/macos/create_macos_build.sh
Expand Up @@ -22,9 +22,9 @@ EXTRA_ARGS=$8

if [ "$VERSION" == "1.1.0" ];
then
RELEASE_TAR_FILE_NAME=Ryujinx-$CONFIGURATION-$VERSION+$SOURCE_REVISION_ID-macos_universal.app.tar
RELEASE_TAR_FILE_NAME=test-ava-ryujinx-$CONFIGURATION-$VERSION+$SOURCE_REVISION_ID-macos_universal.app.tar
else
RELEASE_TAR_FILE_NAME=Ryujinx-$VERSION-macos_universal.app.tar
RELEASE_TAR_FILE_NAME=test-ava-ryujinx-$VERSION-macos_universal.app.tar
fi

ARM64_APP_BUNDLE="$TEMP_DIRECTORY/output_arm64/Ryujinx.app"
Expand Down
27 changes: 27 additions & 0 deletions src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceDriver.cs
Expand Up @@ -5,6 +5,7 @@
using Ryujinx.SDL2.Common;
using System;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
using System.Threading;

using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
Expand All @@ -18,13 +19,34 @@ public class SDL2HardwareDeviceDriver : IHardwareDeviceDriver
private readonly ManualResetEvent _pauseEvent;
private readonly ConcurrentDictionary<SDL2HardwareDeviceSession, byte> _sessions;

private bool _supportSurroundConfiguration;

// TODO: Add this to SDL2-CS
// NOTE: We use a DllImport here because of marshaling issue for spec.
[DllImport("SDL2")]
private static extern int SDL_GetDefaultAudioInfo(IntPtr name, out SDL_AudioSpec spec, int isCapture);

public SDL2HardwareDeviceDriver()
{
_updateRequiredEvent = new ManualResetEvent(false);
_pauseEvent = new ManualResetEvent(true);
_sessions = new ConcurrentDictionary<SDL2HardwareDeviceSession, byte>();

SDL2Driver.Instance.Initialize();

int res = SDL_GetDefaultAudioInfo(IntPtr.Zero, out var spec, 0);

if (res != 0)
{
Logger.Error?.Print(LogClass.Application,
$"SDL_GetDefaultAudioInfo failed with error \"{SDL_GetError()}\"");

_supportSurroundConfiguration = true;
}
else
{
_supportSurroundConfiguration = spec.channels == 6;
}
}

public static bool IsSupported => IsSupportedInternal();
Expand Down Expand Up @@ -164,6 +186,11 @@ public bool SupportsSampleFormat(SampleFormat sampleFormat)

public bool SupportsChannelCount(uint channelCount)
{
if (channelCount == 6)
{
return _supportSurroundConfiguration;
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
Expand Up @@ -45,7 +45,7 @@ public class VirtualDevice
/// <param name="name">The name of the <see cref="VirtualDevice"/>.</param>
/// <param name="channelCount">The count of channels supported by the <see cref="VirtualDevice"/>.</param>
/// <param name="isExternalOutput">Indicate if the <see cref="VirtualDevice"/> is provided by an external interface.</param>
private VirtualDevice(string name, uint channelCount, bool isExternalOutput)
public VirtualDevice(string name, uint channelCount, bool isExternalOutput)
{
Name = name;
ChannelCount = channelCount;
Expand Down
@@ -1,3 +1,4 @@
using Ryujinx.Audio.Integration;
using System.Collections.Generic;

namespace Ryujinx.Audio.Renderer.Device
Expand All @@ -22,7 +23,23 @@ public class VirtualDeviceSessionRegistry
/// The current active <see cref="VirtualDevice"/>.
/// </summary>
// TODO: make this configurable
public VirtualDevice ActiveDevice = VirtualDevice.Devices[2];
public VirtualDevice ActiveDevice { get; }

public VirtualDeviceSessionRegistry(IHardwareDeviceDriver driver)
{
uint channelCount;

if (driver.GetRealDeviceDriver().SupportsChannelCount(6))
{
channelCount = 6;
}
else
{
channelCount = 2;
}

ActiveDevice = new VirtualDevice("AudioTvOutput", channelCount, false);
}

/// <summary>
/// Get the associated <see cref="T:VirtualDeviceSession[]"/> from an AppletResourceId.
Expand Down
4 changes: 1 addition & 3 deletions src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
Expand Up @@ -65,9 +65,7 @@ public void Start(IHardwareDeviceDriver deviceDriver, float volume)
{
OutputDevices = new IHardwareDevice[Constants.AudioRendererSessionCountMax];

// TODO: Before enabling this, we need up-mixing from stereo to 5.1.
// uint channelCount = GetHardwareChannelCount(deviceDriver);
uint channelCount = 2;
uint channelCount = GetHardwareChannelCount(deviceDriver);

for (int i = 0; i < OutputDevices.Length; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
Expand Up @@ -49,8 +49,8 @@ public DelayCommand(uint bufferOffset, DelayParameter parameter, Memory<DelaySta
OutputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Output[i]);
}

DataSourceHelper.RemapLegacyChannelEffectMappingToChannelResourceMapping(newEffectChannelMappingSupported, InputBufferIndices);
DataSourceHelper.RemapLegacyChannelEffectMappingToChannelResourceMapping(newEffectChannelMappingSupported, OutputBufferIndices);
DataSourceHelper.RemapLegacyChannelEffectMappingToChannelResourceMapping(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
DataSourceHelper.RemapLegacyChannelEffectMappingToChannelResourceMapping(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
}

[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
Expand Down
16 changes: 14 additions & 2 deletions src/Ryujinx.Audio/Renderer/Dsp/Command/DeviceSinkCommand.cs
Expand Up @@ -67,7 +67,19 @@ public void Process(CommandList context)

const int sampleCount = Constants.TargetSampleCount;

short[] outputBuffer = new short[bufferCount * sampleCount];
uint inputCount;

// In case of upmixing to 5.1, we allocate the right amount.
if (bufferCount != channelCount && channelCount == 6)
{
inputCount = (uint)channelCount;
}
else
{
inputCount = bufferCount;
}

short[] outputBuffer = new short[inputCount * sampleCount];

for (int i = 0; i < bufferCount; i++)
{
Expand All @@ -79,7 +91,7 @@ public void Process(CommandList context)
}
}

device.AppendBuffer(outputBuffer, InputCount);
device.AppendBuffer(outputBuffer, inputCount);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
Expand Up @@ -66,8 +66,8 @@ public Reverb3dCommand(uint bufferOffset, Reverb3dParameter parameter, Memory<Re

// NOTE: We do the opposite as Nintendo here for now to restore previous behaviour
// TODO: Update reverb 3d processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping.
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices);
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices);
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -116,7 +116,7 @@ private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan
for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
{
int earlyDelayIndex = targetEarlyDelayLineIndicesTable[i];
int outputIndex = outputEarlyIndicesTable[i];
int outputIndex = outputEarlyIndicesTable[earlyDelayIndex];

float tempTapOut = state.PreDelayLine.TapUnsafe(state.EarlyDelayTime[earlyDelayIndex], delayLineSampleIndexOffset);

Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
Expand Up @@ -71,8 +71,8 @@ public ReverbCommand(uint bufferOffset, ReverbParameter parameter, Memory<Reverb

// NOTE: We do the opposite as Nintendo here for now to restore previous behaviour
// TODO: Update reverb processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping.
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices);
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices);
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
8 changes: 4 additions & 4 deletions src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
Expand Up @@ -430,9 +430,9 @@ public static void ToInt(Span<int> output, ReadOnlySpan<float> input, int sample
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RemapLegacyChannelEffectMappingToChannelResourceMapping(bool isSupported, Span<ushort> bufferIndices)
public static void RemapLegacyChannelEffectMappingToChannelResourceMapping(bool isSupported, Span<ushort> bufferIndices, uint channelCount)
{
if (!isSupported && bufferIndices.Length == 6)
if (!isSupported && channelCount == 6)
{
ushort backLeft = bufferIndices[2];
ushort backRight = bufferIndices[3];
Expand All @@ -447,9 +447,9 @@ public static void RemapLegacyChannelEffectMappingToChannelResourceMapping(bool
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RemapChannelResourceMappingToLegacy(bool isSupported, Span<ushort> bufferIndices)
public static void RemapChannelResourceMappingToLegacy(bool isSupported, Span<ushort> bufferIndices, uint channelCount)
{
if (isSupported && bufferIndices.Length == 6)
if (isSupported && channelCount == 6)
{
ushort frontCenter = bufferIndices[2];
ushort lowFrequency = bufferIndices[3];
Expand Down

0 comments on commit 86499b0

Please sign in to comment.