Automatic stabilization of inspiratory oxygen pressure and endexpiratory carbon dioxide pressure in a closed spirometer system