forked from LibreELEC/LibreELEC.tv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
librespot.start
executable file
·117 lines (105 loc) · 3.27 KB
/
librespot.start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2017-present Team LibreELEC
#
# LibreELEC 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 2 of the License, or
# (at your option) any later version.
#
# LibreELEC 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 LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
activate_card() {
if [ -e "/proc/asound/$1" ]; then
return
fi
case "$LIBREELEC_ARCH" in
RPi*.arm)
if [ "$1" = "ALSA" ]; then
dtparam audio=on
sleep 1
fi
;;
*)
echo "Unable to activate card $1 on $LIBREELEC_ARCH"
exit
;;
esac
}
init_alsa() {
. /etc/os-release
if [ ! "$(cat /proc/asound/pcm 2> /dev/null)" ]; then
case "$LIBREELEC_ARCH" in
RPi*.arm)
activate_card "ALSA"
;;
*)
echo "Unable to activate an audio interface on $LIBREELEC_ARCH"
exit
;;
esac
fi
case "$ls_o" in
*:CARD=*)
card="${ls_o##*:CARD=}"
card="${card%%,*}"
activate_card "$card"
index="$(readlink /proc/asound/$card)"
index="${index##*card}"
;;
hw:*,*)
echo "The hw:d,s specification is unreliable, use device:CARD=card instead"
index="${ls_o##hw:}"
index="${index%%,*}"
card="card$index"
activate_card "$card"
;;
*)
if [ -n "$ls_o" ]; then
echo "Unknown playback device specification $ls_o"
fi
;;
esac
case "$LIBREELEC_ARCH" in
RPi*.arm)
[ "$(readlink /proc/asound/ALSA)" == "card$index" ] && [ "$pcm_3" ] &&
amixer -c "$index" cset name="PCM Playback Route" "$pcm_3"
;;
esac
}
. /etc/profile
oe_setup_addon service.librespot
LIBRESPOT="librespot --cache \"$ADDON_HOME/cache\"
--disable-audio-cache \
--name \"Librespot@$HOSTNAME\""
if [ -n "$ls_b" -a "$ls_b" != "-" ]; then
LIBRESPOT="$LIBRESPOT --bitrate $ls_b"
fi
if [ -n "$ls_p" -a -n "$ls_u" ]; then
LIBRESPOT="$LIBRESPOT --disable-discovery \
--password \"$ls_p\" \
--username \"$ls_u\""
fi
if [ "$ls_O" == "Kodi" ]; then
LIBRESPOT="$LIBRESPOT --backend pipe \
--onstart=\"kodi-send \
--action=RunAddon(service.librespot)\" \
| ffmpegx -hide_banner -loglevel warning \
-avioflags direct -fflags nobuffer \
-re -ac 2 -ar 44100 -channel_layout stereo -f s16le -i pipe: \
-sdp_file \"$ADDON_HOME/librespot.sdp\" \
-f rtp rtp://127.0.0.1:5555"
else
init_alsa
if [ -n "$ls_o" ]; then
LIBRESPOT="$LIBRESPOT --device \"$ls_o\""
fi
fi
eval $LIBRESPOT