| 34 | namespace cc { |
| 35 | |
| 36 | size_t AudioDecoder::fileRead(void *ptr, size_t size, size_t nmemb, void *datasource) { |
| 37 | AudioDecoder *thiz = (AudioDecoder *)datasource; |
| 38 | ssize_t toReadBytes = std::min((ssize_t)(thiz->_fileData.getSize() - thiz->_fileCurrPos), (ssize_t)(nmemb * size)); |
| 39 | if (toReadBytes > 0) { |
| 40 | memcpy(ptr, (unsigned char *)thiz->_fileData.getBytes() + thiz->_fileCurrPos, toReadBytes); |
| 41 | thiz->_fileCurrPos += toReadBytes; |
| 42 | } |
| 43 | // ALOGD("File size: %d, After fileRead _fileCurrPos %d", (int)thiz->_fileData.getSize(), thiz->_fileCurrPos); |
| 44 | return toReadBytes; |
| 45 | } |
| 46 | |
| 47 | int AudioDecoder::fileSeek(void *datasource, int64_t offset, int whence) { |
| 48 | AudioDecoder *thiz = (AudioDecoder *)datasource; |