Forums

Full Version: A few bugs in SVN
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been playing with VDrift on my new comp today and noticed a few problems. If I start a game, then leave the game, then start a new one, VDrift crashes.

VDrift seems to crash every time I try to play or record a replay. Also, the list or replays in the Replays menu does not display anything. I'll look into the menu problem...
Last bit of info before the crash:
Code:
SOUND FORMAT:
Samples: 37516
Frequency: 44100
Channels: 2
Bits per sample: 16
DESIRED FORMAT:
Samples: 37516
Frequency: 0
Channels: 2
Bits per sample: 0
src/sound.cpp,505: Sound file isn't in desired format: /home/thelusiv/code/vdrift/data/cars/RS2/engine.wav
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/RS2/interior.joe!
Error when loading car definition file:  /home/thelusiv/code/vdrift/data/cars/RS2/RS2.car
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/M8/glass.joe!
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/M8/interior.joe!
Error when loading car definition file:  /home/thelusiv/code/vdrift/data/cars/M8/M8.car
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/RS2/interior.joe!
Error when loading car definition file:  /home/thelusiv/code/vdrift/data/cars/RS2/RS2.car
include/bipointer.h,63: Asked for NULL pointer
Segmentation fault (core dumped)
Code:
SOUND FORMAT:
Samples: 37516
Frequency: 44100
Channels: 2
Bits per sample: 16
DESIRED FORMAT:
Samples: 37516
Frequency: 0
Channels: 2
Bits per sample: 0
src/sound.cpp,505: Sound file isn't in desired format: /home/thelusiv/code/vdrift/data/cars/RS2/engine.wav

There's your problem. You need a 44.1khz engine sound. In my other projects I throw exceptions here that cause the game to exit, but as VDrift doesn't have a very robust exception system set up, I just have it complain to stderr.
Notice that in the desired format it shows a frequency and bits per sample values of 0. This is why it said it's not in the desired format. It probably got 0 because I haven't gotten my sound card on my new machine set up yet, and so there's no sound card to get info from. I got around this by writing a default constructor for the SOUNDINFO class that initializes frequency and bytespersample data members to reasonable values (44100 and 2 respectively).

Despite this being fixed, I still get crashes when I try to start a game and record a replay:

Code:
include/bipointer.h,63: Asked for NULL pointer

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47299085896560 (LWP 4457)]
0x0000000000466bd5 in SOUNDSOURCE::SetPitchSmooth (this=0x0, newpitch=0.143025964, dt=0.00400000019) at src/sound.cpp:1042
1042                    pitch = pitch*(coeff)+newpitch*(1.0-coeff);
(gdb) bt
#0  0x0000000000466bd5 in SOUNDSOURCE::SetPitchSmooth (this=0x0, newpitch=0.143025964, dt=0.00400000019) at src/sound.cpp:1042
#1  0x000000000048a11d in VAMOSWORLD::Update (this=0xbe04e0, timefactor=1, fps=250, js=0x68dac0) at src/vamosworld.cc:933
#2  0x000000000040d892 in Update () at src/main.cpp:437
#3  0x0000000000410c27 in main (argc=1, argv=0x7fff0017e918) at src/main.cpp:1990
Ohhh, you don't have a sound card? Then run "vdrift -nosound"

I'm going to remove the changes to the constructor you made, because they'll let you get around the checking and load things without successfully initializing first, which, as you found, is bad. By the way, the copy constructor and operator= members you wrote are not needed because the defaults will work fine and will automatically update whenever the class members change....

Did you get an "Error opening audio device" or "Sound interface did not create...etc" when you started the game? If so, I can make it just disable sound automatically when that happens.
Ah yes, I forgot about the -nosound option...but really there should be some way VDrift figures this out on its own, instead of crashing.

