'only one thread of execution' - not quite. Whilst the esp8266 has only one processor core, you can have multiple threads of execution concurrently. I've not looked at the code you're referring to, but the 'usually' methods are:
dma. This is a hardware peripheral that moves a block of data from ram to/from a peripheral (or ram). Your code tells the dma controller where the block of ram is and what peripheral. You tell the peripheral to talk to the dma controller. For example, the I2S peripheral for digital sound (not sure if the esp8266 has this, the esp32 does) when it needs another sample to send, it requests this from the dma controller (this is all done in hardware on the chip) and the dma controller grabs it from ram and gives it to the peripheral. Rinse and repeat. Once set up, the cpu does not need to intervene. The dma controller can interrupt when it is finished.
Interrupts. An ISR is another thread of execution. You can have multiple ISRs and thus multiple threads of execution. Just that only one is executing at a given instant. You could set up a timer interrupt and the timer ISR reads a value from ram and outputs it.
Both these techniques will probably use what is called a 'pin-pong' buffer. This involves two buffers (or arrays or blocks of memory- however you like to refer to them). Whilst one buffer is being used to output the data, the other is being filled with the next. The idea is that you can fill the one buffer in the time it takes to output the other buffer. Once done, you swap the buffers - the one you just filled is being output and the one that was being used for output now gets loaded with the next load of audio samples. Rinse and repeat.
There other techniques as well, some are just a variation of what I've described.
Tasks like your WiFi are running in the background as another thread of execution. It most likely uses interrupts and dma to do its work.
With the esp8266 the software framework allows the use of FreeRtos - this manages multiple threads of execution. On the esp32 it manages the multiple cores as well.