Each video game company would have their own agreements with the music they would license, but they would all go through licensing that music and paying for it up front, before the game is made in most cases. It would all be done through agencies and rights-holders groups and things like that. Very rarely would it be done in an informal capacity.
It would be best to speak to individual companies about what they do, but I know, for instance, that if they have music in a game, it is licensed and it's done through a proper process.