bumble 0.0.219__py3-none-any.whl → 0.0.220__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bumble/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.0.219'
32
- __version_tuple__ = version_tuple = (0, 0, 219)
31
+ __version__ = version = '0.0.220'
32
+ __version_tuple__ = version_tuple = (0, 0, 220)
33
33
 
34
34
  __commit_id__ = commit_id = None
bumble/apps/auracast.py CHANGED
@@ -742,10 +742,9 @@ async def run_receive(
742
742
  ]
743
743
  packet_stats = [0, 0]
744
744
 
745
- audio_output = await audio_io.create_audio_output(output)
746
- # This try should be replaced with contextlib.aclosing() when python 3.9 is no
747
- # longer needed.
748
- try:
745
+ async with contextlib.AsyncExitStack() as stack:
746
+ audio_output = await audio_io.create_audio_output(output)
747
+ stack.push_async_callback(audio_output.aclose)
749
748
  await audio_output.open(
750
749
  audio_io.PcmFormat(
751
750
  audio_io.PcmFormat.Endianness.LITTLE,
@@ -793,8 +792,6 @@ async def run_receive(
793
792
  terminated = asyncio.Event()
794
793
  big_sync.on(big_sync.Event.TERMINATION, lambda _: terminated.set())
795
794
  await terminated.wait()
796
- finally:
797
- await audio_output.aclose()
798
795
 
799
796
 
800
797
  async def run_transmit(
@@ -891,11 +888,10 @@ async def run_transmit(
891
888
  print('Start Periodic Advertising')
892
889
  await advertising_set.start_periodic()
893
890
 
894
- audio_input = await audio_io.create_audio_input(input, input_format)
895
- pcm_format = await audio_input.open()
896
- # This try should be replaced with contextlib.aclosing() when python 3.9 is no
897
- # longer needed.
898
- try:
891
+ async with contextlib.AsyncExitStack() as stack:
892
+ audio_input = await audio_io.create_audio_input(input, input_format)
893
+ pcm_format = await audio_input.open()
894
+ stack.push_async_callback(audio_input.aclose)
899
895
  if pcm_format.channels != 2:
900
896
  print("Only 2 channels PCM configurations are supported")
901
897
  return
@@ -967,8 +963,6 @@ async def run_transmit(
967
963
  await iso_queues[1].write(lc3_frame[mid:])
968
964
 
969
965
  frame_count += 1
970
- finally:
971
- await audio_input.aclose()
972
966
 
973
967
 
974
968
  def run_async(async_command: Coroutine) -> None:
bumble/audio/io.py CHANGED
@@ -19,13 +19,13 @@ from __future__ import annotations
19
19
 
20
20
  import abc
21
21
  import asyncio
22
+ import concurrent.futures
22
23
  import dataclasses
23
24
  import enum
24
25
  import logging
25
26
  import pathlib
26
27
  import sys
27
28
  import wave
28
- from concurrent.futures import ThreadPoolExecutor
29
29
  from typing import TYPE_CHECKING, AsyncGenerator, BinaryIO
30
30
 
31
31
  from bumble.colors import color
@@ -176,7 +176,7 @@ class ThreadedAudioOutput(AudioOutput):
176
176
  """
177
177
 
178
178
  def __init__(self) -> None:
179
- self._thread_pool = ThreadPoolExecutor(1)
179
+ self._thread_pool = concurrent.futures.ThreadPoolExecutor(1)
180
180
  self._pcm_samples: asyncio.Queue[bytes] = asyncio.Queue()
181
181
  self._write_task = asyncio.create_task(self._write_loop())
182
182
 
@@ -405,7 +405,7 @@ class ThreadedAudioInput(AudioInput):
405
405
  """Base class for AudioInput implementation where reading samples may block."""
406
406
 
407
407
  def __init__(self) -> None:
408
- self._thread_pool = ThreadPoolExecutor(1)
408
+ self._thread_pool = concurrent.futures.ThreadPoolExecutor(1)
409
409
  self._pcm_samples: asyncio.Queue[bytes] = asyncio.Queue()
410
410
 
411
411
  @abc.abstractmethod