about summary refs log tree commit homepage
path: root/lib/dtas
DateCommit message (Collapse)
2024-02-01dtas-splitfx: add --stats/-S switch HEAD master
Similar to the switch in dtas-archive(1), I got tired of having to manually add stats to all the rips I was tracking out.
2024-01-27drop MSG_EOR for AF_UNIX + SOCK_SEQPACKET
Using MSG_EOR with these local sockets is not necessary, and appears to trigger a truncation bug on OpenBSD 7.3. Link: https://marc.info/?i=20230826020759.M335788@dcvr
2024-01-27av_ff_common: use mcache
As with soxi(1), waiting for ffprobe(1) or avprobe(1) is still an expensive operation despite Process.spawn being optimized to use vfork(2).
2024-01-27av_ff_common: attempt to fix encodings for ffprobe/avprobe
As with sox, these will be dealing with legacy encodings and badly-encoding software until the end of days, so do our best to fix them up.
2023-10-12favor ffmpeg over deprecated avconv
When this project started avconv was favored in Debian, but that hasn't been the case in many years. Increase the priority of ffmpeg to match the current situation in Debian.
2023-10-12av_ff_common: set TRACKNUMBER comment from "track"
ffprobe aways says `track' instead of `TRACKNUMBER'; but the rest of our code follows FLAC metadata conventions; so use `TRACKNUMBER'. (avprobe is untested since the libav project is dead)
2022-08-14player: drain sinks completely before changing sink rate
For users of the CPU-saving bypass mode (e.g. "format rate=bypass"), this fixes a bug when enqueueing a 44.1kHz immediately after a 48kHz file (or vice-versa). Note: gapless playback with different rates/channels between tracks has never been supported with bypass mode enabled. Bypass only allows opportunistic gapless when sequential tracks have the same format.
2022-07-16splitfx: warn on improper encodings for titles
Sometimes I get non-English song titles and copy+paste them from non-UTF8 texts.
2022-02-12splitfx: fix error reporting of failed tracks
Sometimes the command fails on certain tracks, and we need to use the proper track object for error reporting.
2022-02-03splitfx: disallow combining --trim and --filter
They're two different ways of accomplishing roughly the same thing, but --filter can be more flexible given the use of per-track environment variables.
2022-01-24player: expire sox metadata cache on file st_ctime changes
We still need the TTL to deal with fuse.sshfs and maybe other weird FSes which don't return the st_ctime properly.
2022-01-24splitfx: add --filter option to limit match to comments
This can allow filtering for tracks with a given comment declared via the ".#{COMMENT}" mechanism or the track title. If no prefix is given (before the '='), then all comment values are matched.
2022-01-24splitfx: support per-track environment variables
This allows setting the `FX' env on a per-track basis, since some recordings may have massive dynamic shifts which aren't desirable for casual listening or broadcast playback.
2022-01-23do not check IO#closed? before calling IO#close
IO#close is idempotent since Ruby 2.3, so reduce our instruction footprint to save some memory.
2022-01-23unix_accepted: drop Ruby < 2.3 support code
This should save a little bit of memory for current users.
2022-01-23get rid of DTAS::Nonblock wrapper for Ruby <= 2.0
We require 2.3+, nowadays, so jettison a bunch of code.
2022-01-23use IO#wait_readable consistently
Since Ruby 2.3, it no longer checks FIONREAD, and we require Ruby 2.3+ nowadays, so drop our IO.select-based workarounds.
2022-01-21dtas: drop unnecessary "require 'yaml'" statements
We use DTAS.yaml_load to wrap all YAML.*load calls, but we still need "require 'yaml'" for various .to_yaml calls.
2022-01-21player: remove omap conversion
"omap" is specific to Ruby and makes interopability with other languages more difficult. While it's true environment variables are stored as an ordered array of C strings (see environ(7)); order doesn't matter in practice. Everyone in the real world treats the environment as an unordered key-value store. Followup-to: cac63517e7f751cc (doc: drop ordered map from examples, 2022-01-07)
2022-01-21deduplicate and freeze pathnames + metadata
This ought to save some memory for dtas-player and dtas-readahead users with multiple instances of the same track(s) on their track list.
2022-01-21use YAML.unsafe_load in Psych 4.x (Ruby 3.1+)
Psych 4.x defaults to "nanny mode" to handle untrusted data. This causes breakage with since YAML references (aliases) emitted by dtas-player can't be handled by Psych clients under Ruby 3.1. Since dtas is single user and is a shell designed to run arbitrary code, favor the new YAML.unsafe_load API which behaves like the old YAML.load in Ruby <= 3.0.
2022-01-21get rid of DTAS.dedupe_str wrapper
Ruby 2.3+ supports String#@-, though it did not deduplicate strings. But 2.5 is already old at this point and most users can be expected to have it. This gives some memory regressions for Ruby <= 2.4 users, but cuts down on the code we maintain and reduces bytecode overhead for 2.5+ users.
2022-01-21require Ruby 2.3+
This allows us to jettison a bunch of compatibility code since we've started using Etc.nprocessors and String#- (uminus) in more places. The Ruby core team doesn't support <= 2.5, even.
2022-01-11player: reduce syscalls when splicing to single target
splice(2) alone does not give enough information as to whether the source or destination is blocking. However, as far as audio playback chain goes, the sink should ALWAYS be the limiting factor as decoder sources need to be able to produce data at least as fast as the audio is being played (otherwise there'll be audible drops). Thus, we bias the select(2) into waiting on a targets on if we splice(2) less than the data we requested.
2022-01-11splitfx: fix track_zpad with integer arg
This is a rarely-needed corner-case, but I just needed to use this feature.
2021-05-25do not shell-quote filenames for environment
This allows dtas-player to play files with wonky filenames when piping ffmpeg (or avconv) to sox. SoX-only code dtas-player paths are not affected since they don't require an extra Bourne shell. All of our internal shell pipelines quote "$INFILE", anyways, so there was never any need to escape for those. This may cause compatibility problems for splitfx users, but splitfx is probably too esoteric to have any users besides myself. And I expect anybody editing audio with dtas-splitfx to pick shell-friendly filenames. dtas-player is far more general, and likely to encounter shell-unfriendly filenames which require quoting.
2021-03-21mlib: pathnames may be blobs
POSIX filesystems do not enforce encodings, so we'll convert non-UTF-8 filenames to blobs for SQLite instead of failing on encoding errors. This should allow us to work on collections which feature legacy encodings.
2020-09-29encoding: use CharlockHolmes properly on first run
Ruby case/when is not like C with fall-through, so we can't rely on fall-through behavior to use CharlockHolmes to detect legacy encodings.
2020-05-27player: fix +/- directional seeks while paused
Using relative seek (Up/Dn/PgUp/PgDn) with dtas-console while dtas-player is paused was causing non-sensical/confusing results on unpause. So clamp the minimum seek time to 0s the same way we clamp during playback.
2020-04-20splitfx: support --err-suffix option
Write the contents of "stderr". This is useful for capturing the per-track output of the sox(1) "stats" effect when combined with parallel "--jobs".
2020-04-20splitfx: reduce syscalls for writing comments file
We can flush when all comments are buffered to avoid a writev(2) syscall on every comment.
2020-02-03doc: update copyrights for 2020
Using the 'update-copyright' script from gnulib[1]: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright [1] https://git.savannah.gnu.org/git/gnulib.git
2020-01-06watchable: use fiddle for inotify support
We have String#unpack at our disposal for working with "struct inotify_event", so use it instead of depending on an extension which requires a compiler and development headers to install.
2020-01-06buffer: replace sleepy_penguin with fiddle
Fiddle exists on all Ruby 1.9.2+ installations and seems alright. Since splice is a Linux-only API, we don't need to worry about the values of constants changing (and they're architecture-independent).
2020-01-06provide fiddle-based eventfd implementation
sleepy_penguin requires a compiler and development headers to install, so it could be a PITA to install for users on distro-provided Ruby. Allow fiddle since it's part of the Ruby standard library since 1.9.2 and users won't have to install anything else.
2020-01-06pipe: avoid loading sleepy_penguin
The values of F_{GET,SET}PIPE_SZ are architecture-independent and stable in Linux (unlike Ruby :P), so we won't need to bother loading an extra .so here for two constants.
2019-11-02player: automatically pause if last sink dies
Attempting to play (and fail) every song in the queue or tracklist is not ideal when a the USB/HDMI cable to the sound device gets unplugged by accident. When tee-ing to multiple sinks, we will still gracefully continue if one goes dead and there are remaining sinks. Suggested-by: Rene Maurer Link: https://80x24.org/dtas-all/874l0kb9qm.fsf@loco10.cumparsita.ch/
2019-11-02buffer/splice: pass kwargs as-is to tee/splice
Ruby 2.7.0dev will warn when hashes are passed and intended for use as kwargs unless we expand the hash via "**TRY", but "**" is Ruby 2.0+ syntax and I guess we still support 1.9.3 for the time being.
2019-01-02splice: fix missing F_NONBLOCK flag for single output
This fixes hanging when using a single audio output for Linux users using splice.
2019-01-02dtas 0.16.0 v0.16.0
A bunch of minor fixes and cleanups accumulating for the past two years since the last release. It's tough to remember to make releases when I'm always running the latest version from git :x Most notably, "io_splice" is no longer used for dtas-linux users since "sleepy_penguin" includes all the functionality we use. This is to reduce memory overhead from extra DSOs(*) There's also some deprecation warning fixes for the still-undocumented "dtas-mlib" command. 12 changes since v0.15.0 (2017-04-07): pipeline: new module for running process pipelines console: ensure time calculations are done in UTC Rakefile: update path for uploads player: support guessing encodings for comments get rid of Windows-31J regexps mlib: compatibility with Sequel 5.x mlib: remove redundant tag massaging and encoding mlib: use flock to get around SQLite busy errors mlib: ignore files with nil times dtas/watchable: check SystemCallError mlib: fix unused variable warning use sleepy_penguin 3.5+ for splice and tee support (*) https://udrepper.livejournal.com/8790.html
2019-01-02use sleepy_penguin 3.5+ for splice and tee support
Eliminate loading of the io_splice RubyGem to reduce memory overhead. Extra DSOs are wasteful and io_splice is being phased oiut for sleepy_penguin, which encapsulates more Linux-specific functionality anyways. cf. https://udrepper.livejournal.com/8790.html
2019-01-02mlib: fix unused variable warning
2019-01-02dtas/watchable: check SystemCallError
Sometimes files become unreadable.
2018-01-30mlib: ignore files with nil times
It happens with some video files, apparently.
2018-01-30mlib: use flock to get around SQLite busy errors
The SQLite busy waiting scheme isn't great for usability and the busy timeout is done by sleep+backoff. I prefer to say we only support filesystems with flock() for our little DB.
2018-01-29mlib: remove redundant tag massaging and encoding
Redundant since ("player: support guessing encodings for comments")
2018-01-29mlib: compatibility with Sequel 5.x
Apparently some degree of thread-safety is being enforced; not sure I agree, but oh well...
2018-01-29get rid of Windows-31J regexps
Oops, a Perlism crept in :x
2018-01-29player: support guessing encodings for comments
This can be helpful for end users and is close to what other players use. We can fallback to Encoding.default_external by default (typically UTF-8) and then again using `charlock_holmes' if installed. Note: path names remain binary, because that's how proper filesystems operate.
2017-04-28pipeline: new module for running process pipelines
This should allow us easily to manipulate process pipelines as an array of arrays. Originally posted at http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/435624