Self-sustained oscillations of open cavity flows: when the inner flow dynamics couple to the shear-layer oscillations