I create a game in C language using SDL2 and I got a problem for 3 days that I couldn't fix, because everything was OK, there was no any problem/bug with my code (I am sure about that), but somehow it just did not work, and finallly I found the problem, so I just wanted to share the answer just in case someone will have the same problem in the future.
SDL2 Mix_LoadWAV problem. Mix_LoadWAV(path) loads the wav successfully but then frees it automatically
31 Views Asked by Arda Altun At
1
There are 1 best solutions below
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in SDL-2
- Running SDL library in Qt Creator
- SDL create bordrerless window with rounded corner
- weird > thing when compiling for sdl2 in g++
- Buildozer building pygame error. Fatal error: 'longintrepr.h' file not found. sdl2.c
- setting window to fullscreen introduces delay
- SDL_ttf is missing when compiling SDL2
- fatal error: 'longintrepr.h' file not found
- Linking error for SDL2 on linux while building with cargo
- C/SDL program, render not working with my renderer
- How can I move my MSYS2 folder to another folder (both in the D driver) if possible?
- Loading image and Invert colors with SDL_Image
- Collision Detection works only with two objects
- Can't build project with SDL2 libraries near to it and cmake on Windows
- Visual studio 2019 C++ compiler error on release x64 with WinToast library
- Cannot link a C file that has an easy example with SDL2
Related Questions in SDL-MIXER
- Emscripten and sdl2_mixer error: Mix_Init: no sound/music loaders supported ()
- How to get the good version of SDL_mixer?
- SDL2 Mix_LoadWAV problem. Mix_LoadWAV(path) loads the wav successfully but then frees it automatically
- SDL2 pause sound using SDL_Mixer so it can be resumed
- SDL Mixer sounds not playing with PlayChannel()
- Cannot install sdl_mixer with conan
- How to change Mix_Chunk to Mix_Music in SDL2
- Unable to play mp3 file with SDL mixer 2.6.3 in c++
- Error : "SDL could not initialize! SDL_Error: dsp: No such audio device"
- Problem with playing the next song automatically with SDL_Mixer
- CMake error, SDL_mixer could not find libxmp
- Mix_PlayMusic() not playing music
- why is incorrect audio format?
- Mix_OpenAudio Closes Program Without Creating Window
- SDL_RWread and SDL2 Mixer Loading entire file into memory
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
When I create a variable like
in the main function (or globally by defining it out of the main function),after assigning to the variable and check if it is null or not, it says it returned the pointer successfully, so it is not null. But when I try to play the sound, (whether in the main function or in the game loop) it just wasn't playing and it was returning null when I check if the sfx variable was null or not. So there was a problem that was freeing the sfx automatically, I tried everything but nothing worked. And finally I just changed the path to
and it works now, it doesn't free the sfx until we do it manually. So, just remove the ./ part, I haven't tried if it would be same for a sub-folder path (i.e ./sounds/coin.wav -> sounds/coin.wav), but I just wanted to share the answer because I found nothing on google about this. So I hope this will be helpful for someone who would have the same problem in the future.