edit: anyway it still doesn't work.
Code:
SOUND FORMAT:
Samples: 37516
Frequency: 44100
Channels: 2
Bits per sample: 16
DESIRED FORMAT:
Samples: 37516
Frequency: 0
Channels: 2
Bits per sample: 0
src/sound.cpp,589: Sound file isn't in desired format: /home/thelusiv/code/vdrift/data/cars/NS/engine.wav
SOUND FORMAT:
Samples: 52332
Frequency: 44100
Channels: 2
Bits per sample: 16
DESIRED FORMAT:
Samples: 52332
Frequency: 0
Channels: 2
Bits per sample: 0
src/sound.cpp,589: Sound file isn't in desired format: /home/thelusiv/code/vdrift/data/cars/M8/engine.wav
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/M8/glass.joe!
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/M8/interior.joe!
Error when loading car definition file:  /home/thelusiv/code/vdrift/data/cars/M8/M8.car
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/RS2/interior.joe!
Error when loading car definition file:  /home/thelusiv/code/vdrift/data/cars/RS2/RS2.car
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/M8/glass.joe!
Unable to find the file: /home/thelusiv/code/vdrift/data/cars/M8/interior.joe!
Error when loading car definition file:  /home/thelusiv/code/vdrift/data/cars/M8/M8.car
include/bipointer.h,63: Asked for NULL pointer
Segmentation fault (core dumped)

Pretty sure this is related to replays though, not sound.
I don't think it's due to replays. The last line is my bipointer class (a poorly named smart-ish pointer class) telling us that someone asked for a pointer that's NULL. If something's asking for a pointer that's NULL, it's probably because it's about to use it (and create a SEGFAULT). The only class using bipointers is the sound class, and it's used by the gl_car class to get a reference to newly created sources. Like I said, normally when you get a "src/sound.cpp,589: Sound file isn't in desired format" message, I'd throw an exception and have the game quit, because you're going to get a crash later. To say that another way, the game will crash if you get this message. So, don't be surprised. :-)
In R1663 I made the sound engine automatically disable sound if the init fails. I also more completely disabled sound to try to address crashing. Give it a shot and see if it fixes things for you. I can now play the game fine with -nosound, even after leaving and starting over while recording a replay.
Seems fine now to me. I tried running it normally without -nosound. It ran OK, I was able to record replays and play as many games as I liked without crashing. I also didn't get a ton of messages about sounds not being in the expected format. Thanks!
trunk wasn't compiling anymore since about 1654, this fixes it but i don't know if it is correct:
Code:
Index: include/sound.h
===================================================================
--- include/sound.h     (Revision 1667)
+++ include/sound.h     (Arbeitskopie)
@@ -41,7 +41,7 @@

        void Load(const string & filename, const SOUNDINFO & sound_device_info);
        void Unload() {if (loaded && sound_buffer != NULL) delete [] sound_buffer;sound_buffer = NULL;}
-       const SOUNDINFO & GetSoundInfo() const;
+       const SOUNDINFO & GetSoundInfo() const {return info;}
        //const SOUNDINFO & GetOriginalInfo() {return original_info;}
        //const unsigned int GetSize() {return size;}
        //void ConvertTo(const SOUNDINFO & to_info);
Index: src/sound.cpp
===================================================================
--- src/sound.cpp       (Revision 1667)
+++ src/sound.cpp       (Arbeitskopie)
@@ -946,11 +946,6 @@
        sample_pos = (sample_pos + offset*playing) % buffer->GetSoundInfo().GetSamples();
}

-inline const SOUNDINFO & SOUNDBUFFER::GetSoundInfo() const
-{
-       return info;
-}
-
SOUNDSOURCE & SOUND::NewSource(const string & buffername)
{
        if (disable)
I'm not sure why that was causing issues with your compile... but yeah, that fix is fine. I'll make the same fix in my version and check it in. Originally I wanted that function to be inline because it got called a lot, but that's no longer the case, so it's fine.
i'm also not sure what the issue is/was it compiled fine for the i386 version but for ppc i got this linker error:

/usr/bin/ld: Undefined symbols:
SOUNDBUFFER::GetSoundInfo() const
vdrift.build/Objects-normal/ppc/Gl_Car.o reference to undefined SOUNDBUFFER::GetSoundInfo() const
collect2: ld returned 1 exit status