Coder Social home page Coder Social logo

defender-headunit's People

Contributors

sjoerd82 avatar

Watchers

 avatar

defender-headunit's Issues

PID file

  1. Create PID files for hu.py and daemon scripts.
  2. Use PID files in init scripts (kill and restart)

decentralization and logging

Add logging to syslog:
https://docs.python.org/2/library/logging.handlers.html

Now that we move the code into smaller microservices, logging to file deserves some attention. Logging to the same file is not longer feasible, from a file locking p.o.v.

Logging to separate files is useful (better than no logging), but it will lack the context. To understand a situation one would need to piece back together all separate files to really appreciate what happened.

Before closing the issue, make sure that if a future improvement is wanted, to create an issue for that.

Options:

  1. Move away from the file logger altogether in favor of the syslog. (for now)
  2. Create a separate microservice for logging. (future, perhaps)
  3. Log to separate files. (declined)

Make folder lists smarter

Folder lists keep track of the directory start positions in the playlist, to skip to the next folder.
Generating them may take a few secs, so you don't want to do it too often.

Currently they are saved, but not re-used.
Devise a smart way that minimises the re-creation, and re-use them where possible.

Configuration Tool

Now that the project is growing, more and more configurable options are starting to pop into existence. Some of which are crucial for playback, such as the correct PulseAudio sink and MPD output.

Remote configuration/setup/bootstrapping becomes more and more important, esp. if a setting cannot be defaulted or auto-detected.

Proposed solution:
-config-tool.py, for R/W on configuration.json
-hu.py may R from configuration.json (and call it for initialization, if the config file is missing)
-A web API (flask?) can call config-tool.py to configure the application (and restart hu.py)

  • #TODO = Web API (flask?)
  • in the future, we may create a configuration command line interface on SSH for this

Advanced random modes

Random button:

normal press:
[Off] <-> normal press<-> [All tracks]
[Random Current Folder] -> [Off]
[Random Current Genre] -> [Off]

long press:
[Off] -> long press -> [Random Current Folder]
[Random Current Folder] -> [Random Current Genre]

Long ops. feedback

Feedback (GPIO, LED / SFX) to notify long operations (esp. if blocking) are still going on.

Implement Equalizer

  • Define presets
  • Implement a way to control presets
  • Implement a way to control individual frequencies

Implementation options:

ecasound
Pros: Quality?
Cons: Can we update on-the-fly??
pulse
Pros: EQ already build-in. On-The-Fly.
Cons: PA has, so-far, not been easy to control (in 9.0.. try new v11). Quality?
alsa
Pros: on-the-fly
Cons: Add package alsaequal (custom, seems a bit deprecated?). How to control? Quality?

S91update to start new init scripts

Use configuration.json ["daemons"] to stop/start daemons

Old:
If there are new init scripts after an update these need to be started.
Possibly restart all hu-related scripts? (=easiest)

Inotify on SMB and Local media folders

Add inotify watchers on SMB and Local media folders (SMB might be tricky).
New/Deleted files must trigger hu.py to update db and playlists, as smart as possible.

detect ifup/ifdown and update sources accordingly

hu.py already has a signal for ifup, but haven't figured out yet how to send it from the ifupdown scripts using dbus-send.

WORKAROUND:
As a workaround the cb_ifup() function is plugged in the MPD message system.
mpc sendmessage ifup XXX
mpc sendmessage ifdown XXX

ACTION: figure out the syntax for dbus-send, add it to the ifupdown scripts and remove the workaround.

Ifupdown scripts are here:
/etc/network/if-up.d
/etc/network/if-down.d

error: [Errno 32] Broken pipe

Version: 0.1.0-777-g39c2807

[ MPD ] DBUS event received: player
[SYSTEM] Detected MPD event: player. Retrieving MPD state.
ERROR:dbus.connection:Exception in handler for D-Bus signal:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 230, in maybe_handle_message
File "./hu.py", line 441, in cb_mpd_event
status = mpdc.mpc_get_status()
File "/mnt/PIHU_APP/defender-headunit/hu_mpd.py", line 356, in mpc_get_status
self.mpdc.command_list_ok_begin()
File "usr/lib/python2.7/site-packages/mpd.py", line 583, in command_list_ok_begin
File "usr/lib/python2.7/site-packages/mpd.py", line 279, in _write_command
File "usr/lib/python2.7/site-packages/mpd.py", line 259, in _write_line
File "usr/lib/python2.7/socket.py", line 307, in flush
error: [Errno 32] Broken pipe

