This audio setup seems to work flawlessly without pops and clicks, but I have to test it for a month to be sure.
On My desktop computer:
1. ALSA applications --> ALSA dmix (period_size 512, periods 3) --> SPDIF optical output of Realtek ALC887 onboard soundcard --> SPDIF optical input of Creative Sound Blaster X-Fi HD SB1240 --(zita-a2j -p 128 -n 3)--> jackd -P 90 -d netone -p 256 -n 3
2. jackd -P 90 -d netone -p 256 -n 3 --(zita-j2a -p 128 -n 3)--> headphone jack of Creative Sound Blaster X-Fi HD SB1240 --> headphones
3. JACK clients such as mpv and firefox --> jackd -P 90 -d netone -p 256 -n 3
On Raspberry Pi 3 B+:
1. jackd -P 90 -d netone -p 256 -n 3 from my desktop computer ==(ethernet cable)==> jack_netsource -n 3 -H ip_address_of_my_desktop_computer --> jackd -P 90 -d alsa -p 256 -n 2 --> HiFiBerry Amp2 --> passive speakers
2. JACK clients such as mpd --> jackd -d alsa -p 256 -n 2 --> HiFiBerry Amp2 --> passive speakers
The end result is that my desktop computer and Raspberry Pi 3 B+ share a pair of passive speakers and that my desktop computer can switch between passive speakers and headphones.
On my desktop computer, a keyboard shortcut commands jack connection manager to switch between speaker mode and headphone mode.
I wrote my own jack connection manager in python.