There is another way of looking at it, though. When you meditate, doing shikentaza, “just sitting”, it quickly becomes clear that your mind is full of these little transient moments, thoughts you dwell on, from sexual fantasies to worries about your job to memories of your childhood. During meditation, you get hints that there is a sort of space between these thoughts, moments when that stream of thoughts just isn’t happening. Buddhism developed a kind of philosophy of mind called yogacara, and a kind of analytical model of psychology based on that called abhidharma.
In this (very analytical, even scientific) view, what we call consciousness is a flow of these events, one after another. (This is interestingly like the global workspace theory of consciousness; I’m going to write more on that in the future too.)
When you pay attention to those moments, though, you see they all have to do with the roots of duhkha: you dwell on thoughts of pleasant things; you think of unpleasant things that hurt you in the past or that you fear happening in the future; you fantasize plans of how things should be and how to make things go your way. It’s that stream of moments of “dwelling-on” that make up ordinary consciousness, and the way we feel about them that is duhkha.
In yogacara, it’s that stream of ordinary dwelling-on thoughts that are samsara and the source of suffering. The space between them, those moments when you’re not dwelling on some particular thought, but freely responding in the moment, is nirvana.