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
DuerOS-Light-SDK-v1.1.0/duer-os-light/src/media-player/baidu_media_play_buffer.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | // Copyright 2017 Baidu Inc. All Rights Reserved. |
| TMBOY | 47:9e361da97763 | 2 | // Author: Chen Xihao (chenxihao@baidu.com) |
| TMBOY | 47:9e361da97763 | 3 | // |
| TMBOY | 47:9e361da97763 | 4 | // Description: Buffer for media player |
| TMBOY | 47:9e361da97763 | 5 | |
| TMBOY | 47:9e361da97763 | 6 | #ifndef BAIDU_TINYDU_IOT_OS_SRC_MEDIA_PLAYER_BAIDU_MEDIA_PLAY_BUFFER_H |
| TMBOY | 47:9e361da97763 | 7 | #define BAIDU_TINYDU_IOT_OS_SRC_MEDIA_PLAYER_BAIDU_MEDIA_PLAY_BUFFER_H |
| TMBOY | 47:9e361da97763 | 8 | |
| TMBOY | 47:9e361da97763 | 9 | #include "rtos.h" |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | namespace duer { |
| TMBOY | 47:9e361da97763 | 12 | |
| TMBOY | 47:9e361da97763 | 13 | // FIFO circle buffer |
| TMBOY | 47:9e361da97763 | 14 | class MediaPlayBuffer { |
| TMBOY | 47:9e361da97763 | 15 | public: |
| TMBOY | 47:9e361da97763 | 16 | MediaPlayBuffer(void* buffer, size_t size); |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | ~MediaPlayBuffer(); |
| TMBOY | 47:9e361da97763 | 19 | |
| TMBOY | 47:9e361da97763 | 20 | // write buffer until buffer has enough space |
| TMBOY | 47:9e361da97763 | 21 | void write(const void* data, size_t size); |
| TMBOY | 47:9e361da97763 | 22 | |
| TMBOY | 47:9e361da97763 | 23 | // read buffer until buffer has enough data |
| TMBOY | 47:9e361da97763 | 24 | void read(void* data, size_t size); |
| TMBOY | 47:9e361da97763 | 25 | |
| TMBOY | 47:9e361da97763 | 26 | void clear(); |
| TMBOY | 47:9e361da97763 | 27 | |
| TMBOY | 47:9e361da97763 | 28 | static const size_t MIN_BUFFER_SIZE = 5 * 1024; |
| TMBOY | 47:9e361da97763 | 29 | |
| TMBOY | 47:9e361da97763 | 30 | static const size_t DEFAULT_BUFFER_SIZE = 10 * 1024; |
| TMBOY | 47:9e361da97763 | 31 | |
| TMBOY | 47:9e361da97763 | 32 | private: |
| TMBOY | 47:9e361da97763 | 33 | MediaPlayBuffer(const MediaPlayBuffer&); |
| TMBOY | 47:9e361da97763 | 34 | |
| TMBOY | 47:9e361da97763 | 35 | MediaPlayBuffer& operator=(const MediaPlayBuffer&); |
| TMBOY | 47:9e361da97763 | 36 | |
| TMBOY | 47:9e361da97763 | 37 | char* const _buffer; |
| TMBOY | 47:9e361da97763 | 38 | const size_t _BUFFER_SIZE; |
| TMBOY | 47:9e361da97763 | 39 | Mutex _mutex; |
| TMBOY | 47:9e361da97763 | 40 | bool _wait; |
| TMBOY | 47:9e361da97763 | 41 | Semaphore _semaphore; |
| TMBOY | 47:9e361da97763 | 42 | int _start; |
| TMBOY | 47:9e361da97763 | 43 | int _end; |
| TMBOY | 47:9e361da97763 | 44 | }; |
| TMBOY | 47:9e361da97763 | 45 | |
| TMBOY | 47:9e361da97763 | 46 | } // namespace duer |
| TMBOY | 47:9e361da97763 | 47 | |
| TMBOY | 47:9e361da97763 | 48 | #endif // BAIDU_TINYDU_IOT_OS_SRC_MEDIA_PLAYER_BAIDU_MEDIA_PLAY_BUFFER_H |
