diff --git a/pw_plugin/Makefile b/pw_plugin/Makefile index d886a82..ff9a2b8 100644 --- a/pw_plugin/Makefile +++ b/pw_plugin/Makefile @@ -7,7 +7,7 @@ main.out: main.o stream_wrapper.o ringbuffer.o passthrough.o stream_wrapper.o: stream_wrapper.cc stream_wrapper.h $(CXX) $(CXXFLAGS) -c $< -o $@ -main.o: main.cc circ_buffer.h +main.o: main.cc $(CXX) $(CXXFLAGS) -c $< -o $@ ringbuffer.o: ringbuffer.cc ringbuffer.h $(CXX) $(CXXFLAGS) -c $< -o $@ diff --git a/pw_plugin/link_record.sh b/pw_plugin/link_record.sh deleted file mode 100755 index 1cde396..0000000 --- a/pw_plugin/link_record.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -pw-link aec-sink: - -pw-link aec-playback:output_FL pw-record:input_FL -pw-link aec-playback:output_FR alsa_output.pci-0000_00_1b.0.analog-stereo.playback_FR diff --git a/pw_plugin/main.cc b/pw_plugin/main.cc index 12509b4..8990726 100644 --- a/pw_plugin/main.cc +++ b/pw_plugin/main.cc @@ -9,7 +9,6 @@ #include "spa/param/audio/format-utils.h" #include "spa/param/latency-utils.h" -#include "circ_buffer.h" #include "passthrough.h" int main(int argc, char** argv) { @@ -22,7 +21,7 @@ int main(int argc, char** argv) { return 1; } logger_record lr(pw_thread_loop_get_loop(tloop), &rb); - logger_playback lp(pw_thread_loop_get_loop(tloop), &rb, true, true); + logger_playback lp(pw_thread_loop_get_loop(tloop), &rb); pw_thread_loop_start(tloop); diff --git a/pw_plugin/start.sh b/pw_plugin/start.sh new file mode 100755 index 0000000..b4cc1a9 --- /dev/null +++ b/pw_plugin/start.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +pactl unload-module module-null-sink # Just kill all null sinks + +pactl load-module module-null-sink sink_name=AEC_sink sink_properties=device.description=AEC_sink +pactl set-default-sink AEC_sink + +pactl load-module module-null-sink sink_name=AEC_out sink_properties=device.description=AEC_out +pactl set-default-source AEC_out.monitor + +# Launch main.out; ideally it should not autoconnect +./main.out & +sleep 1 + +pw-link AEC_sink:monitor_FL aec-sink:input_FL +pw-link AEC_sink:monitor_FR aec-sink:input_FR + +pw-link aec-playback:output_FL alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo:playback_FL +pw-link aec-playback:output_FR alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo:playback_FR + +pw-link alsa_input.pci-0000_00_1b.0.analog-stereo:capture_FL aec-record:input_FL +pw-link alsa_input.pci-0000_00_1b.0.analog-stereo:capture_FR aec-record:input_FR + +pw-link aec-output:capture_FL AEC_out:input_FL +pw-link aec-output:capture_FR AEC_out:input_FR diff --git a/pw_plugin/stream_wrapper.cc b/pw_plugin/stream_wrapper.cc index ee5a3aa..a948e77 100644 --- a/pw_plugin/stream_wrapper.cc +++ b/pw_plugin/stream_wrapper.cc @@ -8,18 +8,24 @@ pw_loop* lp, const char* name, pw_properties* props): b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); - auto fmt = SPA_AUDIO_INFO_RAW_INIT( - .format = SPA_AUDIO_FORMAT_F32LE, + spa_audio_info_raw fmt = { + .format = SPA_AUDIO_FORMAT_F32, .rate = rate, .channels = channels, - ); + .position = {SPA_AUDIO_CHANNEL_MONO} + }; + + if(channels==2) { + fmt.position[0] = SPA_AUDIO_CHANNEL_FL; + fmt.position[1] = SPA_AUDIO_CHANNEL_FR; + } params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &fmt); pw_stream_connect(strm, (direction ? PW_DIRECTION_OUTPUT : PW_DIRECTION_INPUT), PW_ID_ANY, - (pw_stream_flags) (PW_STREAM_FLAG_AUTOCONNECT | + (pw_stream_flags) ( PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS), params, 1); }