With this contour specified, how can the integral $\int\limits_{-\infty}^{\infty}dx \frac{e^{-ixt}}{x^2-a^2}$ be equal to $0$? 
*

*Consider the integral $$I=\int\limits_{-\infty}^{\infty}dx \frac{e^{-ixt}}{x^2-a^2}=\int\limits_{-\infty}^{\infty}dx \frac{\cos(xt)}{x^2-a^2}$$ for $t<0$ and $a>0$. The integrand has poles at $x=\pm a$ on the real axis. We can use contour integral to evaluate this.


*Let us choose a contour that lies entirely in the upper half of the complex plane. Let the contour be so indented that the smaller semicircles $C_1$ and $C_2$, each of radius $\epsilon$, goes over the poles at $x=\pm a$, and the larger semicircle $\Gamma$ also lies in the upper half of the complex plane (so that contribution from it vanishes).


*With this choice of contour, I want to show that $I=0$. This is a famous integral that arises in solving the wave equation by the method of Green's function. But my physics textbooks do not work out this integral explicitly, by considering different parts of the contour piece by piece. See page 125, figure 50 here.


*For this contour, using residue theorem and Jordan's lemma, gives (schematically),
$$0=\int\limits_{-\infty}^{-a-\varepsilon} +\int\limits_{-a-\varepsilon}^{-a+\varepsilon}+\int\limits_{-a+\varepsilon}^{a-\varepsilon}+\int\limits_{a-\varepsilon}^{a+\varepsilon}
+\int\limits_{a+\varepsilon}^{+\infty}.$$
In the limit, $\varepsilon\to 0$, the sum of the 1st, 3rd and fifth integrals reduce to the required integral I. Thus, $$I+\int\limits_{-a-\varepsilon}^{-a+\varepsilon}+\int\limits_{a-\varepsilon}^{a+\varepsilon}=0.$$ Therefore, in the limit $\varepsilon\to 0$, $$I=i\pi{\rm Res}_f(z=+a)+i\pi{\rm Res}_f(z=+a)\\
=i\pi\left(\frac{e^{-iat}}{2a}\right)+i\pi\left(\frac{e^{iat}}{-2a}\right)\\
=\frac{\pi}{a}\sin(at).$$
This video suggests that the required integral is nonzero. But it does not agree with the notes I linked. What is going on?
 A: Use twice the corollary to the lemma given in the most upvoted answer here: Definite integral calculation with poles at $0$ and $\pm i\sqrt{3}$
Thus, we get, on corresponding little semicircles around $\;z=\pm a\;$ , that
$$Res_f(z=\pm a)=\lim_{z\to\pm a}(z\pm a)f(z)=\begin{cases}\cfrac{e^{-iat}}{2a}\\{}\\\cfrac {e^{iat}}{-2a}\end{cases}$$
But we only want the real part of the above (since the integral for the imaignary part vanishes for sure since we get an odd function on a convergent imporper integral on the whole real line), and thus we get that the residues are
$$\frac{\cos at}{\pm2a}$$
and from here the integral vanishes.
A: $\def\o{\omega}$
I assume you mean the following quotation:

Let’s first look at the case with $t<0$.  Here, $e^{-i\o t}\to 0$ when $\o\to+i\infty$. This means that, for $t<0$, we can close the contour $C$ in the upper-half plane as shown in the figure and the extra semi-circle doesn’t give rise to any further contribution. But there are no poles in the upper-half plane. This means that, by the Cauchy residue theorem, $G_\text{ret}(\mathbf {r},t)=0$ when $t<0$.

Observe that the integral in question:
$$
I(k)=\int\limits_{-\infty}^{\infty} \frac{e^{-i\o t}}{\o^2-c^2k²}d\o,\tag1
$$
in fact does not exist in the usual sense (for $ck\in\mathbb R$) but only as (for example) a corresponding Cauchy principal value.
I would assume that the claim quoted above is meaningful only if the integral $(1)$ is understood as including the semicircle paths to bypass the poles and fixing the paths to lie in the upper complex half-plane.
This understanding is consistent with the later definition of the advanced Green's function which fixes the paths for bypassing the poles to lie in the lower complex half-plane.
