Step 1: Know the standard trick.
For $\displaystyle\int\frac{p\sin x+q\cos x}{r\sin x+s\cos x}\,dx$, write the top as $A(\text{bottom})+B(\text{derivative of bottom})$. Then the answer is $Ax+B\log|\text{bottom}|+c$.
Step 2: Read $A$ and $B$.
The given answer is $\dfrac{2}{5}x-\dfrac{1}{5}\log(b\sin x+4\cos x)+c$, so $A=\dfrac25$ and $B=-\dfrac15$.
Step 3: Write the matching equation.
The bottom is $b\sin x+4\cos x$, whose derivative is $b\cos x-4\sin x$. So
\[ 2\sin x+a\cos x=\tfrac25(b\sin x+4\cos x)-\tfrac15(b\cos x-4\sin x). \]
Step 4: Compare $\sin x$ terms.
$2=\tfrac25 b+\tfrac45$, so $10=2b+4$, giving $b=3$.
Step 5: Compare $\cos x$ terms.
$a=\tfrac85-\tfrac15 b=\tfrac85-\tfrac35=1$.
Step 6: Add them.
\[ a+b=1+3=4. \]
\[ \boxed{4} \]