diff --git a/src/monocoque/devices/simdevice.h b/src/monocoque/devices/simdevice.h index 5a4d7e7..2f06f8c 100644 --- a/src/monocoque/devices/simdevice.h +++ b/src/monocoque/devices/simdevice.h @@ -123,12 +123,12 @@ typedef struct int configcheck; SoundEffectModulationType modulationType; SoundData sounddata; -#ifdef USE_PULSEAUDIO +//#ifdef USE_PULSEAUDIO pa_stream *stream; -#else - PaStreamParameters outputParameters; - PaStream* stream; -#endif +//#else + //PaStreamParameters outputParameters; + //PaStream* stream; +//#endif } SoundDevice; diff --git a/src/monocoque/devices/sound.c b/src/monocoque/devices/sound.c index e3a4ccb..6c21cb0 100644 --- a/src/monocoque/devices/sound.c +++ b/src/monocoque/devices/sound.c @@ -19,10 +19,8 @@ int setupsound() slogi("connecting pulseaudio..."); // Get a mainloop and its context mainloop = pa_threaded_mainloop_new(); - assert(mainloop); mainloop_api = pa_threaded_mainloop_get_api(mainloop); context = pa_context_new(mainloop_api, "Monocoque"); - assert(context); pa_context_set_state_callback(context, &context_state_cb, mainloop); @@ -30,13 +28,13 @@ int setupsound() pa_threaded_mainloop_lock(mainloop); // Start the mainloop - assert(pa_threaded_mainloop_start(mainloop) == 0); - assert(pa_context_connect(context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) == 0); + pa_threaded_mainloop_start(mainloop); + pa_context_connect(context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL); // Wait for the context to be ready for(;;) { pa_context_state_t context_state = pa_context_get_state(context); - assert(PA_CONTEXT_IS_GOOD(context_state)); + PA_CONTEXT_IS_GOOD(context_state); if (context_state == PA_CONTEXT_READY) break; pa_threaded_mainloop_wait(mainloop); } @@ -52,8 +50,12 @@ int freesound() if (mainloop) { pa_threaded_mainloop_lock(mainloop); } + if (context) + { pa_context_unref(context); + slogt("freed pulseaudio context"); + } if (mainloop) { pa_signal_done(); diff --git a/src/monocoque/devices/sound/usb_generic_shaker.h b/src/monocoque/devices/sound/usb_generic_shaker.h index 7ecfa3e..3be45b0 100644 --- a/src/monocoque/devices/sound/usb_generic_shaker.h +++ b/src/monocoque/devices/sound/usb_generic_shaker.h @@ -3,12 +3,12 @@ #include "../simdevice.h" -#ifdef USE_PULSEAUDIO +//#ifdef USE_PULSEAUDIO int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* mainloop, pa_context* context, const char* devname, int volume, int pan, int channels, const char* streamname); int usb_generic_shaker_free(SoundDevice* sounddevice, pa_threaded_mainloop* mainloop); -#else -int usb_generic_shaker_init(SoundDevice* sounddevice); -int usb_generic_shaker_free(SoundDevice* sounddevice); -#endif +//#else +//int usb_generic_shaker_init(SoundDevice* sounddevice); +//int usb_generic_shaker_free(SoundDevice* sounddevice); +//#endif #endif diff --git a/src/monocoque/devices/sound/usb_generic_shaker_pulse.c b/src/monocoque/devices/sound/usb_generic_shaker_pulse.c index 1f47606..c90e76a 100644 --- a/src/monocoque/devices/sound/usb_generic_shaker_pulse.c +++ b/src/monocoque/devices/sound/usb_generic_shaker_pulse.c @@ -108,11 +108,11 @@ int usb_generic_shaker_free(SoundDevice* sounddevice, pa_threaded_mainloop* main int err = 0; if (sounddevice->stream) { - //pa_stream_cork(sounddevice->stream, 1, stream_success_cb, mainloop); + pa_stream_cork(sounddevice->stream, 1, stream_success_cb, mainloop); pa_stream_disconnect(sounddevice->stream); pa_stream_unref(sounddevice->stream); // why is this wrong - //pa_xfree(sounddevice->stream); + } diff --git a/src/monocoque/devices/sounddevice.h b/src/monocoque/devices/sounddevice.h index dab98ef..43fbaea 100644 --- a/src/monocoque/devices/sounddevice.h +++ b/src/monocoque/devices/sounddevice.h @@ -1,11 +1,11 @@ #ifndef _SOUNDDEVICE_H #define _SOUNDDEVICE_H -#ifdef USE_PULSEAUDIO +//#ifdef USE_PULSEAUDIO #include -#else -#include "portaudio.h" -#endif +//#else +//#include "portaudio.h" +//#endif typedef enum