Skip to content

Commit 6aa789f

Browse files
committed
Fix an issue with ResolveSpriteSource and Linux file paths
1 parent 6c922e0 commit 6aa789f

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

src/NitroSharp/Builtins.Graphics.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,18 @@ public override void CreateSprite(
229229
return result;
230230
}
231231

232-
Entity? srcEntity = Get(new EntityPath(src));
233-
if (srcEntity is ColorSource colorSrc)
234-
{
235-
return SpriteTexture.SolidColor(colorSrc.Color, colorSrc.Size);
236-
}
237-
if (srcEntity is Image img)
238-
{
239-
return img.Texture.WithSourceRectangle(srcRect);
240-
}
241-
242232
if (_ctx.Content.RequestTexture(src) is AssetRef<Texture> asset)
243233
{
244234
return SpriteTexture.FromAsset(asset, srcRect);
245235
}
246236

247-
return null;
237+
Entity? srcEntity = Get(new EntityPath(src));
238+
return srcEntity switch
239+
{
240+
ColorSource colorSrc => SpriteTexture.SolidColor(colorSrc.Color, colorSrc.Size),
241+
Image img => img.Texture.WithSourceRectangle(srcRect),
242+
_ => null
243+
};
248244
}
249245

250246
public override void CreateSpriteEx(

src/NitroSharp/Content/FFmpegTextureLoader.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ protected override Texture LoadStaging(Stream stream)
2323
int streamId = ffmpeg.av_find_best_stream(
2424
context.Inner,
2525
AVMediaType.AVMEDIA_TYPE_VIDEO,
26-
-1, -1,
27-
null, 0
26+
-1, -1, null, 0
2827
);
2928

3029
AVCodecContext* codecCtx = context.OpenStream(streamId);
@@ -44,7 +43,7 @@ protected override Texture LoadStaging(Stream stream)
4443
GraphicsUtils.CopyTextureRegion(
4544
src: frame->data[0], 0, 0, 0,
4645
srcRowPitch: (uint)frame->linesize[0],
47-
srcDepthPitch: (uint)frame->linesize[0] * height ,
46+
srcDepthPitch: (uint)frame->linesize[0] * height,
4847
dst: map.Data.ToPointer(), 0, 0, 0,
4948
dstRowPitch: map.RowPitch, dstDepthPitch: map.DepthPitch,
5049
width, height, depth: 1, bytesPerPixel: 4
@@ -94,8 +93,7 @@ public override Size GetTextureSize(Stream stream)
9493
int streamId = ffmpeg.av_find_best_stream(
9594
context.Inner,
9695
AVMediaType.AVMEDIA_TYPE_VIDEO,
97-
-1, -1,
98-
null, 0
96+
-1, -1, null, 0
9997
);
10098
AVCodecParameters* codecpar = context.Inner->streams[streamId]->codecpar;
10199
return new Size((uint)codecpar->width, (uint)codecpar->height);

src/NitroSharp/Media/NullAudio/NullAudioSource.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ private async Task ConsumeLoop(PipeReader audioData)
5252
Debug.Assert(_cts is not null);
5353
while (!_cts.IsCancellationRequested)
5454
{
55-
while (!_cts.IsCancellationRequested)
56-
{
57-
ReadResult readResult = await audioData.ReadAsync();
58-
audioData.AdvanceTo(readResult.Buffer.End);
59-
}
55+
ReadResult readResult = await audioData.ReadAsync();
56+
audioData.AdvanceTo(readResult.Buffer.End);
6057
}
6158
}
6259

0 commit comments

Comments
 (0)