Contour integration problem with sin and cos so I'm revising contour integration for an upcoming complex analysis exam. I have been asked to integrate $$\int_0^{2\pi}\frac{\sin^2x}{a+b  \cos x}dx$$
I thought the sensible thing to do here would be to substitute in $z=e^{ix}$ and take a contour integral around the unit circle, call this path $\ast$ so that my integral becomes $$\frac{1}{2i}Re(\int_\ast\frac{1-z^2}{az+bz^2}dz)$$
Then, letting $f(z)=\frac{1-z^2}{az+bz^2}$, I thought the function had simple poles at $z=0$ with residue $\frac{1}{a}$ and another simple pole at $z=\frac{-a}{b}$ with residue $\frac{a}{b^2}-\frac{1}{a}$ and thus I get the that $$Re(\int_\ast\frac{1-z^2}{az+bz^2}dz)=2i(2\pi i)\frac{a}{b^2}=-4\pi(\frac{a}{b^2})$$ which is not the answer given, that is: $=\frac{2\pi}{b^2}[a-\sqrt{a^2-b^2}]$,but I can't work out why. 
Any help appreciated, thank you in advance. 

If you substitute $z = e^{ix}$, then $\sin(x) = (z - \frac{1}{z})/(2i) $ and $\sin^2(x) =(z-\frac{1}{z})^2/(-4) = \frac{(z^2-1)^2}{-4z^2} $
$dz = ie^{ix}dx = izdx$ or $dx = \frac{dz}{zi}$
$a+b\cos x = a + b\frac{z+\frac{1}{z}}{2} = \frac{2az + bz^2 +1}{2z}$
So,
$$I = \int_*\frac{\frac{(z^2-1)^2}{-4z^2}dz}{zi\frac{2az + bz^2 +1}{2z}}$$
$$I = \int_*\frac{i(z^2-1)^2dz}{2z^2(2az + bz^2 +1)}$$
