From 3ab4e69d6474c88678bbb1a42851bb0072898e26 Mon Sep 17 00:00:00 2001 From: Paul Dino Jones Date: Mon, 22 Jul 2024 21:45:57 -0400 Subject: [PATCH] More support for beyond stereo --- .../devices/sound/usb_generic_shaker_pulse.c | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/monocoque/devices/sound/usb_generic_shaker_pulse.c b/src/monocoque/devices/sound/usb_generic_shaker_pulse.c index 234c965..3d924bd 100644 --- a/src/monocoque/devices/sound/usb_generic_shaker_pulse.c +++ b/src/monocoque/devices/sound/usb_generic_shaker_pulse.c @@ -105,13 +105,28 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main pa_channel_map channel_map; pa_channel_map_init_auto(&channel_map, channels, PA_CHANNEL_MAP_DEFAULT); //pa_channel_map_init_stereo(&channel_map); - //pa_channel_map_parse(&channel_map, "front-left,front-right"); + // not sure about what to do here + if(channels == 2) + { + pa_channel_map_parse(&channel_map, "front-left,front-right"); + } + if(channels == 4) + { + pa_channel_map_parse(&channel_map, "front-left,front-right,rear-left,rear-right"); + } + if(channels == 6) + { + pa_channel_map_parse(&channel_map, "front-left,front-right,rear-left,rear-right,front-center,lfe"); + } + if(channels == 8) + { + pa_channel_map_parse(&channel_map, "front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right"); + } stream = pa_stream_new(context, streamname, &sample_specifications, &channel_map); pa_stream_set_state_callback(stream, stream_state_cb, mainloop); - if (sounddevice->m.hapticeffect.effecttype == EFFECT_GEARSHIFT) { pa_stream_set_write_callback(stream, gear_sound_stream, &sounddevice->sounddata); @@ -128,17 +143,19 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main buffer_attr.prebuf = (uint32_t) -1; buffer_attr.minreq = (uint32_t) -1; - pa_cvolume* cv; - pa_cvolume_mute(cv, channels); + pa_cvolume cv; + pa_cvolume_mute(&cv, channels); pa_volume_t channel_volume = PA_CLAMP_VOLUME((pa_volume_t)((volume/100.d)*PA_VOLUME_NORM)); pa_stream_flags_t stream_flags; stream_flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY | PA_STREAM_START_CORKED; - cv->values[pan] = channel_volume; - assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, cv, NULL) == 0); + // for now i'm only supporting playing on one specified channel which is the concept you should build your setups around + cv.values[pan] = channel_volume; + + assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL) == 0); // Wait for the stream to be ready for(;;) { @@ -148,7 +165,6 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main pa_threaded_mainloop_wait(mainloop); } - //pa_threaded_mainloop_unlock(mainloop); // Uncork the stream so it will start playing