Skip to content

Commit 63f4c1c

Browse files
Cleanup AudioFlinger
1 parent 76be9fd commit 63f4c1c

File tree

2 files changed

+6
-62
lines changed

2 files changed

+6
-62
lines changed

internal_filesystem/lib/mpos/audio/__init__.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,3 @@
33
# Simple routing: play_wav() -> I2S, play_rtttl() -> buzzer, record_wav() -> I2S mic
44

55
from .audioflinger import AudioFlinger
6-
7-
# Create singleton instance
8-
_instance = AudioFlinger.get()
9-
10-
# Re-export stream type constants for convenience
11-
STREAM_MUSIC = AudioFlinger.STREAM_MUSIC
12-
STREAM_NOTIFICATION = AudioFlinger.STREAM_NOTIFICATION
13-
STREAM_ALARM = AudioFlinger.STREAM_ALARM
14-
15-
# Re-export main API from singleton instance for backward compatibility
16-
init = _instance.init
17-
play_wav = _instance.play_wav
18-
play_rtttl = _instance.play_rtttl
19-
stop = _instance.stop
20-
pause = _instance.pause
21-
resume = _instance.resume
22-
set_volume = _instance.set_volume
23-
get_volume = _instance.get_volume
24-
is_playing = _instance.is_playing
25-
record_wav = _instance.record_wav
26-
is_recording = _instance.is_recording
27-
has_i2s = _instance.has_i2s
28-
has_buzzer = _instance.has_buzzer
29-
has_microphone = _instance.has_microphone
30-
31-
__all__ = [
32-
# Class
33-
'AudioFlinger',
34-
35-
# Stream types
36-
'STREAM_MUSIC',
37-
'STREAM_NOTIFICATION',
38-
'STREAM_ALARM',
39-
40-
# Playback functions
41-
'init',
42-
'play_wav',
43-
'play_rtttl',
44-
'stop',
45-
'pause',
46-
'resume',
47-
'set_volume',
48-
'get_volume',
49-
'is_playing',
50-
51-
# Recording functions
52-
'record_wav',
53-
'is_recording',
54-
55-
# Hardware checks
56-
'has_i2s',
57-
'has_buzzer',
58-
'has_microphone',
59-
]

internal_filesystem/lib/mpos/audio/audioflinger.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self):
3737
if AudioFlinger._instance:
3838
return
3939
AudioFlinger._instance = self
40-
40+
4141
self._i2s_pins = None # I2S pin configuration dict (created per-stream)
4242
self._buzzer_instance = None # PWM buzzer instance
4343
self._current_stream = None # Currently playing stream
@@ -377,12 +377,11 @@ def is_recording(self):
377377
bool: True if recording active, False otherwise
378378
"""
379379
return self._current_recording is not None and self._current_recording.is_recording()
380-
381-
380+
382381
# ============================================================================
383-
# Class methods that delegate to singleton instance
382+
# Class method forwarding to singleton instance
384383
# ============================================================================
385-
# Store original instance methods BEFORE we replace them with class methods
384+
# Store original instance methods before replacing them
386385
_original_methods = {}
387386
_methods_to_delegate = [
388387
'init', 'play_wav', 'play_rtttl', 'record_wav', 'stop', 'pause', 'resume',
@@ -393,10 +392,9 @@ def is_recording(self):
393392
for method_name in _methods_to_delegate:
394393
_original_methods[method_name] = getattr(AudioFlinger, method_name)
395394

396-
# Helper function to create delegating class methods
395+
# Helper to create delegating class methods
397396
def _make_class_method(method_name):
398397
"""Create a class method that delegates to the singleton instance."""
399-
# Capture the original method in the closure
400398
original_method = _original_methods[method_name]
401399

402400
@classmethod
@@ -406,7 +404,7 @@ def class_method(cls, *args, **kwargs):
406404

407405
return class_method
408406

409-
410407
# Attach class methods to AudioFlinger
411408
for method_name in _methods_to_delegate:
412409
setattr(AudioFlinger, method_name, _make_class_method(method_name))
410+

0 commit comments

Comments
 (0)