Formation and dissociation of hydrogen-related defect centers in Mg-doped GaN