FastLED 3.9.15
Loading...
Searching...
No Matches

◆ plm_buffer_write()

size_t fl::third_party::plm_buffer_write ( plm_buffer_t * self,
uint8_t * bytes,
size_t length )

Definition at line 877 of file pl_mpeg.hpp.

877 {
878 if (self->mode == PLM_BUFFER_MODE_FIXED_MEM) {
879 return 0;
880 }
881
882 if (self->discard_read_bytes) {
883 // This should be a ring buffer, but instead it just shifts all unread
884 // data to the beginning of the buffer and appends new data at the end.
885 // Seems to be good enough.
886
888 if (self->mode == PLM_BUFFER_MODE_RING) {
889 self->total_size = 0;
890 }
891 }
892
893 // Do we have to resize to fit the new data?
894 size_t bytes_available = self->capacity - self->length;
895 if (bytes_available < length) {
896 size_t new_size = self->capacity;
897 do {
898 new_size *= 2;
899 } while (new_size - self->length < length);
900 self->bytes = (uint8_t *)PLM_REALLOC(self->bytes, new_size);
901 self->capacity = new_size;
902 }
903
904 fl::memcopy(self->bytes + self->length, bytes, length);
905 self->length += length;
906 self->has_ended = FALSE;
907 return length;
908}
fl::UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
void plm_buffer_discard_read_bytes(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:951
@ PLM_BUFFER_MODE_FIXED_MEM
Definition pl_mpeg.hpp:721
unsigned char uint8_t
Definition coder.h:209
enum plm_buffer_mode mode
Definition pl_mpeg.hpp:743
void * memcopy(void *dest, const void *src, size_t n) FL_NOEXCEPT
Definition cstring.h:103
#define PLM_REALLOC(p, sz)
Definition pl_mpeg.hpp:181
#define FALSE
Definition pl_mpeg.hpp:175

References FALSE, FL_NOEXCEPT, length(), fl::memcopy(), plm_buffer_discard_read_bytes(), PLM_BUFFER_MODE_FIXED_MEM, PLM_BUFFER_MODE_RING, and PLM_REALLOC.

Referenced by plm_read_packets(), plm_seek(), and plm_seek_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: