(self, chunk)
| 379 | # |
| 380 | |
| 381 | def _read_fmt_chunk(self, chunk): |
| 382 | try: |
| 383 | wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<HHLLH', chunk.read(14)) |
| 384 | except struct.error: |
| 385 | raise EOFError from None |
| 386 | if wFormatTag != WAVE_FORMAT_PCM and wFormatTag != WAVE_FORMAT_EXTENSIBLE: |
| 387 | raise Error('unknown format: %r' % (wFormatTag,)) |
| 388 | try: |
| 389 | sampwidth = struct.unpack_from('<H', chunk.read(2))[0] |
| 390 | except struct.error: |
| 391 | raise EOFError from None |
| 392 | if wFormatTag == WAVE_FORMAT_EXTENSIBLE: |
| 393 | try: |
| 394 | cbSize, wValidBitsPerSample, dwChannelMask = struct.unpack_from('<HHL', chunk.read(8)) |
| 395 | # Read the entire UUID from the chunk |
| 396 | SubFormat = chunk.read(16) |
| 397 | if len(SubFormat) < 16: |
| 398 | raise EOFError |
| 399 | except struct.error: |
| 400 | raise EOFError from None |
| 401 | if SubFormat != KSDATAFORMAT_SUBTYPE_PCM: |
| 402 | try: |
| 403 | import uuid |
| 404 | subformat_msg = f'unknown extended format: {uuid.UUID(bytes_le=SubFormat)}' |
| 405 | except Exception: |
| 406 | subformat_msg = 'unknown extended format' |
| 407 | raise Error(subformat_msg) |
| 408 | self._sampwidth = (sampwidth + 7) // 8 |
| 409 | if not self._sampwidth: |
| 410 | raise Error('bad sample width') |
| 411 | if not self._nchannels: |
| 412 | raise Error('bad # of channels') |
| 413 | self._framesize = self._nchannels * self._sampwidth |
| 414 | self._comptype = 'NONE' |
| 415 | self._compname = 'not compressed' |
| 416 | |
| 417 | |
| 418 | class Wave_write: |
no test coverage detected