We were leaking these streams before, which causes pipewire to hang when the user changes the default sink.
Unified · Split
| @@ -84,17 +84,14 @@ audiodevopen(void) · 83 unmodified lines | ||
| 84 | 84 | |
| 85 | 85 | lock(&pwstate.lk); |
| 86 | 86 | pwstate.written = 0; |
| 87 | − if(pwstate.init > 0){ | |
| 88 | − kproc("pipewire main loop", pwproc, pwstate.loop); | |
| 89 | − unlock(&pwstate.lk); | |
| 90 | − return; | |
| 87 | + if(pwstate.init == 0){ | |
| 88 | + pw_init(&argc, (char***)&argv); | |
| 89 | + pwstate.init++; | |
| 90 | + pwstate.loop = pw_main_loop_new(NULL); | |
| 91 | + if(pwstate.loop == NULL) | |
| 92 | + sysfatal("could not create loop"); | |
| 91 | 93 | } |
| 92 | 94 | |
| 93 | − pwstate.init++; | |
| 94 | − pw_init(&argc, (char***)&argv); | |
| 95 | − pwstate.loop = pw_main_loop_new(NULL); | |
| 96 | − if(pwstate.loop == NULL) | |
| 97 | − sysfatal("could not create loop"); | |
| 98 | 95 | pwstate.output = pw_stream_new_simple( |
| 99 | 96 | pw_main_loop_get_loop(pwstate.loop), |
| 100 | 97 | "drawterm", |
| @@ -139,6 +136,7 @@ void · 38 unmodified lines | ||
| 139 | 136 | audiodevclose(void) |
| 140 | 137 | { |
| 141 | 138 | pw_main_loop_quit(pwstate.loop); |
| 139 | + pw_stream_destroy(pwstate.output); | |
| 142 | 140 | } |
| 143 | 141 | |
| 144 | 142 | int |