portaudio.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. From 84d090e2fde50c66b965b84c73abd9f04a1770dd Mon Sep 17 00:00:00 2001
  2. From: orbea <orbea@riseup.net>
  3. Date: Thu, 7 May 2020 15:31:48 +0000
  4. Subject: [PATCH] spu2-x: Make portaudio an optional dependency. (#3110)
  5. * spu2-x: Make portaudio an optional dependency.
  6. v2: Fix crash in the audio settings with SDL1 and without portaudio.
  7. * cmake: Add PORTAUDIO_API to disable portaudio support.
  8. ---
  9. build.sh | 4 +++-
  10. cmake/BuildParameters.cmake | 1 +
  11. cmake/SearchForStuff.cmake | 6 ++++--
  12. cmake/SelectPcsx2Plugins.cmake | 15 ++++++++-------
  13. plugins/spu2-x/src/CMakeLists.txt | 19 ++++++++++++++++---
  14. plugins/spu2-x/src/Linux/Config.cpp | 20 +++++++++++++++++++-
  15. plugins/spu2-x/src/SndOut.cpp | 2 ++
  16. plugins/spu2-x/src/SndOut.h | 2 ++
  17. 8 files changed, 55 insertions(+), 14 deletions(-)
  18. diff --git a/build.sh b/build.sh
  19. index e1bc256475..54b30e404e 100755
  20. --- a/build.sh
  21. +++ b/build.sh
  22. @@ -213,6 +213,7 @@ for ARG in "$@"; do
  23. --pgo-optimize ) flags="$flags -DUSE_PGO_OPTIMIZE=TRUE" ;;
  24. --pgo-generate ) flags="$flags -DUSE_PGO_GENERATE=TRUE" ;;
  25. --no-dev9ghzdrk ) flags="$flags -DDISABLE_DEV9GHZDRK=TRUE" ;;
  26. + --no-portaudio ) flags="$flags -DPORTAUDIO_API=FALSE" ;;
  27. --no-simd ) flags="$flags -DDISABLE_ADVANCE_SIMD=TRUE" ;;
  28. --no-trans ) flags="$flags -DNO_TRANSLATION=TRUE" ;;
  29. --cross-multilib ) flags="$flags -DCMAKE_TOOLCHAIN_FILE=$toolfile"; useCross=1; ;;
  30. @@ -244,7 +245,8 @@ for ARG in "$@"; do
  31. echo
  32. echo "** Distribution Compatibilities **"
  33. echo "--sdl12 : Build with SDL1.2 (requires if wx is linked against SDL1.2)"
  34. - echo "--no-dev9ghzdrk : Skip dev9ghzdrk. (Avoids needing escalated privileges to build.)"
  35. + echo "--no-dev9ghzdrk : Skip dev9ghzdrk. (Avoids needing escalated privileges to build.)"
  36. + echo "--no-portaudio : Skip portaudio for spu2x."
  37. echo
  38. echo "** Expert Developer option **"
  39. echo "--gtk3 : replace GTK2 by GTK3"
  40. diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake
  41. index 235bdb8e59..83bab90dab 100644
  42. --- a/cmake/BuildParameters.cmake
  43. +++ b/cmake/BuildParameters.cmake
  44. @@ -48,6 +48,7 @@ option(DISABLE_CHEATS_ZIP "Disable including the cheats_ws.zip file")
  45. option(DISABLE_PCSX2_WRAPPER "Disable including the PCSX2-linux.sh file")
  46. option(XDG_STD "Use XDG standard path instead of the standard PCSX2 path")
  47. option(EXTRA_PLUGINS "Build various 'extra' plugins")
  48. +option(PORTAUDIO_API "Build portaudio support on spu2x" ON)
  49. option(SDL2_API "Use SDL2 on spu2x and onepad (wxWidget mustn't be built with SDL1.2 support" ON)
  50. option(GTK3_API "Use GTK3 api (experimental/wxWidget must be built with GTK3 support)")
  51. diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake
  52. index a062d457a3..50f8f5f3e8 100644
  53. --- a/cmake/SearchForStuff.cmake
  54. +++ b/cmake/SearchForStuff.cmake
  55. @@ -105,7 +105,9 @@ endif()
  56. if(OPENCL_API)
  57. check_lib(OPENCL OpenCL CL/cl.hpp)
  58. endif()
  59. -check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h)
  60. +if(PORTAUDIO_API)
  61. + check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h)
  62. +endif()
  63. check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h)
  64. if(SDL2_API)
  65. @@ -227,4 +229,4 @@ if((GCC_VERSION VERSION_EQUAL "9.0" OR GCC_VERSION VERSION_GREATER "9.0") AND GC
  66. https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=275ab714637a64672c6630cfd744af2c70957d5a
  67. Even with that patch, compiling with LTO may still segfault. Use at your own risk!
  68. This text being in a compile log in an open issue may cause it to be closed.")
  69. -endif()
  70. \ No newline at end of file
  71. +endif()
  72. diff --git a/cmake/SelectPcsx2Plugins.cmake b/cmake/SelectPcsx2Plugins.cmake
  73. index 69d0e07b91..00bf22e6ca 100644
  74. --- a/cmake/SelectPcsx2Plugins.cmake
  75. +++ b/cmake/SelectPcsx2Plugins.cmake
  76. @@ -7,7 +7,7 @@ set(msg_dep_cdvdgiga "check these libraries -> gtk2, libudev")
  77. set(msg_dep_zerogs "check these libraries -> glew, opengl, X11, nvidia-cg-toolkit (>=2.1)")
  78. set(msg_dep_gsdx "check these libraries -> opengl, png (>=1.2), zlib (>=1.2.4), X11, liblzma")
  79. set(msg_dep_onepad "check these libraries -> sdl2, X11, gtk2")
  80. -set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (>=1.9), sdl (>=1.2) pcsx2 common libs")
  81. +set(msg_dep_spu2x "check these libraries -> soundtouch (>=1.5), alsa, portaudio (optional, >=1.9), sdl (>=1.2), pcsx2 common libs")
  82. set(msg_dep_zerospu2 "check these libraries -> soundtouch (>=1.5), alsa")
  83. set(msg_dep_dev "check these libraries -> gtk2, pcap, libxml2")
  84. if(GLSL_API)
  85. @@ -267,12 +267,13 @@ endif()
  86. # spu2-x
  87. #---------------------------------------
  88. # requires: -SoundTouch
  89. -# -ALSA
  90. -# -Portaudio
  91. +# -ALSA
  92. # -SDL
  93. # -common_libs
  94. +#
  95. +# optional: -Portaudio
  96. #---------------------------------------
  97. -if((PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND SDLn_FOUND AND common_libs)
  98. +if((SOUNDTOUCH_FOUND AND SDLn_FOUND AND common_libs)
  99. AND ((Linux AND ALSA_FOUND) OR (UNIX AND NOT Linux)))
  100. set(spu2-x TRUE)
  101. elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/plugins/spu2-x")
  102. @@ -287,8 +288,8 @@ endif()
  103. # zerospu2
  104. #---------------------------------------
  105. # requires: -SoundTouch
  106. -# -ALSA
  107. -# -PortAudio
  108. +# -ALSA
  109. +# -PortAudio
  110. #---------------------------------------
  111. if(EXTRA_PLUGINS)
  112. if(EXISTS "${CMAKE_SOURCE_DIR}/plugins/zerospu2" AND SOUNDTOUCH_FOUND AND ALSA_FOUND)
  113. @@ -312,4 +313,4 @@ if(GTKn_FOUND)
  114. set(USBnull TRUE)
  115. endif()
  116. #---------------------------------------
  117. -#-------------------------------------------------------------------------------
  118. \ No newline at end of file
  119. +#-------------------------------------------------------------------------------
  120. diff --git a/plugins/spu2-x/src/CMakeLists.txt b/plugins/spu2-x/src/CMakeLists.txt
  121. index e4c7141287..d17538e33e 100644
  122. --- a/plugins/spu2-x/src/CMakeLists.txt
  123. +++ b/plugins/spu2-x/src/CMakeLists.txt
  124. @@ -45,7 +45,6 @@ set(spu2xSources
  125. RegTable.cpp
  126. Reverb.cpp
  127. SndOut.cpp
  128. - SndOut_Portaudio.cpp
  129. SndOut_SDL.cpp
  130. spu2freeze.cpp
  131. Spu2replay.cpp
  132. @@ -111,7 +110,6 @@ else()
  133. include_directories(Linux)
  134. endif()
  135. -
  136. set(spu2xFinalSources
  137. ${spu2xSources}
  138. ${spu2xHeaders}
  139. @@ -121,11 +119,26 @@ set(spu2xFinalSources
  140. set(spu2xFinalLibs
  141. Utilities_NO_TLS
  142. ${ALSA_LIBRARIES}
  143. - ${PORTAUDIO_LIBRARIES}
  144. ${GTK2_LIBRARIES}
  145. ${SOUNDTOUCH_LIBRARIES}
  146. )
  147. +if (PORTAUDIO_FOUND)
  148. + set(spu2xFinalFlags
  149. + ${spu2xFinalFlags}
  150. + "-DSPU2X_PORTAUDIO"
  151. + )
  152. +
  153. + LIST(APPEND spu2xFinalSources
  154. + SndOut_Portaudio.cpp
  155. + )
  156. +
  157. + set(spu2xFinalLibs
  158. + ${spu2xFinalLibs}
  159. + ${PORTAUDIO_LIBRARIES}
  160. + )
  161. +endif()
  162. +
  163. if (SDL2_API)
  164. set(spu2xFinalLibs
  165. ${spu2xFinalLibs}
  166. diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp
  167. index 998f9bd25a..96a9e7bc8b 100644
  168. --- a/plugins/spu2-x/src/Linux/Config.cpp
  169. +++ b/plugins/spu2-x/src/Linux/Config.cpp
  170. @@ -76,7 +76,9 @@ bool _visual_debug_enabled = false; // windows only feature
  171. u32 OutputModule = 0;
  172. int SndOutLatencyMS = 300;
  173. int SynchMode = 0; // Time Stretch, Async or Disabled
  174. +#ifdef SPU2X_PORTAUDIO
  175. static u32 OutputAPI = 0;
  176. +#endif
  177. static u32 SdlOutputAPI = 0;
  178. int numSpeakers = 0;
  179. @@ -122,7 +124,7 @@ void ReadSettings()
  180. wxString temp;
  181. -#if SDL_MAJOR_VERSION >= 2
  182. +#if SDL_MAJOR_VERSION >= 2 || !defined(SPU2X_PORTAUDIO)
  183. CfgReadStr(L"OUTPUT", L"Output_Module", temp, SDLOut->GetIdent());
  184. #else
  185. CfgReadStr(L"OUTPUT", L"Output_Module", temp, PortaudioOut->GetIdent());
  186. @@ -130,6 +132,7 @@ void ReadSettings()
  187. OutputModule = FindOutputModuleById(temp.c_str()); // find the driver index of this module
  188. // find current API
  189. +#ifdef SPU2X_PORTAUDIO
  190. #ifdef __linux__
  191. CfgReadStr(L"PORTAUDIO", L"HostApi", temp, L"ALSA");
  192. if (temp == L"OSS")
  193. @@ -142,6 +145,7 @@ void ReadSettings()
  194. CfgReadStr(L"PORTAUDIO", L"HostApi", temp, L"OSS");
  195. OutputAPI = 0; // L"OSS"
  196. #endif
  197. +#endif
  198. #ifdef __unix__
  199. CfgReadStr(L"SDL", L"HostApi", temp, L"pulseaudio");
  200. @@ -158,7 +162,9 @@ void ReadSettings()
  201. SndOutLatencyMS = CfgReadInt(L"OUTPUT", L"Latency", 300);
  202. SynchMode = CfgReadInt(L"OUTPUT", L"Synch_Mode", 0);
  203. +#ifdef SPU2X_PORTAUDIO
  204. PortaudioOut->ReadSettings();
  205. +#endif
  206. #ifdef __unix__
  207. SDLOut->ReadSettings();
  208. #endif
  209. @@ -209,7 +215,9 @@ void WriteSettings()
  210. CfgWriteInt(L"OUTPUT", L"Synch_Mode", SynchMode);
  211. CfgWriteInt(L"DEBUG", L"DelayCycles", delayCycles);
  212. +#ifdef SPU2X_PORTAUDIO
  213. PortaudioOut->WriteSettings();
  214. +#endif
  215. #ifdef __unix__
  216. SDLOut->WriteSettings();
  217. #endif
  218. @@ -273,7 +281,9 @@ void DisplayDialog()
  219. GtkWidget *output_frame, *output_box;
  220. GtkWidget *mod_label, *mod_box;
  221. +#ifdef SPU2X_PORTAUDIO
  222. GtkWidget *api_label, *api_box;
  223. +#endif
  224. #if SDL_MAJOR_VERSION >= 2
  225. GtkWidget *sdl_api_label, *sdl_api_box;
  226. #endif
  227. @@ -309,11 +319,14 @@ void DisplayDialog()
  228. mod_label = gtk_label_new("Module:");
  229. mod_box = gtk_combo_box_text_new();
  230. gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "0 - No Sound (Emulate SPU2 only)");
  231. +#ifdef SPU2X_PORTAUDIO
  232. gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "1 - PortAudio (Cross-platform)");
  233. +#endif
  234. gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "2 - SDL Audio (Recommended for PulseAudio)");
  235. //gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "3 - Alsa (probably doesn't work)");
  236. gtk_combo_box_set_active(GTK_COMBO_BOX(mod_box), OutputModule);
  237. +#ifdef SPU2X_PORTAUDIO
  238. api_label = gtk_label_new("PortAudio API:");
  239. api_box = gtk_combo_box_text_new();
  240. #ifdef __linux__
  241. @@ -325,6 +338,7 @@ void DisplayDialog()
  242. gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "OSS");
  243. #endif
  244. gtk_combo_box_set_active(GTK_COMBO_BOX(api_box), OutputAPI);
  245. +#endif
  246. #if SDL_MAJOR_VERSION >= 2
  247. sdl_api_label = gtk_label_new("SDL API:");
  248. @@ -383,8 +397,10 @@ void DisplayDialog()
  249. gtk_container_add(GTK_CONTAINER(output_box), mod_label);
  250. gtk_container_add(GTK_CONTAINER(output_box), mod_box);
  251. +#ifdef SPU2X_PORTAUDIO
  252. gtk_container_add(GTK_CONTAINER(output_box), api_label);
  253. gtk_container_add(GTK_CONTAINER(output_box), api_box);
  254. +#endif
  255. #if SDL_MAJOR_VERSION >= 2
  256. gtk_container_add(GTK_CONTAINER(output_box), sdl_api_label);
  257. gtk_container_add(GTK_CONTAINER(output_box), sdl_api_box);
  258. @@ -430,6 +446,7 @@ void DisplayDialog()
  259. if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1)
  260. OutputModule = gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box));
  261. +#ifdef SPU2X_PORTAUDIO
  262. if (gtk_combo_box_get_active(GTK_COMBO_BOX(api_box)) != -1) {
  263. OutputAPI = gtk_combo_box_get_active(GTK_COMBO_BOX(api_box));
  264. #ifdef __linux__
  265. @@ -456,6 +473,7 @@ void DisplayDialog()
  266. }
  267. #endif
  268. }
  269. +#endif
  270. #if SDL_MAJOR_VERSION >= 2
  271. if (gtk_combo_box_get_active(GTK_COMBO_BOX(sdl_api_box)) != -1) {
  272. diff --git a/plugins/spu2-x/src/SndOut.cpp b/plugins/spu2-x/src/SndOut.cpp
  273. index 7963b12b75..6d9d58c2b3 100644
  274. --- a/plugins/spu2-x/src/SndOut.cpp
  275. +++ b/plugins/spu2-x/src/SndOut.cpp
  276. @@ -88,7 +88,9 @@ SndOutModule *mods[] =
  277. DSoundOut,
  278. WaveOut,
  279. #endif
  280. +#if defined(_WIN32) || defined(SPU2X_PORTAUDIO)
  281. PortaudioOut,
  282. +#endif
  283. #if defined(SPU2X_SDL) || defined(SPU2X_SDL2)
  284. SDLOut,
  285. #endif
  286. diff --git a/plugins/spu2-x/src/SndOut.h b/plugins/spu2-x/src/SndOut.h
  287. index ba84075aec..918d9d08ff 100644
  288. --- a/plugins/spu2-x/src/SndOut.h
  289. +++ b/plugins/spu2-x/src/SndOut.h
  290. @@ -673,7 +673,9 @@ extern SndOutModule *DSoundOut;
  291. extern SndOutModule *XAudio2_27_Out;
  292. extern SndOutModule *XAudio2Out;
  293. #endif
  294. +#if defined(_WIN32) || defined(SPU2X_PORTAUDIO)
  295. extern SndOutModule *PortaudioOut;
  296. +#endif
  297. #if defined(SPU2X_SDL) || defined(SPU2X_SDL2)
  298. extern SndOutModule *const SDLOut;
  299. #endif