| 366 | self._data_seek_needed = 1 |
| 367 | |
| 368 | def readframes(self, nframes): |
| 369 | if self._data_seek_needed: |
| 370 | self._data_chunk.seek(0, 0) |
| 371 | pos = self._soundpos * self._framesize |
| 372 | if pos: |
| 373 | self._data_chunk.seek(pos, 0) |
| 374 | self._data_seek_needed = 0 |
| 375 | if nframes == 0: |
| 376 | return b'' |
| 377 | data = self._data_chunk.read(nframes * self._framesize) |
| 378 | if self._sampwidth != 1 and sys.byteorder == 'big': |
| 379 | data = _byteswap(data, self._sampwidth) |
| 380 | if self._convert and data: |
| 381 | data = self._convert(data) |
| 382 | self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) |
| 383 | return data |
| 384 | |
| 385 | # |
| 386 | # Internal methods. |