Browse Source

Only do audio conversion if audio is initialized

Also experimented with Tracy callstacks, currently disabled due to
crashing in audio callback callstack collection.
pitch-detection
Macoy Madson 9 months ago
parent
commit
5cd6e0be60
  1. 1
      src/Tracy.cake
  2. 18
      test/src/VocalGame.cake

1
src/Tracy.cake

@ -65,6 +65,7 @@ unexpected location?")
(defmacro module-use-tracy-build-options ()
(tokenize-push output
(add-build-options "-DTRACY_ENABLE")
;; (add-build-options "-DTRACY_CALLSTACK=10") ;; TODO: Causes exit code 134, failing in tracy alloc
(add-c-search-directory-module "Dependencies/tracy"))
(return true))

18
test/src/VocalGame.cake

@ -2,8 +2,6 @@
(import "Ogre.cake" "OgreInitialize.cake" "SDL.cake" "Math.cake" "Tracy.cake")
(module-use-tracy-build-options)
;; TODO: Should this happen automatically, because import automatically adds current working dir?
;; Should it add working dir?
(add-c-search-directory-module ".")
@ -12,6 +10,7 @@
"<math.h>" "<stdio.h>" "<string.h>")
;; These are read and written to from different threads (currently, without locking)
(var audio-is-initialized bool false)
(var audio-is-recording bool false)
(var audio-input-buffer (* Uint8) null)
(var audio-input-buffer-size int 0)
@ -150,6 +149,10 @@
input-device-spec-out (* SDL_AudioSpec)
&return bool)
(ZoneScopedN "Audio intialization")
;; This will take a while. Make sure we aren't marked as ready while preparing
(set audio-is-initialized false)
(var audio-driver (* (const char)) (SDL_GetCurrentAudioDriver))
(scope-timed "Audio drivers"
(printf "Available drivers:\n")
@ -273,6 +276,8 @@
(when output-device-out (set (deref output-device-out) output-device-id))
(when input-device-out (set (deref input-device-out) input-device-id))
(set audio-is-initialized true)
(return (and output-device-id input-device-id)))
(defun-local sdl-audio-close (output-device SDL_AudioDeviceID
@ -418,7 +423,8 @@
(var prev-recording-value bool audio-is-recording)
(set audio-is-recording (at SDL_SCANCODE_SPACE currentKeyStates))
(when (and (!= prev-recording-value audio-is-recording)
(when (and audio-is-initialized
(!= prev-recording-value audio-is-recording)
(not audio-is-recording))
(ZoneScopedN "Audio conversion")
(scope ;; Convert audio to playback format.
@ -540,7 +546,6 @@
(set exit-reason "Failed to render frame")
(break))))
(FrameMarkNamed "Shutdown")
(ZoneScopedN "Shutdown")
(set audio-is-recording false)
@ -591,7 +596,9 @@
(defun-comptime process-3d-assets (manager (& ModuleManager) module (* Module) &return bool)
(scope ;; Models/meshes
;; Make sure output dir exists and we have an absolute path to it
(var model-assets ([] (* (const char))) (array "Monkey" "MaterialSphere"))
(var model-relative-dir (* (const char)) "test/data/Models")
(makeDirectory model-relative-dir)
;; Output must be absolute or OgreMeshTool will fail (probably due to different working dir)
(var model-output-dir (* (const char)) (makeAbsolutePath_Allocated null model-relative-dir))
@ -599,7 +606,6 @@
(Logf "Asset-Building: could not make directory %s absolute\n" model-relative-dir)
(return false))
(var model-assets ([] (* (const char))) (array "Monkey" "MaterialSphere"))
(var i int 0)
(while (< i (array-size model-assets))
(var blend-asset ([] MAX_PATH_LENGTH char) (array 0))
@ -697,3 +703,5 @@ install ImageMagick. See https://www.imagemagick.org/script/download.php\n")
(use-ogre-build-options) ;; Only needed for the dependency
(add-cpp-build-dependency "OgreHlms.cpp")
(module-use-tracy-build-options)

Loading…
Cancel
Save