about summary refs log tree commit homepage
path: root/lib/dtas/player.rb
DateCommit message (Collapse)
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
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/
2017-03-02deduplicate strings using String#-@ (uminus) in Ruby 2.5+
This is faster than relying on eval() for older Rubies. https://bugs.ruby-lang.org/issues/13077 Ruby 2.5 is targetted for release in December 2017.
2016-12-31player: freeze sink name to avoid needless dup
Ruby Hashes will automatically create frozen copies of unfrozen strings used as hash keys to avoid accidental mutation. Pre-freeze keys explicitly so the Ruby VM will not need to create the frozen copy.
2016-12-27http -> https, and relocate homepage to https://80x24.org/dtas/
HTTPS allows some level of security(*) and we've actually supported it on 80x24.org for many months, now. So, point new readers to it. Moving away from hostname-based homepages will allow us to save on subjectAltName space (and bandwith) when negotiating an HTTPS connection. We'll also have an .onion mirror for Tor users, soon, too; in case we can't afford to pay ICANN in the future. (assuming TLS libraries don't have any more Heartblead-level bugs in them, CAs aren't compromised, MITM HTTPS stripping proxies don't get in your way, and your certificate bundle isn't compromised).
2016-01-24player: avoid allocation on sort
Hash#keys already allocates a new array, so we may sort it in place without worrying about side effects and avoiding an extra allocation.
2016-01-02copyright updates for 2016
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] git://git.savannah.gnu.org/gnulib.git
2015-12-25enable "frozen_string_literal: true"
While we're in the area, make a wording change from "GPLv3 or later" to "GPL-3.0+", as the latter is favored by SPDX.org
2015-10-04player: cleanup command dispatch
We can generate many command calls easily and dynamically, so avoid the code and cognitive overhead for the majority of commands.
2015-09-07player: add "queue cat" command
This will dump the contents of the current queue, including positional seeking information and commands. This is mainly intended for debugging and tools which rely on dtas internals.
2015-09-06use a common /dev/null
This allows us to avoid wasting time reopening the same device over and over again.
2015-04-13cleanup: avoid redundant Array conversion for escapes
We already convert xs arg to be an Array, so avoid bloating our code with redundancy.
2015-01-28player: fix queue skipping on player errors
Oops, introduced in the previous commit: commit 37eae22446feb5a805d9cd59f6ad54362829189f (player: support the "trim" parameter)
2015-01-28player: support the "trim" parameter
This feature is intended to allow users to "zoom-in" on a particular portion of a track to tweak parameters (either with dtas-sourceedit(1) or via playback of splitfx YAML files). This may be combined with looping the tracklist (via "tl repeat").
2015-01-25use omap (ordered map) for env hashes
While the Ruby Hash class is ordered in 1.9+, the YAML specifications do not specify hashes as ordered by default. Thus we must explicitly declare ordering via !omap for interopability with non-Ruby tools. This makes the YAML output of dtas-sourcedit and dtas-sinkedit slightly more verbose Users of dtas-splitfx are also encouraged to declare !omap when creating their YAML files for interoperability. Ordering env is important because any implementation of built-in variable expansion is dependent on it.
2015-01-20doc: describe most classes a bit
Hopefully this makes the code less daunting to newcomers
2015-01-19update copyright years and links to mailing list archives
The documentation part is managed by the new Documentation/update-copyright script. For the future, the rest may be managed by the update-copyright tool in gnulib
2015-01-19avoid aliasing global "spawn" method
This makes debugging, grepping, and following code confusing at times and also unexpected breaks usage of the global "spawn" method.
2015-01-06player: enqueued commands cannot use bypass
We cannot specify an audio format for bypass mode, so inherit the last one we used and hope it works.
2014-12-28source/splitfx: restart source on YAML modifications
Since splitfx YAML files are intended to be frequently edited and modified by the user, we'll support automatically restarting the source when the user saves changes via their favorite $EDITOR This change is only for Linux users. However, sleepy_penguin supports kqueue nowadays so a patch to support such functionality would be appreciated.
2014-12-27player: support playing splitfx YAML files
This allows splitfx users to test CUE breakpoints and run file-specific effects without interrupting their normal flow.
2014-06-06update copyrights and email address for 2014
I'm still normal, and still trolling, but 80x24.org will be epic :)
2014-05-26player: style cleanup to favor &:methods
This makes the code less verbose and avoids captures.
2013-12-27player: optimize away some more select calls
This keeps us from doing an extra IO.select when we know the sink buffer is readable (as we just registered a sink as writable).
2013-12-27merge some select calls for splice users
Avoid an additional select syscall in the splice path by injecting the target checks into the main loop. We can do this because we always process writers before readers. This adds additional userspace processing, but it avoids one potentially expensive (and potentially task-switching) syscall in many cases; so it should be worth it to avoid skipping with small buffer. This should avoid buffer underuns with mixed-sized buffers when using multiple sinks. This could work for the read_write path, too, but I don't use that enough and this change may still be buggy even for splice users.
2013-10-06player: delay tracklist reset until asked to play
This prevents us from resetting the tracklist when we add new tracks and want to restart playback.
2013-10-05player: add factor out redundant condition check
The addition of a "need_to_queue" method should reduce the amount of cognitive overhead required to parse these conditions
2013-09-30player: support seeking based on embedded cuesheet (FLAC)
This adds the ability to seek internally within FLAC file based on the internal CUE sheet. Other formats may be supported in the future, but FLAC is the only one I know of which supports embedded cue sheets. Note: flac 1.3.0 is recommended for users of non-CDDA-compatible formats. See updates to dtas-player_protocol(7) for details.
2013-09-28player: support bypass for rate, bits, channel
This may be used to avoid automatic: * resampling (rate) * down/upmixing (channel) * dither/truncation (bits) Using any bypass mode means we can no longer guarantee gapless playback for audio collections where rate, channel, or bits vary. This can however be useful when CPU usage is too high. This may also be useful in audio engineering situations.
2013-09-19player: stop sinks whenever we're out-of-tracks to play
We should not leave sinks running when nothing is playing, since that blocks the sound device from being used by others.
2013-09-10player: do not reset tracklist if paused
We should only reset the tracklist if the user has completely iterated through the list of tracks to be played.
2013-09-09player: s/echo/wall/ for broadcasting to all watchers
"wall" is analogous to the wall(1) command, so we shall use that instead of echo.
2013-09-09player: "tl goto" takes optional offset arg in HHMMSS.SUBSEC
This should make implementing SetPosition in the MPRIS 2.0 spec possible.
2013-09-09tracklist: next_track -> advance_track
This is a more accurate depiction of what happens, and we'll implement "next" and "previous" commands in the future.
2013-09-09player: reset tracklist when idle stat is detected
We should return to the starting position of the tracklist if we are idle.
2013-09-09player: do not repeat first track on start if using playlist
We already flush the currently playing track into the head of the queue upon player exit (even if it was in the @tl), so we should use @tl.next_track as usual instead of @tl.cur_track in case the queue is empty.
2013-09-09player: implement basic tracklist functionality
This should allow us to repeat through a list of tracks with relative ease. There is a rudimentary dtas-tl client implemented. This may be removed in the future.
2013-09-01player: explicitly stop+wait for sink death at_exit
This allows me to hit Ctrl-C on a dtas-player(1) process, wait on termination of the player, and immediately restart it without worrying about sink conflicts upon restart. Before this change, sinks would continue running for a bit (depending on buffer sizes).
2013-09-01player: add "state dump" command to serialize state
This helps in case dtas-player is hit with SIGKILL or the system crashes. This does not fsync(2) as that could introduce delays on slow filesystems. Users should open the file manually and fsync themselves if they need to.
2013-08-29remove "encoding: binary" header use
We don't need it since IO#read(bytes, buf) will convert to ASCII-8BIT anyways. Everywhere else, we ensure path names are already binary. We do this mainly at the client layer before using Shellwords to escape the paths. We also must be careful about parsing output from soxi/avprobe which can show us metadata in whatever encoding is in the file. We must still handle data from parsing command output as binary, as the encoding of file metadata tends to vary. This also should buy us Syck compatibility for Ruby 1.9.3 users on Debian systems where Ruby 1.9.3 still uses Syck.
2013-08-28add license/copyright headers/footers to all files
All files we distribute in the tarball need to have a copyright/license specified for Savannah. We don't need the example state file anymore.
2013-08-26player: do not assign @current until successful spawn
This should hopefully prevent us from getting wedged if we hit an error while preparing to spawn (or during spawn).
2013-08-26add lightly-tested ffmpeg support
Since ffmpeg/ffprobe are wrappers around their libav-variants, I haven't had the chance to actually test with "real" ffmpeg, but the usage is probably similar enough to not matter.
2013-08-26player: break out gracefully if a file is totally unplayable
Sometimes we'll enqueue the wrong file and avconv won't be able to handle it.
2013-08-26player: flesh out multi-source in protocol/sourceedit
We should be fully-capable of managing any number of options to try sources in.
2013-08-26cleanup multi-source handling between sox and av
This should better prepare us to make "source ed" into "source <av|sox> ed" and set per-source priorities. We also now treat @env consistently for all per-source commands (such as soxi/avprobe) so we can be sure we're using the same installation of sox or libav if using a non-standard PATH, or if we want to set AV_LOG_FORCE_NOCOLOR
2013-08-25player: fix logic around sink death/respawns
We do not need a respawn flag, since we already infer expected vs unexpected sink death by checking the @targets array. Additionally, next_source must always check @current before calling, and not clobber the existing @current because that would cause two source processes writing into the same pipe.
2013-08-25preliminary support for avconv/avprobe from libav
avconv is capable of outputting to the .sox format, greatly simplifying our life as it enables us to easily apply sox effects on a per-source file basis. dtas-sourceedit and the "source" protocol commands will need to change to support internal priorities (like sink).
2013-08-25split out source handling to prepare for avconv/ffmpeg support
We should've done this at the start, but we didn't.
2013-08-25player: remove unreachable branch
a sink can never have respawn set and not be active