MPD

- Main Page
- Data Structures
- Files

- File List
- Globals

Functions

# src/decoder_buffer.h File Reference

`#include <stdbool.h>`
`#include <stddef.h>`

Go to the source code of this file.

## Functions
struct decoder_buffer * | decoder_buffer_new (struct decoder *decoder, struct input_stream *is, size_t size)
| Creates a new buffer.
void | decoder_buffer_free (struct decoder_buffer *buffer)
| Frees resources used by the decoder_buffer object.
bool | decoder_buffer_is_empty (const struct decoder_buffer *buffer)
bool | decoder_buffer_is_full (const struct decoder_buffer *buffer)
bool | decoder_buffer_fill (struct decoder_buffer *buffer)
| Read data from the input_stream and append it to the buffer.
const void * | decoder_buffer_read (const struct decoder_buffer *buffer, size_t *length_r)
| Reads data from the buffer.
void | decoder_buffer_consume (struct decoder_buffer *buffer, size_t nbytes)
| Consume (delete, invalidate) a part of the buffer.
bool | decoder_buffer_skip (struct decoder_buffer *buffer, size_t nbytes)
| Skips the specified number of bytes, discarding its data.

## Function Documentation

void decoder_buffer_consume | ( | struct decoder_buffer * | buffer,
|  | size_t | nbytes
| ) |  |

Consume (delete, invalidate) a part of the buffer.

The "nbytes" parameter must not be larger than the length returned by decoder_buffer_read().

Parameters:

  buffer | the decoder_buffer object
  nbytes | the number of bytes to consume

bool decoder_buffer_fill | ( | struct decoder_buffer * | buffer | ) |

Read data from the input_stream and append it to the buffer.

Returns:
  true if data was appended; false if there is no data available (yet), end of file, I/O error or a decoder command was received

void decoder_buffer_free | ( | struct decoder_buffer * | buffer | ) |

Frees resources used by the decoder_buffer object.

bool decoder_buffer_is_empty | ( | const struct decoder_buffer * | buffer | ) |

bool decoder_buffer_is_full | ( | const struct decoder_buffer * | buffer | ) |

struct decoder_buffer* decoder_buffer_new | ( | struct decoder * | decoder,
|  | struct input_stream * | is,
|  | size_t | size
| ) |  | `[read]`

Creates a new buffer.

Parameters:

  decoder | the decoder object, used for decoder_read(), may be NULL
  is | the input stream object where we should read from
  size | the maximum size of the buffer

Returns:
  the new decoder_buffer object

const void* decoder_buffer_read | ( | const struct decoder_buffer * | buffer,
|  | size_t * | length_r
| ) |  |

Reads data from the buffer.

This data is not yet consumed, you have to call decoder_buffer_consume() to do that. The returned buffer becomes invalid after a decoder_buffer_fill() or a decoder_buffer_consume() call.

Parameters:

  buffer | the decoder_buffer object
  length_r | pointer to a size_t where you will receive the number of bytes available

Returns:
  a pointer to the read buffer, or NULL if there is no data available

bool decoder_buffer_skip | ( | struct decoder_buffer * | buffer,
|  | size_t | nbytes
| ) |  |

Skips the specified number of bytes, discarding its data.

Parameters:

  buffer | the decoder_buffer object
  nbytes | the number of bytes to skip

Returns:
  true on success, false on error