So, does Barry retain his consciousness of timeline x when in timeline x+1?
Yes. This is shown in the following episode where Barry tries to speak to Dr Wells about what he knows and remembers from Timeline X. The things he remembers includes all of the events with the Weather Wizard, the attacks on Joe and the police station/chief, the kidnapping of Iris, the tidal wave, and Iris' confession of feelings for him
If yes, then did Barry of timeline x have the memories of timeline x-1 when he saw a speed mirage?
I'm going to assume that Timeline X-1 is the one where Nora Allen wasn't killed in the battle between Flashes, and Thawne didn't replace Dr. Wells.
In this case, the Barry(X) we see would not have full memories of Timeline X-1, as he never experienced those events himself.
If so, why didn't he stop the events of timeline x from happening?
Barry does stop the events of Timeline X from happening - that's essentially what creates Timeline X-1. The differences between them all stem from Barry suddenly knowing what originally happened, and then taking actions to prevent them. Unfortunately, things did not end up how Barry expected/hoped (particularly in the case of Iris, and yet another person learning the true identity of The Flash),