
from pythonforandroid.recipe import CythonRecipe
from os.path import join


class AudiostreamRecipe(CythonRecipe):
    version = 'master'
    url = 'https://github.com/kivy/audiostream/archive/{version}.zip'
    name = 'audiostream'
    depends = ['python3', 'sdl2', 'pyjnius']

    def get_recipe_env(self, arch):
        env = super().get_recipe_env(arch)
        sdl_include = 'SDL2'
        sdl_mixer_include = 'SDL2_mixer'
        env['USE_SDL2'] = 'True'
        env['SDL2_INCLUDE_DIR'] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include')

        env['CFLAGS'] += ' -I{jni_path}/{sdl_include}/include -I{jni_path}/{sdl_mixer_include}'.format(
                              jni_path=join(self.ctx.bootstrap.build_dir, 'jni'),
                              sdl_include=sdl_include,
                              sdl_mixer_include=sdl_mixer_include)
        env['NDKPLATFORM'] = self.ctx.ndk_platform
        env['LIBLINK'] = 'NOTNONE'  # Hacky fix. Needed by audiostream setup.py
        return env


recipe = AudiostreamRecipe()

@@ -52,160 +52,528 @@
 rom 
-os.path import join%0A%0A%0Aclass AudiostreamRecipe(CythonRecipe):%0A    version = 'master'%0A    url = 'https://github.com/kivy/audiostream/archive/%7Bversion%7D.zip
+pythonforandroid.toolchain import shprint, current_directory, info%0Aimport sh%0Afrom os.path import join%0A%0A%0Aclass AudiostreamRecipe(CythonRecipe):%0A    # audiostream has no tagged versions; this is the latest commit to master 2020-12-22%0A    # it includes a fix for the dyload issue on android that was preventing use%0A    version = '69f6b100f1ea4e3982a1acf6bbb0804e31a2cd50'%0A    url = 'https://github.com/kivy/audiostream/archive/%7Bversion%7D.zip'%0A    sha256sum = '4d415c91706fd76865d0d22f1945f87900dc42125ff5a6c8d77898ccdf613c21
 '%0A  
@@ -1377,16 +1377,772 @@
 rn env%0A%0A
+    def postbuild_arch(self, arch):%0A        # TODO: This code was copied from pyjnius, but judging by the%0A        #       audiostream history, it looks like this step might have%0A        #       happened automatically in the past.%0A        #       Given the goal of migrating off of recipes, it would%0A        #       be good to repair or build infrastructure for doing this%0A        #       automatically, for when including a java class is%0A        #       the best solution to a problem.%0A        super().postbuild_arch(arch)%0A        info('Copying audiostream java files to classes build dir')%0A        with current_directory(self.get_build_dir(arch.arch)):%0A            shprint(sh.cp, '-a', join('audiostream', 'platform', 'android'), self.ctx.javaclass_dir)%0A%0A
 %0Arecipe 

fix for audiostream/issues/25