From a8874e32a45896670ac01e4c6b92b4aee37dda8e Mon Sep 17 00:00:00 2001 From: Vlad-Stefan Harbuz Date: Tue, 7 Feb 2023 23:25:02 +0100 Subject: [PATCH] add cmd/podtest --- .gitignore | 1 + Makefile | 11 +++++++++++ README.md | 4 ++++ cmd/podtest/main.ha | 30 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 cmd/podtest/main.ha diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..25a619b --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +.POSIX: +.SUFFIXES: + +bin/podtest: + mkdir -p bin + $(VARS) hare build $(LIBS) -o bin/podtest cmd/podtest + +run: + $(VARS) hare run $(LIBS) cmd/podtest + +.PHONY: run diff --git a/README.md b/README.md index 8b71dd9..6d9577e 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,7 @@ The implementation currently has basic functionality but is easy to extend. ``` git subtree -P vendor/hare-spapod/ add https://git.sr.ht/~vladh/hare-spapod main ``` + +## Tests + +There is a small test you can run with `make run`. diff --git a/cmd/podtest/main.ha b/cmd/podtest/main.ha new file mode 100644 index 0000000..0f0b585 --- /dev/null +++ b/cmd/podtest/main.ha @@ -0,0 +1,30 @@ +use fmt; +use sp = spapod; + +def DEFAULT_RATE: u32 = 44100; +def DEFAULT_CHANNELS: u32 = 2; + +export fn main() void = { + let buf: []u32 = alloc([0...], 1024); + let b: sp::builder = sp::builder { ... }; + sp::push_object(&buf, &b, + sp::spa_type::OBJECT_Format, + sp::spa_param_type::EnumFormat: u32); + sp::add_prop(&buf, &b, sp::spa_format::mediaType: u32, 0); + sp::add_id(&buf, &b, sp::spa_media_type::audio); + sp::add_prop(&buf, &b, sp::spa_format::mediaSubtype: u32, 0); + sp::add_id(&buf, &b, sp::spa_media_subtype::raw); + sp::add_prop(&buf, &b, sp::spa_format::AUDIO_format: u32, 0); + sp::add_id(&buf, &b, sp::spa_audio_format::S16); + sp::add_prop(&buf, &b, sp::spa_format::AUDIO_rate: u32, 0); + sp::add_int(&buf, &b, DEFAULT_RATE: i32); + sp::add_prop(&buf, &b, sp::spa_format::AUDIO_channels: u32, 0); + sp::add_int(&buf, &b, DEFAULT_CHANNELS: i32); + sp::add_prop(&buf, &b, sp::spa_format::AUDIO_position: u32, 0); + sp::push_array(&buf, &b, sp::spa_type::Id, size(u32): u32); + sp::add_array_val(&buf, &b, 69); + sp::add_array_val(&buf, &b, 420); + sp::pop(&buf, &b); + sp::pop(&buf, &b); + sp::print_buffer(&buf, &b); +}; -- 2.45.2