In /etc/pulse/default.pa
1) Comment out line that loads module module-udev-detect.so
2) General idea is to use module-combine-sink. hw:0,1 and hw:0,3 might need changing depending on hardware, but otherwise add:
load-module module-alsa-sink device=hw:0,1 sink_name=optical_output
load-module module-alsa-sink device=hw:0,3 sink_name=hdmi_output
load-module module-combine-sink sink_name=hdmiandoptical slaves=hdmi_output,optical_output
set-default-sink hdmiandoptical