Test hosted audio and art on Kryon's raylib-free paths
The native audio test installs MediaAudioUseDesktop from kryon/media_audio_desktop: Kryon's desktop mixer pulls through its SDL sink on SDL's paced dummy driver, linking SDL2 and libopus instead of raylib and a miniaudio null build. The art test decodes the recovered preview through kryon/image_pixels (GdkPixbuf on first use) and checks the same 1x1 opaque RGB pixel, with no raylib rtextures build or stubs. The README documents the desktop provider and the RAYLIB_A-free test command. Local tests: full Apps suite through build-queue on a clean tree, including art_host_test.py and audio_host_test.py (dummy and desktop/SDL modes). Owner-request: Waozi, 2026-11-16 (remove raylib dependencies) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
67213658ed
commit
04bedb0f6f
5 files changed
+29
-46
No files matched your search
@@ -151,7 +151,7 @@ position. Legacy Media services retain their existing dispatch and permission
|
||||
policy.
|
||||
|
||||
The native consumer installs its provider once on its owning thread with
|
||||
`MediaAudioUseRaylib()` from `kryon/media_audio_raylib`. Without a provider,
|
||||
`MediaAudioUseDesktop()` from `kryon/media_audio_desktop`. Without a provider,
|
||||
authorized calls return `Unsupported`; device/browser results retain Kryon's
|
||||
`Unavailable`/`Suspended` semantics. Apps supplies each actual `HostedApp.audio`
|
||||
owner and `AppHostAudioRead` to `WidgetHostAudioCall`, using the active node's
|
||||
@@ -280,7 +280,7 @@ verifies public package imports and launcher search/grouping.
|
||||
copy, one transfer at a time and waiting 1 s, doubling to 60 s, between attempts.
|
||||
`python3 tests/art_host_test.py /path/to/libziran.a` serves a real HTTP failure,
|
||||
then decodes the recovered art's pixels without a display.
|
||||
- `RAYLIB_A=/path/to/libraylib.a python3 tests/audio_host_test.py /path/to/libziran.a`
|
||||
exercises real hosted guests with dummy/no-provider and private null-device
|
||||
Raylib hosts. Run `tests/native_fixture.py`, `tests/consumer_test.py` and
|
||||
- `python3 tests/audio_host_test.py /path/to/libziran.a`
|
||||
exercises real hosted guests with dummy/no-provider hosts and Kryon's desktop
|
||||
mixer on SDL's private dummy device. Run `tests/native_fixture.py`, `tests/consumer_test.py` and
|
||||
`tests/tree_test.sh` with the same resolved compiler/runtime graph too.
|
||||
@@ -15,7 +15,9 @@
|
||||
#import "kryon/hosted_app"
|
||||
#import "kryon/hosted_values"
|
||||
#import "kryon/file_download"
|
||||
#import "art_decode"
|
||||
#import "kryon/image_pixels"
|
||||
#import "std/image"
|
||||
#import "std/vec"
|
||||
transfer: FileDownload;
|
||||
requests: s32;
|
||||
bundle_calls: s32;
|
||||
@@ -23,8 +25,6 @@ libc :: #system_library "libc";
|
||||
PreparationTestBegin :: () #foreign libc;
|
||||
PreparationTestYield :: () #foreign libc;
|
||||
PreparationTestNow :: () -> float64 #foreign libc;
|
||||
art_raylib :: #system_library "raylib";
|
||||
ArtUnloadImage :: (image: RaylibGlyphImage) #foreign art_raylib "UnloadImage";
|
||||
rejected: s32;
|
||||
cached: string;
|
||||
ArtBundle :: (context: *void, parent: *AppNode, entry: *AppEntry) -> HostedAsset {
|
||||
@@ -93,12 +93,14 @@ ArtCheck :: () -> s32 {
|
||||
PreparationTestYield()
|
||||
}
|
||||
if !preview.found || requests != 4 { return 7 }
|
||||
// Decode through Kryon's actual native CPU decoder, then inspect pixel data.
|
||||
image := RaylibDecodePixels(preview.data, ".png")
|
||||
if image.data == null || image.width != 1 || image.height != 1 || image.format != 4 { return 8 }
|
||||
pixel := cast(*u8)image.data
|
||||
correct := pixel[0] == 40 && pixel[1] == 160 && pixel[2] == 100
|
||||
ArtUnloadImage(image)
|
||||
// Decode the recovered bytes through Kryon's actual desktop CPU decoder,
|
||||
// which reads a file, then inspect its straight RGBA pixel data.
|
||||
decoded := FixtureEnvironment("APPS_ART_PREVIEW")
|
||||
if !WriteEntireFile(decoded, preview.data) { return 8 }
|
||||
image := LoadImagePixels(decoded)
|
||||
if image.width != 1 || image.height != 1 || image.pixels.count != 4 { VecFree(image.pixels); return 8 }
|
||||
correct := image.pixels[0] == 40 && image.pixels[1] == 160 && image.pixels[2] == 100 && image.pixels[3] == 255
|
||||
VecFree(image.pixels)
|
||||
if !correct { return 9 }
|
||||
FileDownloadRelease(*transfer)
|
||||
if !SlimStop(*host) { return 10 }
|
||||
|
||||
+8
-21
@@ -5,7 +5,6 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
@@ -48,14 +47,12 @@ def main():
|
||||
(assets / 'preview.png').unlink()
|
||||
(assets / 'apps/apps.zx').unlink()
|
||||
native.bundle('collection', root, assets)
|
||||
toolchain, kryon, raylib = [Path(subprocess.check_output(
|
||||
[native.ZIRAN, 'pkg', 'path', name], cwd=ROOT, text=True).strip())
|
||||
for name in ('ziran', 'kryon', 'raylib')]
|
||||
toolchain = Path(subprocess.check_output(
|
||||
[native.ZIRAN, 'pkg', 'path', 'ziran'], cwd=ROOT, text=True).strip())
|
||||
mapping = WORK / 'module-map.tsv'
|
||||
lines = (ROOT / 'build/.ziran/module-map.tsv').read_text().splitlines()
|
||||
lines += ['M\troot\tnative_behavior\t' + str(ROOT / 'tests/native_behavior.zi'),
|
||||
'M\troot\tart_host_behavior\t' + str(ROOT / 'tests/art_host_behavior.zi'),
|
||||
'D\troot\tart_decode\t' + kryon.name + '\traylib_image_decode']
|
||||
'M\troot\tart_host_behavior\t' + str(ROOT / 'tests/art_host_behavior.zi')]
|
||||
mapping.write_text('\n'.join(lines) + '\n')
|
||||
os.environ['ZIRAN_PACKAGE_MAP'] = str(mapping)
|
||||
output = WORK / 'c'
|
||||
@@ -66,26 +63,15 @@ def main():
|
||||
'int main(void) { int r=ArtCheck(); if(r) fprintf(stderr,"Apps art test %d failed\\n",r); return r?1:0; }\n')
|
||||
includes = [arg for p in [output, *sorted(output.rglob('*'))] if p.is_dir() for arg in ('-iquote', str(p))]
|
||||
cc = os.environ.get('CC', 'cc')
|
||||
# Only Raylib's CPU image decoder is linked; no window or graphics context exists.
|
||||
support = WORK / 'raylib_support.c'
|
||||
support.write_text('#include <stdlib.h>\n'
|
||||
'void TraceLog(int level, const char *text, ...) { (void)level; (void)text; }\n'
|
||||
'void *MemAlloc(unsigned int size) { return calloc(size, 1); }\n'
|
||||
'void *MemRealloc(void *data, unsigned int size) { return realloc(data, size); }\n'
|
||||
'void MemFree(void *data) { free(data); }\n'
|
||||
'const char *rlGetPixelFormatName(unsigned int format) { (void)format; return ""; }\n')
|
||||
decoder = WORK / 'rtextures.o'
|
||||
run(cc, '-O1', '-ffunction-sections', '-fdata-sections', '-I' + str(raylib / 'src'),
|
||||
'-c', raylib / 'src/rtextures.c', '-o', decoder)
|
||||
# Kryon's desktop decoder loads the system GdkPixbuf on first use; no
|
||||
# window or graphics context exists.
|
||||
executable = WORK / 'test'
|
||||
webp_libs = shlex.split(subprocess.check_output(
|
||||
['pkg-config', '--libs', 'libwebpdemux', 'libwebp'], text=True))
|
||||
run(cc, '-std=c11', '-O1', '-ffunction-sections', '-fdata-sections',
|
||||
'-I' + str(toolchain / 'include'), *includes, *sorted(output.rglob('*.c')),
|
||||
ROOT / 'tests/preparation_host.c', support, sys.argv[1], decoder,
|
||||
ROOT / 'tests/preparation_host.c', sys.argv[1],
|
||||
'-Wl,--gc-sections', '-Wl,--wrap=BundleOpenBytes',
|
||||
'-Wl,--wrap=BundleInstantiate', '-Wl,--wrap=BundleInstanceRun', '-Wl,--wrap=BundleClose',
|
||||
*webp_libs, '-lm', '-lpthread', '-o', executable)
|
||||
'-ldl', '-lm', '-lpthread', '-o', executable)
|
||||
class Handler(http.server.BaseHTTPRequestHandler):
|
||||
calls = 0
|
||||
def do_GET(self):
|
||||
@@ -107,6 +93,7 @@ def main():
|
||||
thread.start()
|
||||
env = dict(os.environ, APPS_ART_URL=f'http://127.0.0.1:{server.server_port}/art.zx',
|
||||
APPS_ART_DESTINATION=str(WORK / 'download.zx'),
|
||||
APPS_ART_PREVIEW=str(WORK / 'preview.png'),
|
||||
APPS_FIXTURE_SLIM_ROOT_BUNDLE=str(root), APPS_FIXTURE_SLIM_ROOT_SHA256=native.digest(root),
|
||||
APPS_FIXTURE_UI_BUNDLE=str(controller), APPS_FIXTURE_HARNESS_SHA256=native.digest(controller))
|
||||
try:
|
||||
|
||||
@@ -27,7 +27,7 @@ Node :: #import "node_types";
|
||||
#import "kryon/media_audio"
|
||||
#import "kryon/media_audio_host"
|
||||
#if #defined(APPS_AUDIO_NATIVE_TEST) {
|
||||
#import "kryon/media_audio_raylib"
|
||||
#import "kryon/media_audio_desktop"
|
||||
}
|
||||
using HostValueKind;
|
||||
using FrameStatus;
|
||||
@@ -85,7 +85,7 @@ AudioDummy :: (voice: *MediaAudioVoice, command: MediaAudioCommand, bytes: strin
|
||||
}
|
||||
AudioInstall :: () {
|
||||
#if #defined(APPS_AUDIO_NATIVE_TEST) {
|
||||
MediaAudioUseRaylib()
|
||||
MediaAudioUseDesktop()
|
||||
} else {
|
||||
MediaAudioUseProvider(AudioDummy)
|
||||
}
|
||||
|
||||
@@ -64,14 +64,6 @@ def main():
|
||||
os.environ['APPS_AUDIO_' + kind + '_SHA256'] = native.digest(path)
|
||||
toolchain = Path(subprocess.check_output([ZIRAN, 'pkg', 'path', 'ziran'], cwd=ROOT, text=True).strip())
|
||||
kryon = Path(subprocess.check_output([ZIRAN, 'pkg', 'path', 'kryon'], cwd=ROOT, text=True).strip())
|
||||
raylib = Path(os.environ['RAYLIB_A'])
|
||||
# Use Raylib's actual decoder/mixer with miniaudio's paced null backend.
|
||||
# ALSA null consumes without pacing and cannot verify a playback clock.
|
||||
audio_source = raylib.parent / 'source/raudio.c'
|
||||
null_audio = WORK / 'null-audio.o'
|
||||
run(os.environ.get('CC', 'cc'), '-O1', '-ffunction-sections', '-fdata-sections',
|
||||
'-DMA_ENABLE_ONLY_SPECIFIC_BACKENDS', '-DMA_ENABLE_NULL',
|
||||
'-I' + str(audio_source.parent), '-c', audio_source, '-o', null_audio)
|
||||
# Like consumer_test.py, extend the actual resolved package map only for
|
||||
# test entry modules outside the package's published module roots.
|
||||
mapping = WORK / 'module-map.tsv'
|
||||
@@ -92,7 +84,9 @@ def main():
|
||||
includes = [arg for p in [output, *sorted(output.rglob('*'))] if p.is_dir() for arg in ('-iquote', str(p))]
|
||||
libs = []
|
||||
if actual:
|
||||
libs = [str(null_audio), str(raylib), *subprocess.check_output(['pkg-config', '--libs', 'sdl2', 'libdrm', 'gbm', 'egl', 'glesv2', 'opus'], text=True).split(), '-ldl']
|
||||
# Kryon's desktop mixer pulls through its SDL sink; SDL's dummy
|
||||
# driver paces that pull like a device clock and opens no device.
|
||||
libs = subprocess.check_output(['pkg-config', '--libs', 'sdl2', 'opus'], text=True).split()
|
||||
executable = WORK / 'test'
|
||||
run(os.environ.get('CC', 'cc'), '-std=c11', '-O1', '-ffunction-sections', '-fdata-sections',
|
||||
'-I' + str(toolchain / 'include'), *includes, *sorted(output.rglob('*.c')),
|
||||
@@ -110,7 +104,7 @@ def main():
|
||||
if result.returncode:
|
||||
print((result.stdout + result.stderr)[-6000:])
|
||||
result.check_returncode()
|
||||
print('Apps audio: ' + ('actual Raylib/null device' if actual else 'dummy/no provider') + ' passed')
|
||||
print('Apps audio: ' + ('actual desktop mixer/SDL dummy device' if actual else 'dummy/no provider') + ' passed')
|
||||
print('Apps audio package: ' + str(kryon))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user