lock pulseaudio mainloop while freeing sound devices
This commit is contained in:
parent
6f14b09f1a
commit
6d0b027171
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
#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_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
|
#else
|
||||||
int usb_generic_shaker_init(SoundDevice* sounddevice);
|
int usb_generic_shaker_init(SoundDevice* sounddevice);
|
||||||
#endif
|
|
||||||
int usb_generic_shaker_free(SoundDevice* sounddevice);
|
int usb_generic_shaker_free(SoundDevice* sounddevice);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,9 @@ void stream_state_cb(pa_stream *s, void *mainloop) {
|
||||||
pa_threaded_mainloop_signal(mainloop, 0);
|
pa_threaded_mainloop_signal(mainloop, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_generic_shaker_free(SoundDevice* sounddevice)
|
int usb_generic_shaker_free(SoundDevice* sounddevice, pa_threaded_mainloop* mainloop)
|
||||||
{
|
{
|
||||||
|
pa_threaded_mainloop_lock(mainloop);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
if (sounddevice->stream)
|
if (sounddevice->stream)
|
||||||
{
|
{
|
||||||
|
|
@ -104,6 +105,7 @@ int usb_generic_shaker_free(SoundDevice* sounddevice)
|
||||||
// why is this wrong
|
// why is this wrong
|
||||||
//pa_xfree(sounddevice->stream);
|
//pa_xfree(sounddevice->stream);
|
||||||
}
|
}
|
||||||
|
pa_threaded_mainloop_unlock(mainloop);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,21 @@ int sounddev_gearshift_update(SimDevice* this, SimData* simdata)
|
||||||
gear_sound_set(sounddevice, simdata);
|
gear_sound_set(sounddevice, simdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_PULSEAUDIO
|
||||||
|
|
||||||
|
int sounddev_free(SimDevice* this)
|
||||||
|
{
|
||||||
|
SoundDevice* sounddevice = (void *) this->derived;
|
||||||
|
|
||||||
|
usb_generic_shaker_free(sounddevice, mainloop);
|
||||||
|
|
||||||
|
free(sounddevice);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
int sounddev_free(SimDevice* this)
|
int sounddev_free(SimDevice* this)
|
||||||
{
|
{
|
||||||
SoundDevice* sounddevice = (void *) this->derived;
|
SoundDevice* sounddevice = (void *) this->derived;
|
||||||
|
|
@ -112,6 +127,7 @@ int sounddev_free(SimDevice* this)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int sounddev_init(SoundDevice* sounddevice, const char* devname, int volume, int frequency, int pan, int channels, double duration, double threshold)
|
int sounddev_init(SoundDevice* sounddevice, const char* devname, int volume, int frequency, int pan, int channels, double duration, double threshold)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue