aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Audio/Detail/DeviceName.cs
blob: b77e2f402a3650106af18374ea332292e389cce6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Ryujinx.Common.Memory;
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Ryujinx.Horizon.Sdk.Audio.Detail
{
    [StructLayout(LayoutKind.Sequential, Size = 0x100, Pack = 1)]
    struct DeviceName
    {
        public Array256<byte> Name;

        public DeviceName(string name)
        {
            Name = new();
            Encoding.ASCII.GetBytes(name, Name.AsSpan());
        }

        public override string ToString()
        {
            int length = Name.AsSpan().IndexOf((byte)0);
            if (length < 0)
            {
                length = 0x100;
            }

            return Encoding.ASCII.GetString(Name.AsSpan()[..length]);
        }
    }
}