The following code playes "sample.mp3", and terminates. This is so surprising because the data passed via pipe are binary streams, so ffplay should have no idea about the duration of "sample.mp3", but it terminates right after it reaches the end.
$ cat sample.mp3 | ffmpeg -i pipe:0 -f mp3 pipe:1 | ffplay -autoexit -
What binary signal is ffplay watching to detect the terminal of sample.mp3?
-f mp3
produces a muxed file, i.e. it's not a raw stream of MP3 data, but structured input i.e. in a container. There may be a header & trailer, and each chunk of MP3 data is framed.
When ffplay receives a file or pipe input, it probes the input and determines the container type. It then passes the data to that demuxer to parse the stream. Within each demuxer, like the MP3 demuxer, there's a routine which will signal End Of File if some conditions are met. For MP3, if a function to break the buffered data into packets fails, that's EOF.