-
Notifications
You must be signed in to change notification settings - Fork 1
Fix audio pipeline: replace native codec P/Invoke with managed packages, add NAudio playback, fix infinite dequeue loop #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bd010cc
3080713
cc491a5
a47b209
985c708
01f6ccd
2c1e6a3
bcec590
51f0490
f1f3697
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,12 @@ | ||||||||||
| using AirPlay.Models.Configs; | ||||||||||
| using AirPlay.Models.Configs; | ||||||||||
| using AirPlay.Services; | ||||||||||
| using AirPlay.Utils; | ||||||||||
| using Microsoft.Extensions.Hosting; | ||||||||||
| using Microsoft.Extensions.Options; | ||||||||||
| using System; | ||||||||||
| using System.Collections.Generic; | ||||||||||
| using System.IO; | ||||||||||
| using System.Runtime.InteropServices; | ||||||||||
| using System.Threading; | ||||||||||
| using System.Threading.Tasks; | ||||||||||
|
|
||||||||||
|
|
@@ -15,14 +17,40 @@ public class AirPlayService : IHostedService, IDisposable | |||||||||
| private readonly IAirPlayReceiver _airPlayReceiver; | ||||||||||
| private readonly DumpConfig _dConfig; | ||||||||||
|
|
||||||||||
| private AudioOutputService _audioOutput; | ||||||||||
| private List<byte> _audiobuf; | ||||||||||
|
||||||||||
| private List<byte> _audiobuf; |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AirPlayService.RecreateAudioOutput() calls Thread.Sleep(200) while holding _audioOutputLock, which blocks audio writes (OnPCMDataReceived) and flush handling during the sleep. Release the lock before sleeping, or perform the delay after disposing but before reacquiring the lock to recreate.
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In DUMP builds, _audiobuf.AddRange(e.Data) appends the entire backing array even when e.Length indicates only part of it is valid PCM. This can inflate dumps with trailing zeros/garbage and make the WAV header length inconsistent. Append only the first e.Length bytes.
| _audiobuf.AddRange(e.Data); | |
| var validPcmChunk = new byte[e.Length]; | |
| Buffer.BlockCopy(e.Data, 0, validPcmChunk, 0, e.Length); | |
| _audiobuf.AddRange(validPcmChunk); |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AirPlayService.StopAsync() disposes and nulls _audioOutput without taking _audioOutputLock, so it can race with OnPCMDataReceived / OnAudioFlushReceived which also access _audioOutput under that lock. Take _audioOutputLock while disposing/nulling to ensure consistent synchronization.
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AirPlayService.Dispose() disposes and nulls _audioOutput without taking _audioOutputLock, which can race with event handlers that call _audioOutput under the lock. Use the same _audioOutputLock when disposing/nulling to avoid dispose-vs-use races.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI workflow was changed from a multi-OS/multi-config matrix to Windows-only Release publish. If the project is intended to stay cross-platform, this removes build coverage for Linux/macOS and may allow regressions to slip in. Consider keeping matrix builds for compile/test on other OSes while still publishing the win-x64 artifact.