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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# Maintainer: PiterDeVries <https://aur.archlinux.org/account/PiterDeVries>
pkgname='moc-stable-complete'
_pkgname='moc'
pkgver='2.5.2'
pkgrel=3
pkgdesc='Music On Console is an ncurses-based console audio player - stable version with patches that support PulseAudio and FluidSynth, compiled against current FFmpeg'
arch=('i686' 'x86_64' 'aarch64')
url="https://moc.daper.net/"
license=('GPL-2.0-or-later')
depends=('popt' 'libmad' 'libid3tag' 'jack' 'curl' 'libltdl' 'file' 'sndio' 'fluidsynth' 'libsmf')
makedepends=('speex' 'ffmpeg>=5.1' 'taglib' 'libmpcdec' 'wavpack' 'libmodplug' 'faad2')
optdepends=('speex: for using the speex plugin'
'ffmpeg>=5.1: for using the ffmpeg plugin'
'taglib: for using the musepack plugin'
'libmpcdec: for using the musepack plugin'
'wavpack: for using the wavpack plugin'
'faad2: for using the aac plugin'
'libmodplug: for using the modplug plugin')
provides=('moc')
conflicts=('moc' 'moc-pulse' 'moc-git' 'moc-unstable' 'moc-stable' 'moc-development' 'moc-fluidsynth-plugin')
source=("https://ftp.daper.net/pub/soft/${_pkgname}/stable/${_pkgname}-${pkgver}.tar.bz2"
"moc-fluidsynth-plugin-0.6.6.tar.gz::https://github.com/joanbm/moc-fluidsynth-plugin/archive/refs/tags/v0.0.6.tar.gz"
"pulse.c"
"pulse.h"
"ffmpeg.c.patch")
sha256sums=('f3a68115602a4788b7cfa9bbe9397a9d5e24c68cb61a57695d1c2c3ecf49db08'
'5585d541c6bc92103a71a044d096f16d872ac260a078d7d91b005f60939aefb4'
'84cbc24e9c81f0ea699438bdb8827f1519c107fb963a8b59baf50e3a21f70252'
'93e89cc4f4025f30a9b1b0c4c2603ca35950cf237dc0fc15f09759438232bc33'
'1c80e716ff774a7bb5f07cb938663aac596c12f6302f64b389504519778de5d0')
install="moc-stable-complete.install"
prepare() {
cd "${_pkgname}-${pkgver}"
### The rest of the build() section will be divided into several subsections:
### necessary patches(1), PulseAudio support(2), FluidSynth plugin(3), patches for FFmpeg plugin compatibility with
### FFmpeg versions>5.0 (4) and updating the configuration files (5).
## 1. Fix the compilation (fix all current errors):
# add support for https in the file: 'files.c'
sed -i '95a\ || !strncasecmp (str, "https://", sizeof ("https://") - 1)' "${srcdir}/${_pkgname}-${pkgver}/files.c"
# fix warning about the file 'configure.in' (should be named 'configue.ac'):
mv "${srcdir}/${_pkgname}-${pkgver}/configure.in" "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
## 2. Add the PulseAudio support:
# (Note: PulseAudio support based on the AUR/moc-pulse package)
# copy files 'pulse.c' and 'pulse.h' into the main directory:
cp ../pulse.c "${srcdir}/${_pkgname}-${pkgver}/"
cp ../pulse.h "${srcdir}/${_pkgname}-${pkgver}/"
# include the 'pulse.h' header into the file: 'audio.c'
sed -i '34a\#ifdef HAVE_PULSE' "${srcdir}/${_pkgname}-${pkgver}/audio.c"
sed -i '35a\# include "pulse.h"' "${srcdir}/${_pkgname}-${pkgver}/audio.c"
sed -i '36a\#endif"' "${srcdir}/${_pkgname}-${pkgver}/audio.c"
# add "PulseAudio" as an option in the main configuration file - modify the file: 'options.c'
sed -i '575 s/CHECK_DISCRETE(5), "SNDIO", "Jack", "ALSA", "OSS", "null");/CHECK_DISCRETE(5), "SNDIO", "PulseAudio", "Jack", "ALSA", "OSS", "null");/' \
"${srcdir}/${_pkgname}-${pkgver}/options.c"
sed -i '578 s/CHECK_DISCRETE(5), "SNDIO", "Jack", "ALSA", "OSS", "null");/CHECK_DISCRETE(5), "SNDIO", "PulseAudio", "Jack", "ALSA", "OSS", "null");/' \
"${srcdir}/${_pkgname}-${pkgver}/options.c"
# finally, modify the main configuration file to add another option - file: 'configure.ac'
sed -i '190a\if test "x$with_pulse" != "xno"' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '191a\then' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '192a\ PKG_CHECK_MODULES(PULSE, [libpulse],' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '193a\ [SOUND_DRIVERS="$SOUND_DRIVERS PULSE"' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '194a\ EXTRA_OBJS="$EXTRA_OBJS pulse.o"' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '195a\ AC_DEFINE([HAVE_PULSE], 1, [Define if you have PulseAudio.])' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '196a\ EXTRA_LIBS="$EXTRA_LIBS $PULSE_LIBS"' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '197a\ CFLAGS="$CFLAGS $PULSE_CFLAGS"],' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '198a\ [true])' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '199a\fi' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
sed -i '200a\' "${srcdir}/${_pkgname}-${pkgver}/configure.ac"
# last tiny detail: add "PULSEAUDIO" into the "SoundDriver" section in the example config file 'config.example.in'
sed -i '124 s/ALSA, JACK,/ALSA, JACK, PULSEAUDIO,/' "${srcdir}/${_pkgname}-${pkgver}/config.example.in"
## 3. Add the FluidSynth support (made by Joan Bruguera Micó)
# Note: for some reason, it can't be included directly (can only be compiled separately as a shared library)
# ...probably because the moc-fulidsynth-plugin adds specific steps for compiling the libfluidsynth_decoder.so (as a standalone plugin)
# - that makes some of the following steps kind of redundant
# (will needs to compile the libfluidsynth_decoder.so directly later - see the build() and package() sections)
# copy the 'fluidsynth' decoder plugin from the moc-fluidsynth-plugin project:
cp -r ../moc-fluidsynth-plugin-0.0.6/moc/decoder_plugins/fluidsynth "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins"
# add the 'fluidsynth' right after 'timidity' in the decoder list - the file: 'decoders.m4'
sed -i '26a\m4_include(decoder_plugins/fluidsynth/fluidsynth.m4)' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/decoders.m4"
# ... and to the file: 'decoder_plugins/Makefile.am'
sed -i '38a\if BUILD_fluidsynth' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/Makefile.am"
sed -i '39a\ SUBDIRS += fluidsynth' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/Makefile.am"
sed -i '40a\endif' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/Makefile.am"
sed -i '41a\' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/Makefile.am"
# also add 'fluidsynth' to the file: 'tools/md5check.sh'
sed -i '240 s/timidity/timidity|fluidsynth/' "${srcdir}/${_pkgname}-${pkgver}/tools/md5check.sh"
# and list it in the main makefile: 'Makefile.in'
sed -i '69a\ $(top_srcdir)/decoder_plugins/fluidsynth/fluidsynth.m4 \' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/Makefile.in"
# add notion about the FluidSynth support to the default example config file: 'config.example.in'
sed -i '625a\# Self-describing FluidSynth audio characteristic options.' "${srcdir}/${_pkgname}-${pkgver}/config.example.in"
sed -i '626a\#FluidSynth_SoundFont = /usr/share/soundfonts/default.sf2' "${srcdir}/${_pkgname}-${pkgver}/config.example.in"
sed -i '627a\#FluidSynth_Rate = 44100 # Between 8000 and 96000' "${srcdir}/${_pkgname}-${pkgver}/config.example.in"
sed -i '628a\' "${srcdir}/${_pkgname}-${pkgver}/config.example.in"
# and finally: give credit to the author of the moc-fluidsynth-plugin - add him to the file: 'THANKS'
sed -i '16a\Joan Bruguera:' "${srcdir}/${_pkgname}-${pkgver}/THANKS"
sed -i '17a\ * Added FluidSynth decoder for MIDI.' "${srcdir}/${_pkgname}-${pkgver}/THANKS"
sed -i '18a\' "${srcdir}/${_pkgname}-${pkgver}/THANKS"
## 4. Patch the FFmpeg decoder plugin so that its compatible with current version of FFmpeg:
# apply patch to the file 'decoder_plugins/ffmpeg/ffmpeg.c' - this is the core change,
# as it fixes the breaking API changes that happened between FFmpeg 4.4->5.1
patch < ../ffmpeg.c.patch "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/ffmpeg/ffmpeg.c"
# modify the FFmpeg plugin's makefile 'decoder_plugins/ffmpeg/ffmpeg.m4' - ensure that MOC compiles
# against FFmpeg version>=5.1 (API-wise, this means libavcodec 59.24.100):
sed -i '36 s/--atleast-version 54.59.100 libavcodec/--atleast-version 59.24.100 libavcodec/' "${srcdir}/${_pkgname}-${pkgver}/decoder_plugins/ffmpeg/ffmpeg.m4"
## 5. final step - reconfigure the configuration system:
autoreconf -i -f
}
build() {
cd "${_pkgname}-${pkgver}"
./configure --prefix=/usr \
--without-rcc \
--with-pulse \
--with-oss \
--with-alsa \
--with-jack \
--with-aac \
--with-mp3 \
--with-musepack \
--with-vorbis \
--with-flac \
--with-wavpack \
--with-sndfile \
--with-modplug \
--with-ffmpeg \
--with-speex \
--with-samplerate \
--with-curl \
--with-fluidsynth \
--disable-cache \
--disable-debug
make
## Since the FluidSynth plugin can't be included directly (requires specific additional make parameters),
## we will now create a new Makefile and use it to build the file libfluidsynth_decoder.so
## Note that as far as packaging goes, this is kind of a weird hack:
# create the new Makefile in the "${srcdir}":
cd "${srcdir}"
touch "Makefile"
# fill the new Makefile - based on the content of Makefile from the moc-fluidsynth-plugin:
echo 'CC := gcc' >> "${srcdir}/Makefile"
echo 'SMF_FLAGS = $(shell pkg-config --exists smf && pkg-config --cflags --libs smf && echo "-DHAVE_SMF")' >> "${srcdir}/Makefile"
echo 'libfluidsynth_decoder.so: moc/decoder_plugins/fluidsynth/fluidsynth.c' >> "${srcdir}/Makefile"
echo ' $(CC) -Wall -Wextra -fPIC -DSTANDALONE -Imoc -shared moc/decoder_plugins/fluidsynth/fluidsynth.c \' >> "${srcdir}/Makefile"
echo ' $(shell pkg-config --cflags --libs fluidsynth) $(SMF_FLAGS) -o libfluidsynth_decoder.so' >> "${srcdir}/Makefile"
# create a symbolic link called 'moc' in "${srcdir}" - this mirrors the directory structure from the moc-fluidsynth plugin:
ln -s "${_pkgname}-${pkgver}" "${srcdir}/${_pkgname}"
# and of course make the libfluidsynth_decoder.so library itself:
make libfluidsynth_decoder.so
}
package() {
cd "${_pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
# now all that remains to do is to replace the libfluidsynth_decoder.so with the one from "${srcdir}":
rm "${pkgdir}/usr/lib/moc/decoder_plugins/libfluidsynth_decoder.so"
cp "${srcdir}/libfluidsynth_decoder.so" "${pkgdir}/usr/lib/moc/decoder_plugins/"
}
# vim: ts=2 sw=2
|