SHARE
TWEET

opusfile callbacks

daskol Oct 23rd, 2019 62 in 6 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int TDecoder::ReadCallback(void *stream, uint8_t *ptr, int nobytes) {
  2.     auto is = reinterpret_cast<std::istream *>(stream);
  3.     return is->read(reinterpret_cast<char *>(ptr), nobytes).gcount();
  4. }
  5.  
  6. int TDecoder::SeekCallback(void *stream, int64_t offset, int whence) {
  7.     auto is = reinterpret_cast<std::istream *>(stream);
  8.     std::ios::seekdir dir;
  9.     switch (whence) {
  10.     case SEEK_SET:
  11.         dir = is->beg;
  12.         break;
  13.     case SEEK_CUR:
  14.         dir = is->cur;
  15.         break;
  16.     case SEEK_END:
  17.         dir = is->end;
  18.         break;
  19.     default:
  20.         throw std::runtime_error("unexpected whence");
  21.     }
  22.     is->seekg(offset, dir);
  23.     return 0;
  24. }
  25.  
  26. int64_t TDecoder::TellCallback(void *stream) {
  27.     auto is = reinterpret_cast<std::istream *>(stream);
  28.     return is->tellg();
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top