Instrumentum III · Technical description · v0.11 · Windows 10 and 11, x64

Holy Snail Player

A light, fast, always-on-top audio player in one native exe: music files, audiobooks with chapters, internet radio with time-shift, podcasts and audio CDs. No installer, no DLLs of its own, no runtime to install.

At a glance

995 KiB
Release exe (1,018,368 bytes), icon included; a rebuild from the source download is byte for byte the same
budget 1 MiB (1,048,576 bytes)
37 ms
Launch to first paint, from an empty folder with empty settings
budget 100 ms
5.1 MiB
Private memory, idle, 10,000 tracks listed
budget 12 MiB
0 ms
CPU over 20 s while paused
timer and device stopped
12,800
Lines of C++ in the program
src/, no framework
160
Unit tests
Player_tests.exe

Measured on Windows 11 Pro with the v0.11 Release build. Full measurements are in the budget table below. Sizes are binary: 1 KiB is 1,024 bytes and 1 MiB is 1,048,576 bytes.

What it plays

SourceFormatsHow
Music filesMP3, WAV, FLAC, M4A (AAC and Apple Lossless), WMA (Standard, Pro, Lossless, Voice)Gapless, sample-exact joins. Titles from ID3v1/v2, WAV INFO and id3 chunks, FLAC comments, MP4 tags and WMA (ASF) tags; legacy Cyrillic tags detected. Protected (DRM) WMA files are refused with a message.
Audiobooks, long filesM4B, long MP3Streamed from disk. ID3 CHAP/CTOC and MP4 chapters as seek bar ticks and a Chapters menu; Prev/Next move by chapter; resume positions for anything 20 minutes or longer.
Internet radioMP3 and AAC streams (AAC-LC, HE-AAC, HE-AAC v2 in ADTS), .pls and .m3u linksThe codec is told by the Content-Type or, when the server sends none, by the first bytes. ICY titles shown when their song is reached. Pause keeps buffering (up to 20 minutes) so Play carries on behind live.
PodcastsRSS feeds, MP3, M4A and WMA episodesEpisodes stream over HTTP Range requests, nothing is downloaded; resume positions and heard marks.
Audio CDCD-DATable of contents and CD-Text read through the CD-ROM driver; raw sector reads played gaplessly; bad sectors retried, then silenced.

Audiobook mode keeps a separate one-book list. Every jump asks first, a listening log records play, pause, jumps and 30-second checkpoints, the place is recovered after a crash, and "Back to" undoes the last jump.

Stack

WinHTTP, Media Foundation, XmlLite, dwmapi, oleaut32 and the WinRT imports are delay-loaded: none of them loads before the window is painted, and most only load when their feature is first used. C++/WinRT is confined to smtc.cpp and Media Foundation to mf.cpp.

Threads and how they talk

Eight kinds of thread (UI, audio, loader, scanner, stream reader, radio, feed lister, disc lister), with no shared locks between the audio thread and anything else. Workers report to the UI thread by posted messages; the audio thread is fed by atomic pointer exchanges and lock-free rings.

Threads and how they talk: the loader, scanner and listers post messages to the UI thread; the UI thread hands each Track to the audio thread by atomic exchange and reads its id, position and change count back through atomics; the stream reader and radio threads feed the audio thread through lock-free single-producer PCM rings; the audio thread drives the WASAPI device. Loader path to Track Scanner folders, tag titles Listers feeds, CD contents WASAPI device shared mode output UI thread window, playlist, app state, copies of track metadata Audio thread current, next, switchTo, retired; one resampler across tracks Stream reader one per long track Radio HTTP, ICY, decode PostMessage with a heap payload that the UI thread frees Track handoff atomic exchange atomics: id, position, changes lock-free single-producer PCM rings file, HTTP Range or CD as byte source

Gapless playback

The engine holds three slots: next (the preloaded following track), switchTo (play this now: a jump, a new folder) and a small ring of retired tracks. Each audio callback first applies a pending switchTo or seek, then reads frames from the current track. When a track ends partway through a buffer, the engine takes next, retires the old track and keeps filling the same buffer. That is the whole gapless mechanism. Repeat One seeks the current track back to its start instead.

Decoders produce the file's own sample rate. A single linear resampler converts to the device rate and keeps its state across track changes, so joins stay sample-exact even when resampled.

A 200 ms UI timer runs only while playing. It reads the published track id, position and change counter, moves the seek bar, frees retired tracks and asks the loader for the next preload after each change.

Memory model

WhatHow it is heldMeasured cost
Files up to 64 MiBRead whole into memory and decoded on the fly; the next track preloaded the same way0.68 MiB over idle + both files
Larger files, M4A/M4B, WMA, podcast episodes, CD tracksA reader thread per track decodes into a 10-second float ring4.56 MiB over idle (143 MiB MP3)
AAC, ALAC and WMA through Media FoundationSame ring, plus Media Foundation's own state6.4 to 8.8 MiB over idle (60 min files)
RadioUp to 20 minutes of 16-bit audio, committed as it fills and released once playedabout 11 MiB per buffered minute; an AAC station adds about 1.2 MiB for its decoder