Enhance SMB Source: Read from shares list

Support multiple SMB locations as sub-source.

Q. Self-Discovery of Shares or Pre-Configured File with locations?
A. For now, let's use the file approach to keep it simple.

Read from shares list file (similar to streams.txt) -- !PER SSID/NETWORK!.

Support Crossover (DSP)

Implement a crossover. Consider ecasound w/ MPD integration.

Hardware: Required is a multi-channel output. Use HDMI (with audio grabber) or a USB soundcard, or something (TODO: figure out what the requirements are). HDMI seems good, as it outputs 24bit.

Requirements: First implement #20.

Sources:
http://rtaylor.sites.tru.ca/2013/06/25/digital-crossovereq-with-open-source-software-howto/
http://www.instructables.com/id/Raspberry-Pi-Music-Server-With-Built-in-Crossover-/
or google: ecasound DSP on raspberry pi

Add Control: IR

Add infrared control (LIRC?).

Challenge: find a panel mount / flanged IR receiver

Optimize Linux init.d

Analyze init order
Analyze actual init execution order (seems that this is not necessarily as defined)

Implement a Watchdog

Watchdog needs to restart main or any daemon script that may somehow have stopped/crashed.

Add plugin: GPIO out

Create a plugin to output events to GPIO pins.
These pins can be hooked up to a LED or a beeper, etc.

Supported events:

  • Button feedback
  • Updating DB
  • Blocking
  • ...

Must be configurable

Implement FM

There are a number of Linux tools available, plan to support all of these, but implement only the one for the D-Link USB FM radio.

Replace calls to mount with a /proc/mounts parser

Place this function in the global hu_utils package. Parsing would be a simple split by space (?) on:
with open('/proc/mounts','r') as f:
mounts = [line.split()[1] for line in f.readlines()]

Format of /proc/mounts is similar to /etc/fstab
https://linux.die.net/man/5/fstab
Fields:
1: (fs_spec) device
2: (fs_file) mountpoint
3: (fs_vfstype) filesystem
4: (fs_mntops) mount options
5: (fs_freq) determines when to backup, used by dump (ignore)
6: (fs_passno) determines how to check, used by fsck (ignore)

At this time, I think we only need the first two fields.

Custom initialization (quickplay)

Goal: Fastest possible resume of audio playback

Do:

  1. set a flag on the FS, indicating the last 1, 2 or 3 active sources.
  2. create custom init load orders for each source
  3. create an early init.d script to decide which init order to execute in order to get music playing as fast as possible
  4. add an argument to hu.py to prioritize a source?

@1) /root/S1, /root/S2, /root/S3

@2) idea:
Scripts folder:
contains the init scripts that are part of this custom initialization
init scripts must either be here or in the regular init.d folder, not both
/etc/init.d/scripts/

Customizations:
folders that contain softlinks to the scripts folder, the softlinks can be renamed to change the order of execution of the scripts.
/etc/init.d/locmus/
/etc/init.d/smb/
etc.
ex for smb:
..
S31mpd => S70
S40network => S70
S70headunit => S72
S40bluetooth => S73
..

@3) "QuickPlay", does a "rcS" on the appropriate customization folder, based on the source flag.
/etc/init.d/03quickplay
Sanity checks:
Number of scripts in the scripts folder must be equal to the number of softlinks in the customization OR all scripts must be accounted for in customization.
If sanity check fails, or there is no previously recorded source, we can instead execute the /scripts, in their defined order.

THINK:
Refine more..

THINK:
Currently we have /etc/init.d/controls, but I'm not sure that's the best way fwd.
There are a number of (Python) daemons that need to be executed at various stages in the init

Add resume track configuration options

Config options:
- resume track on restart <Y*|N>
- resume track at source change <Y*|N>
*Threshold and Expiry settings (if present) will be applied

Thresholds:
Resume thresholds (for each of the above):
- Min. Track Length (don’t save progress if it’s shorter): (default “30”, if not specified)
- Min. Progress (don’t save progress until after this duration): (default “20”, if not specified)

Expiry/Timeout:
- Expiry/Timeout
Don’t restore progress after has passed. (default “0” (no expiry), if not specified)

THINK:
We could make it so that it can be overridden per source, but I feel this overly complicates things, yet yielding little real-world benefit. Use case: Audio books source, where you definitely want to keep track of progress. In this case perhaps, it could even more useful to save progress for EVERY audio track!

Nice, templateable, web interface for the Flask frontend

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.