How to know which format to play in Voicemail

Hey,
Here is the sceanrio: Let’s suppose that I have a voicemail stored with g729 & g711 in the same time. When I want to check the new messages, Asterisk choose the play the message stored in G711. I want to know, why specifically it choose to play that file & not the file stored with G729. & I want to know the function which allowed Asterisk to choose that file.

Thank you for the help