When paused or stopped, the UI timer is killed and the audio device is stopped, so the player uses no CPU. Two deliberate exceptions: a paused radio station keeps downloading for time-shift (1 to 3 ms of CPU per second), and a stream reader with a full ring checks it twice a second.

Windows integration

Hardening

Control Flow Guard (/guard:cf), CET shadow stack compatibility (/CETCOMPAT), static imports resolved from System32 only (/DEPENDENTLOADFLAG:0x800) and SetDefaultDllDirectories limited to System32 at startup, so a DLL dropped next to the exe is never loaded. The exe carries no build paths.

State on disk

%LOCALAPPDATA%\HolySnailPlayer\settings.ini, UTF-16 so that non-ASCII paths survive: the window and its modes, the music list's folder, track and position, the book's path, track and position, stations, podcasts, resume positions and heard episodes. Audiobook mode adds listening.log beside it. Nothing is written to the registry; removing the exe and that folder removes the player.

Budgets and measurements

MetricBudgetv0.11Status
Release exe size1 MiB (1,048,576 bytes)1,018,368 bytes (30,208 under), byte for byte the same when rebuilt from the source downloadmet
Launch to first paint (empty folder, empty settings)100 ms37 msmet
Private memory, idle, 10,000 tracks12 MiB5.08 MiBmet
Playing a folderidle + files + 2 MiB+0.72 MiBmet
Playing a streamed fileidle + next + 12 MiB+4.56 MiB (v0.1)met
Playing through Media Foundation (60 min AAC, ALAC, WMA; 60 s of 192 kHz ALAC)idle + next + 20 MiB+6.44 to +8.83 MiB; +18.73 MiB at 192 kHzmet
AAC radio stationidle + audio buffered + 5 MiBabout +3.2 MiBmet
CPU while playingunder 1%16 ms per 20 s (v0.1); 0.02 to 0.04% on Media Foundation filesmet
CPU while pausedabout 00 ms per 20 smet
Track to trackgaplesssample-exactmet

Testing

Building

Visual Studio 2022 or newer with the C++ build tools and the Windows SDK, plus CMake 3.21 or newer. No package manager and nothing to download.

cmake -S . -B build -A x64
cmake --build build --config Release
build\Release\Player_tests.exe

Release builds compile warning-free at /W4 with whole-program optimization.

Source map

FileRole
main.cppEntry point, single instance, command line
ui.cpp, theme.cppWindow, controls, layout, DPI, mini mode, menus; colors and owner drawing
app.cppApp state: music and book lists, transport, session restore, worker messages
audio.cppDevice, audio callback, track handoff, resampling
loader.cpp, stream.cppPath to playable Track; reader threads and PCM rings
scanner.cpp, playlist.cppFolder walk and tag titles; list, natural sort, shuffle bag, history
tags.cpp, mp4.cpp, mf.cppID3, WAV and FLAC tags and chapters; MP4 atoms; Media Foundation (AAC, ALAC, WMA)
asf.cpp, adts.cppWMA (ASF) headers: titles and DRM detection; ADTS framing of AAC stations
radio.cpp, http.cpp, podcast.cppStations and ICY; bounded GET and Range reads; RSS and station links
cd.cpp, booklog.cpp, settings.cppAudio CD; Audiobook mode's log; the INI file
smtc.cppMedia keys and flyout (the only C++/WinRT file)

License

The source code is licensed under the Apache License, Version 2.0. The name "Holy Snail Player", the snail icon and the holysnail.org look are not covered by that license; forks are welcome under a name and icon of their own. The only bundled library, miniaudio with its dr_libs decoders, is public domain or MIT No Attribution; C++/WinRT is MIT.

Download v0.11

ProgramHolySnailPlayer.exe · 995 KiB (1,018,368 bytes)

The player itself, ready to run on Windows 10 and 11 (x64). No installer: put it in any folder and start it.

SHA-256f3db70217fab8d1465f4fc389ac703c60692fb8152058eef95f02e8095e9f07b

DocumentationHolySnailPlayer-v0.11-docs.zip · 20 KiB

The user guide, how to check your downloads, the developer guide, the license and notice, trademarks and third-party notices, as plain text.

SHA-256350960157e73403604ca859987742f5192c5d99512578e32925db10405d30b13

Source codeHolySnailPlayer-v0.11-source.zip · 886 KiB

The complete source with its tests and build files. Built as described in DEVELOPERS.txt, it gives an exe identical byte for byte to the one above.

SHA-2563dafd522a97cf87595ba1ee0dd95844e4075e283063095605f9507f41c77f82f

Holy Snail Player v0.11 · Workshop of The Holy Snail