1activegeek / docker-airconnect

AirConnect container for turning Chromecast into Airplay targets
228 stars 27 forks source link

Exclude certain devices? #26

Closed Hukuma1 closed 2 years ago

Hukuma1 commented 2 years ago

I have three speakers total. One of them ends up being the nVidia Shield. I wish to exclude it from being automatically found/used. What's the best way to do this with your Docker image?

I found this comment: https://github.com/philippe44/AirConnect/issues/163#issuecomment-489313827 and it mentions to use switch -m or -n but neither of which show up when I run aircast-x86-64 -h. Not sure if those were old switches or what.

v0.2.50.5 (May 24 2021 @ 15:13:08)
See -t for license terms
Usage: [options]
  -b <ip>               network address to bind to
  -a <port>[:<count>]   set inbound port and range for RTP and HTTP
  -c <mp3[:<rate>]|flc[:0..9]|wav>      audio format send to player
  -v <0..1>              group MediaVolume factor
  -x <config file>      read config from file (default is ./config.xml)
  -i <config file>      discover players, save <config file> and exit
  -I                    auto save config at every network scan
  -l <[rtp][:http][:f]> RTP and HTTP latency (ms), ':f' forces silence fill
  -r                    let timing reference drift (no click)
  -f <logfile>          Write debug to logfile
  -p <pid file>         write PID in file
  -d <log>=<level>      Set logging level, logs: all|raop|main|util|cast, level: error|warn|info|debug|sdebug
  -z                    Daemonize
  -Z                    NOT interactive
  -k                    Immediate exit on SIGQUIT and SIGTERM
  -t                    License terms
  --noflush             ignore flush command (wait for teardown to stop)

Build options: LINUX

Currently using this super simple Docker compose:

  airconnect:
    image: 1activegeek/airconnect
    container_name: airconnect
    hostname: airconnect
    network_mode: "host"
1activegeek commented 2 years ago

Thanks for checking out the container. So I'm going to assume you have some basic docker knowledge since you shared the compose, and that you were able to run that aircast command in the container to see the -h output. I only created the container, I don't work on or maintain the code. So I can't help on what switches are needed to achieve your desired outcome. What I can say though is that you can run any commands (such as the -m or -n) using the AIRCAST_VAR or AIRUPNP_VAR options to have the container modify the aircast runtime options. Please consult the documentation here for using that. My compose is a bit rusty, but it should be fairly easy to mimic other documentation out there around using Variables in the compose. I believe it should just be:

  airconnect:
    image: 1activegeek/airconnect
    container_name: airconnect
    hostname: airconnect
    network_mode: "host"
    environment:
      - AIRCAST_VAR="-m"

And take note if you have Sonos or Heos devices about the additional -l 1000:2000 port requirement.

Hukuma1 commented 2 years ago

I should have said thank you first! My apologies. Thank you for making this, and an even bigger thank you for such a quick reply.

I ended up finding my issue, and that seems to be that I would need to run specific config file. Is there a way to then mount the config.xml that I need to pass to a local directory using your container? e.g. -v /local/path/to/config:/config.xml

Right now I exec into your Docker container and run aircast-x86-64 -i config.xml and that outputs the JSON file I need to edit for what I wish to do. But this file is created internally since there's no volume mapped. Wanted to see if it's possible to move and map this file outside so if I wipe the container I could retain my config for ease of upgrade?

I'm confused how I can run the -x config.xml switch automatically. Doing the switch below does not seem to work.

  airconnect:
    image: 1activegeek/airconnect
    container_name: airconnect
    hostname: airconnect
    network_mode: "host"
    environment:
      - AIRCAST_VAR="-x config.xml"

Sorry, a bit of a noob overall!

1activegeek commented 2 years ago

Quick and dirty - just do a cat on the file inside the container. Grab that output, and create a local file. Then mount/map that file inside the container, just as you said using the -v command. That should work perfectly fine - and I think I had done that long ago when I first started using it.

As for the command, you'll need to remember that you need to specify the absolute path of the file. I believe the command will be passed to the service file, which doesn't live in the same directory as the config file default. So specify the full absolute path of the file. I think you can also just map the config file (and no variable), and it should run using that config if I recall correctly. It's been a bit though, so perhaps some trial and error is in store 😊

Hukuma1 commented 2 years ago
  airconnect:
    image: 1activegeek/airconnect
    container_name: airconnect
    hostname: airconnect
    network_mode: "host"
    volumes:
      - /my/local/config/folder/config.xml:/config.xml

So this works as it keeps my file in the Docker. Great. However it does not seem to load it automatically. The only way I can load it is if I exec into the docker manually and run aircast-x86-64 -x config.xml. Then it loads just fine, but again, manuallly.

If I bring back

   environment:
      - AIRCAST_VAR="-x config.xml"

It just errors out immediately: 2021-08-29 04:49:43,078 INFO exited: aircast-x86-64 (exit status 1; not expected)

1activegeek commented 2 years ago

Have you tried specifying the config file explicitly? In this case it looks like you have the config file mapped to just /, so you would need -x /config.xml

Hukuma1 commented 2 years ago

Tried a bunch. -x /config.xml , -x /bin/config.xml , -x /config/config.xml

Same end result. I looked up the (exit status 1; not expected) error being possibly a bad path, which would make sense. But is there a way to see what actual path it's trying? Debug verbose log?

Hukuma1 commented 2 years ago

Actually just found the other switch mentioned under troubleshooting -d all=debug and that also gives the same error output. Could it be the AIRCAST_VAR is being passed incorrectly in the container somehow?

Something as simple as

   environment:
      - AIRCAST_VAR="-t"

Doesn't work either.

If I exec into container it works as it should. Definitely some issue with var not being passed?

root@airconnect:/# aircast-x86-64 -t
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
Hukuma1 commented 2 years ago

My goodness. Figured it out! For anyone reading this in the future:

  airconnect:
    image: 1activegeek/airconnect
    container_name: airconnect
    hostname: airconnect
    network_mode: "host"
    environment:
      - AIRCAST_VAR=-x /config.xml
    volumes:
      - /my/local/config/folder/config.xml:/config.xml

Original line was - AIRCAST_VAR="-x /config.xml" and the proper one has to be - AIRCAST_VAR=-x /config.xml without the quotes. Otherwise it will not work when it tries to pass on the arg with quotes when it writes it into etc/supervisord.conf file.

1activegeek commented 2 years ago

💥 there you go - glad to have figured it out. I know people had used it, but again my compose is a bit rusty. That doesn't surprise me though that it was something as simple as that. It usually is. Formatting is very key when it comes to docker. Thanks for documenting it though.

Hukuma1 commented 2 years ago

Thanks again for this awesome container. Very appreciated!