Coder Social home page Coder Social logo

connor-brooks / play_stdin.sh Goto Github PK

View Code? Open in Web Editor NEW
59.0 6.0 3.0 17 KB

A set of lightweight scripts to stream audio between two *nix machines. Perfect for use with a Raspberry Pi

Home Page: http://connor-brooks.com/play_stdin.sh.html

License: GNU General Public License v2.0

Shell 100.00%
streaming-audio minimalist hacky music-streaming raspberry-pi audio stream

play_stdin.sh's People

Contributors

connor-brooks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

play_stdin.sh's Issues

remove pipe on exit

Thanks for the nice sample code of a simple bash -based 'server' that takes commands from a remote client.

When play_stdin_server.sh exits abnormally (control-C, for example), the /tmp/play_stdin_server pipe is left lying around.

Not a huge deal, but it would be cleaner if the script removed it. If I run the script, do a control-C and run it again, I get an error message as the script tries to create the already existing pipe.

Use the 'trap on EXIT' feature of bash to ensure a cleanup function is run no matter how the script exits - both normally and abnormally

Just before "#Create the pipe", add:

always_run_on_exit () {
   # Use -f so that there is no error if the pipe does not yet exist or was already removed
   rm -f $CONTROLLER_PIP_FILE
}

# No matter how the script exits, ensure pipe gets removed
trap always_run_on_exit EXIT

Then you can remove the 'rm $CONTROLLER_PIPE_FILE' from server_exit() too. Although there's no harm in leaving it there as the 'cleanup_server_fifo' function uses 'rm -f' which won't report an error when trying to remove something that's not there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.