Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-mbed5-blinky by
baidu_media_play_buffer.h
00001 // Copyright 2017 Baidu Inc. All Rights Reserved. 00002 // Author: Chen Xihao (chenxihao@baidu.com) 00003 // 00004 // Description: Buffer for media player 00005 00006 #ifndef BAIDU_TINYDU_IOT_OS_SRC_MEDIA_PLAYER_BAIDU_MEDIA_PLAY_BUFFER_H 00007 #define BAIDU_TINYDU_IOT_OS_SRC_MEDIA_PLAYER_BAIDU_MEDIA_PLAY_BUFFER_H 00008 00009 #include "rtos.h" 00010 00011 namespace duer { 00012 00013 // FIFO circle buffer 00014 class MediaPlayBuffer { 00015 public: 00016 MediaPlayBuffer(void* buffer, size_t size); 00017 00018 ~MediaPlayBuffer(); 00019 00020 // write buffer until buffer has enough space 00021 void write(const void* data, size_t size); 00022 00023 // read buffer until buffer has enough data 00024 void read(void* data, size_t size); 00025 00026 void clear(); 00027 00028 static const size_t MIN_BUFFER_SIZE = 5 * 1024; 00029 00030 static const size_t DEFAULT_BUFFER_SIZE = 10 * 1024; 00031 00032 private: 00033 MediaPlayBuffer(const MediaPlayBuffer&); 00034 00035 MediaPlayBuffer& operator=(const MediaPlayBuffer&); 00036 00037 char* const _buffer; 00038 const size_t _BUFFER_SIZE; 00039 Mutex _mutex; 00040 bool _wait; 00041 Semaphore _semaphore; 00042 int _start; 00043 int _end; 00044 }; 00045 00046 } // namespace duer 00047 00048 #endif // BAIDU_TINYDU_IOT_OS_SRC_MEDIA_PLAYER_BAIDU_MEDIA_PLAY_BUFFER_H
Generated on Tue Jul 12 2022 16:28:53 by
1.7.2
