Skip to content

Feature/spm library product#1

Merged
dsward2 merged 10 commits into
mainfrom
feature/spm-library-product
Jun 9, 2026
Merged

Feature/spm library product#1
dsward2 merged 10 commits into
mainfrom
feature/spm-library-product

Conversation

@dsward2

@dsward2 dsward2 commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Merge changes for shared TLS certificates.

dsward2 and others added 10 commits June 8, 2026 11:16
Set up the new SwiftPM library target and product so external packages
can depend on us, with a placeholder source file. Sources move in the
next commit. Executable target and tests unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Splits the package into two targets:

  - LiveAudioServerCore (new library product): all the server, encoding,
    streaming, and config logic. Exposes a public façade:
      * struct ServerConfig (aka LiveAudioServerConfig typealias)
      * final class LiveAudioServer with init(config:), start() async throws,
        stop() async, isRunning
      * enum LiveAudioServerError for setup-failure cases
      * func parseCLI(_:) -> CLIParseResult — pure, testable
      * version/notice constants
  - LiveAudioServer (executable): a thin shim around the library that does
    argv parsing, signal handling, and process exit.

CLame is now a dependency of the library, not the executable. Tests now
@testable import LiveAudioServerCore.

Behavior changes:
  - HTTPServer.swift no longer calls exit(1) when its NWListener enters the
    .failed state; library code never terminates the process.

Behavior unchanged:
  - CLI flags, defaults, exit codes, on-the-wire protocol all identical.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds LiveAudioServerLogger protocol with SilentLogger and StderrLogger
implementations, plus a process-wide LiveAudioServerLogging.logger sink.
The library's log() function now hands every formatted line to that
sink instead of calling fputs(stderr) directly.

The default logger is SilentLogger so a SwiftPM consumer never gets
stderr output unless they opt in. The CLI shim installs StderrLogger
at startup, preserving identical CLI output.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Four new tests under "LiveAudioServer public API" exercise the public
façade the way a host SwiftUI app would:

- LiveAudioServerConfig defaults match CLI defaults.
- start() then GET /status.json then stop() round-trips cleanly, with
  isRunning flipping true → false at the boundaries. Encoders are
  disabled in this test to sidestep a libmp3lame assertion that fires
  when lame_encode_flush runs without any frames having been encoded
  (real flow always has frames).
- stop() on a never-started server is a no-op.
- Calling start() while already running throws .alreadyRunning.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Documents the new LiveAudioServerCore library product: SwiftPM
dependency snippet, public API usage example (config + start/stop), and
integrator notes (multi-instance, SIGPIPE, encoder lifecycle gotcha,
which module to import).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The build_arch helper echoed its progress line on stdout alongside the
swift build --show-bin-path output, so $(build_arch arm64) captured both
and the subsequent binary-existence check looked at a malformed path.
Redirect the progress echo to stderr so only the bin path lands in the
captured stdout.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Swap the NSLock guarding LiveAudioServer's running flag for a serial
DispatchQueue, because NSLock.lock()/unlock() trip a Swift 6 availability
warning inside async functions while DispatchQueue.sync is async-safe and
gives the same mutual exclusion. With the lock replaced, mark both
LiveAudioServer and PCMReader @unchecked Sendable so host apps can hold
them across actor boundaries.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Updates Version.swift and the README's SwiftPM dependency snippet and
sample Bonjour TXT records to 0.1.3.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds ServerConfig.tlsIdentity (sec_identity_t) so embedders can share one
already-loaded identity across multiple listeners instead of re-reading
the .p12 from disk. The CLI continues to use tlsIdentityPath/tlsPassword;
the new field takes precedence when set. Makes loadTLSIdentity and
TLSIdentityError public so hosts can reuse the existing loader.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dsward2 dsward2 merged commit ace4b34 into main Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant