I think the easiest way to see that
$x(t) = a \cos \omega t + b\sin \omega t \tag{1}$
is the general solution of
$\dfrac{\partial^2 x(t)}{\partial t^2} + \omega^2 x(t) = 0 \tag{2}$
is to exploit the good ol' plug and grind method, to wit: we have, from (1)
$\dfrac{\partial x(t)}{\partial t} = -a \omega \sin \omega t + b \omega \cos \omega t, \tag{3}$
and
$\dfrac{\partial^2 x(t)}{\partial t^2} = -a \omega^2 \cos \omega t - b \omega^2 \sin \omega t; \tag{4}$
so much for the grinding; if we now plug (1) and (4) into (2) we obtain the identity
$-\omega^2 (a \cos \omega t + b\sin \omega t) + \omega^2(a \cos \omega t + b\sin \omega t) = 0, \tag{5}$
which shows that functions of the form (1) solve (2); to see that (1) represents all solutions in full generality, we need to establish that it embraces all possible initial conditions via appropriate choice of $a$ and $b$. This means that given $x(t_0)$ and $(\partial x(t_0)/\partial t)$ we can find $a$ and $b$ such that
$x(t_0) = a\cos \omega t_0 + b\sin\omega t_0, \tag{6}$
and
$\dfrac{\partial x(t_0)}{\partial t} = -a \omega\sin\omega t_0 + b\omega\cos\omega t_0. \tag{7}$
We may write (6), (7) in matrix-vector form:
$\begin{bmatrix} \cos \omega t_0 & \sin \omega t_0 \\ -\omega \sin \omega t_0 & \omega \cos \omega t_0 \end{bmatrix} \begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} x(t_0) \\ \dfrac{\partial x(t_0)}{\partial t} \end{pmatrix}; \tag{8}$
since the determinant of the matrix on the left of (8) is $\omega(\cos^2 \omega t_0 + \sin^2 \omega t_0) = \omega \ne 0$ except as a trivial case, we see that $a$, $b$ are uniquely determined by the initial conditions and thus (1) represents a complete family of solutions to (2); it is thus the general solution.
I thinks that's the easy way; but if one wants to show that the general solution indeed follows from the derived identity
$\left(\dfrac{\partial x}{\partial t}\right)^2 + \omega^2 x^2 = c, \; \text{a constant}, \tag{9}$
which is actually a rather elegant approach to this problem (in my humble opinion), then a slightly more sophisticated methodology than good ol' plug and grind must be employed, and this may be done as follows: we observe that (9) is in fact the equation of an ellipse centered at $(0, 0)$ in the $x(t)$-$\dot x(t)$ plane, where I have introduced the notation
$\dot x(t) = \dfrac{\partial x(t)}{\partial t} \tag{10}$
for the sake of notational convenience. This ellipse may be represented parametrically in centered polar coordinates by setting
$x = \dfrac{\sqrt c}{\omega}\cos \theta \tag{11}$
and
$\dot x = \sqrt c \sin \theta; \tag{12}$
we see from (11), (12) that
$\dot x^2 + \omega^2 x^2 = c \sin^2 \theta + \omega^2 \dfrac{c}{\omega^2}\cos^2 \theta =
c(\sin^2 \theta + \cos^2 \theta) = c, \tag{13}$
so that (9) is in fact satisfied. $\theta$ is in fact a differentiable function of $t$, since $x$ and $\dot x$ are; this may be seen by an easy application of the implicit function theorem to (11) and (12); alternatively one may, in a region where $\cos \theta \ne 0$, i.e., where $x(t) \ne 0$, use the formula
$\omega \tan \theta(t) = \dfrac{\sqrt c \sin \theta(t)}{\sqrt c \omega^{-1} \cos \theta(t)} = \dfrac{\dot x(t)}{x(t)} \tag{14}$
which implies
$\theta (t) = \tan^{-1} (\dfrac{\dot x(t)}{\omega x(t)}), \tag{15}$
showing that $\dot \theta(t)$ exists and is continuous since $x(t)$ and $\dot x(t)$ are (either by hypothesis or the fact that $x(t)$ solves (2)) continuously differentiable. In the event that $x(t) = 0$ for some $t$, we may use the corresponding formula in terms of $\cot$:
$\theta(t) = \cot^{-1} (\dfrac{\omega x(t)}{\dot x (t)}). \tag{16}$
Inspecting (9), we note that the constant $c \ge 0$, and $c = 0$ precisely when $x(t) = \dot x (t) = 0$ for all $t$; thus for any non-trivial ($c > 0$) solution at least one of $x(t), \dot x(t) \ne 0$ at all times, so one of (15), (16) may always be applied; $\dot \theta(t)$ exists for all $t$. Since $\theta(t)$ is differentiable, from (11) we obtain
$\dot x(t) = -\dfrac{\sqrt c }{\omega} \dot \theta(t) \sin \theta(t), \tag{16}$
and comparing this with (12) we find
$\sqrt c \sin \theta(t) = -\dfrac{\sqrt c }{\omega} \dot \theta(t) \sin \theta(t),\tag{17}$
which immediately yields
$\dfrac{\dot \theta(t)}{\omega} = -1 \tag{18}$
or
$\dot \theta(t) = -\omega; \tag{19}$
integrating (19):
$\theta (t) - \theta(t_0) = \int_{t_0}^t \theta(s) ds = -\int_{t_0}^t \omega ds = -\omega(t - t_0) \tag{20}$
whence
$\theta(t) = -\omega(t - t_0) + \theta(t_0); \tag{21}$
Inserting this into (11):
$x(t) = \dfrac{\sqrt c}{\omega} \cos (-\omega(t - t_0) + \theta(t_0)); \tag{22}$
a tad of re-arranging:
$x(t) = \dfrac{\sqrt c}{\omega} \cos (-\omega t + (\theta(t_0) + \omega t_0)); \tag{23}$
(23) may be expressed as the sum of a $\sin$ and $\cos$ term by means of the usual formula the cosine of the sum of two angles:
$x(t) = \dfrac{\sqrt c}{\omega} (\cos(\omega t_0 + \theta(t_0)) \cos (-\omega t) - \sin(\omega t_0 + \theta(t_0)) \sin (-\omega t)), \tag{24}$
or, using the even-odd properties of $\sin$ and $\cos$,
$x(t) = \dfrac{\sqrt c}{\omega} (\cos(\omega t_0 + \theta(t_0)) \cos (\omega t) + \sin(\omega t_0 + \theta(t_0)) \sin (\omega t)). \tag{25}$
If we set
$a = \dfrac{\sqrt c}{\omega}\cos(\omega t_0 + \theta(t_0)), \tag{26}$
$b = \dfrac{\sqrt c}{\omega}\sin(\omega t_0 + \theta(t_0)), \tag{27}$
(25) becomes
$x(t) = a \cos \omega t + b \sin \omega t; \tag{28}$
we see that the general solution of (2) indeed follows by direct deduction, as opposed to verification by substitution, from (9).
Note: for those interested, a similar technique was invoked by Yours Truly to answer this similar question. End of Note.
Hope this helps. Cheers,
and as always,
Fiat Lux!!!