Carbon and oxygen depletion and extinction in the translucent cloud toward HD 24534 (X Persei)