[ELI5] What exactly is a buffer in Computer Science?

782 views

I’ve always been confused with buffer for I’ve heard the term in many realms including programming (nodejs) and operating systems; plus, “buffering” in video players.

So, is it the same “buffer” everywhere? I mean is it a standard of some kind because it’s been used in many technologies related to computer science.

In: Technology

6 Answers

Anonymous 0 Comments

A buffer is temporary holding place for data before it is processed. When you type on your keyboard, the keystroke data is put into a buffer. Then depending on what program, text box, etc. you are using, the processor processes the data and makes the appropriate updates to where it is needed (like showing it on screen, applying any commands or special processes to it like copy and paste functions, storing the information in RAM/ROM, etc.) Typically each process has a separate buffer which your CPU can access, handle reading from, writing to, and processing, as well as share information between other buffers. i.e. your keyboard has one buffer, your mouse another, your display another, your web browser another etc. and your processor handles information sharing between all of them.

When a video or music buffers, it is similar. There is data being held for display/playback that then gets processed. However if the buffer empties without having an end-of-file marker (a special flag designed to tell the playback device that no more data is needed), the program won’t know what data to display/playback next. Thus in the context of video/audio, buffering is when the video/audio buffer is filled with data when it has processed all the data in the buffer without receiving an end-of-file marker. Streamed content has special markers to mark the end of a piece of content that act as end-of-file markers.

Anonymous 0 Comments

It is a temporary storage of information. especially when you talk about realtime data tranfers so if there is any transmission problem the user will not observe it

If you eat a chocolate bar each day you could purchase one each day but then you are out if you cant get to the store. If you instead have a buffer if 7 chocolate bar at home you can miss going to the store for a week and still have a bar to eat each day. That is what a buffer is, temperate storage of something.

For video what you do is to first retrieve for example 10 seconds and then start to play. So if the network drops some packet with data you can ask for it to be retransmitted to fix the problem. IT can also be that packets are delayed or the rate you get them at drops for a few seconds.

Anonymous 0 Comments

Simply put, it is storage for data.

So an audio buffer stores bytes of audio signal to be consumed/processed.

And it’s a term generally used for any data.

Anonymous 0 Comments

Think of it like a temporary place to put things that need to be worked on or processed. Like a to-do pile of work on your desk. Instead of just doing work the moment it’s given to you, you have people put it in a folder on your desk so you can work on everything at a steady pace.

For videos for example, the rate at which you download a file may fluctuate but if the playback of that video did too it would be very awkward to watch. A buffer is a temporary storage place for some of that video so the downloading process can put it somewhere as it comes in and the playback process can play it at a steady rate.

Anonymous 0 Comments

Buffering is a *technique*, not one specific place in the computer.

Here’s the an example. Before a video player starts displaying a movie, it gathers up several seconds worth. This way, if the internet pauses for a little while, the player can keep showing the movie without a pause. When you see a “buffering” message in the middle of playing a video, that means that the internet got so slow that the player ran out of video to display. A smart player might notice that 10 seconds (or whatever) of buffered video wasn’t enough, given how flaky the internet is at this location is, so maybe it’ll bump up the buffer to 20 or 30 seconds.

If the internet is simply too slow to show the movie, then buffering won’t fix it. Instead, the player might need to download the whole thing before showing it. But often the average internet speed is faster than needed to show the movie, but it runs slower sometimes and faster sometimes. That’s where buffering can help.

Anonymous 0 Comments

A buffer is a convenient place to get stuff (in this case data) quickly.

An analogy is that I have 4 crates of beer in my garage. That is a buffer for the 36 crates the local shop has.

In turn, I move 6 at a time into my fridge. That is another buffer.

When I want a beer, 5 times out of 6 there is one ready in my fridge so I can grab it super easy.

1 time out of 6 I have to go to the garage and refuel the fridge. Still better than a trip every time.

Every crate I have to go to the garage.