Merge pull request #2068 from jepler/audioio-compat

audioio: By default, be compatible with 4.x
This commit is contained in:
Scott Shawcroft 2019-08-19 19:43:52 -07:00 committed by GitHub
commit bd4d3c6393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -74,6 +74,12 @@ CIRCUITPY_AUDIOIO = $(CIRCUITPY_FULL_BUILD)
endif
CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO)
ifndef CIRCUITPY_AUDIOIO_COMPAT
CIRCUITPY_AUDIOIO_COMPAT = $(CIRCUITPY_AUDIOIO)
endif
CFLAGS += -DCIRCUITPY_AUDIOIO_COMPAT=$(CIRCUITPY_AUDIOIO_COMPAT)
ifndef CIRCUITPY_AUDIOPWMIO
CIRCUITPY_AUDIOPWMIO = 0
endif

View File

@ -33,6 +33,12 @@
#include "shared-bindings/audioio/__init__.h"
#include "shared-bindings/audioio/AudioOut.h"
#ifdef CIRCUITPY_AUDIOIO_COMPAT
#include "shared-bindings/audiocore/Mixer.h"
#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/audiocore/WaveFile.h"
#endif
//| :mod:`audioio` --- Support for audio input and output
//| ======================================================
//|
@ -57,10 +63,19 @@
//| Since CircuitPython 5, `Mixer`, `RawSample` and `WaveFile` are moved
//| to :mod:`audiocore`.
//|
//| For compatibility with CircuitPython 4.x, some builds allow the items in
//| `audiocore` to be imported from `audioio`. This will be removed for all
//| boards in a future build of CicuitPython.
//|
STATIC const mp_rom_map_elem_t audioio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audioio) },
{ MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audioio_audioout_type) },
#ifdef CIRCUITPY_AUDIOIO_COMPAT
{ MP_ROM_QSTR(MP_QSTR_Mixer), MP_ROM_PTR(&audioio_mixer_type) },
{ MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
{ MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
#endif
};
STATIC MP_DEFINE_CONST_DICT(audioio_module_globals, audioio_module_globals_table);