Using buffers improves the performance of multimedia applications that perform numerous file I/O operations when accessing media devices. With buffered file I/O, the system maintains a block of memory that the operating system uses to store data as it is read from (or written to) the disk. If data is already in the buffer, the operating system can transfer the record to the application's area without reading the sector from the disk. This improves performance by reducing the number of times the application accesses the disk for read or write operations. The application only accesses the media device when the buffer must be filled from or written to the disk.
Many factors must be considered when deciding whether or not to use buffered file I/O; for example, the number and size of read and write operations. Although it is difficult to identify criteria for using buffered I/O, there are some general guidelines you can follow. It is a good idea to use buffered I/O for applications that perform many I/O operations, less than 4KB each. However, if you are performing I/O operations where buffer sizes may be larger than 4KB (as in the case of streaming), it might be best to use unbuffered I/O. If an application such as the Sync/Stream Manager (SSM) provides its own internal buffers, a secondary set of buffers during run-time may hinder, rather than improve, performance. Experiment to optimize file I/O for your application's requirements.