Yes, $f=x$ almost everywhere wrt $P$. Consider the push-forward measure $\mu=f_*P$
(in probability, it is also called the distribution of $f$). It is defined as
$\mu(E)=P(f^{-1}(E))$. This $\mu$ is a probability measure on $C$. Your condition becomes
$$\int_C d\mu=x,$$
and this implies that $\mu$ is an atom at $x$.