<commit_before># Copyright 2014 <NAME> <<EMAIL>>
#
# This software is provided 'as-is', without any express or implied
# warranty.  In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
#    claim that you wrote the original software. If you use this software
#    in a product, an acknowledgment in the product documentation would be
#    appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
#    misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.

from sdl2 cimport *
from sdl2_mixer cimport *
from pygame_sdl2.rwobject cimport to_rwops
from libc.string cimport memset

import sys
from pygame_sdl2.error import error

import pygame_sdl2.mixer_music as music
import pygame_sdl2

cdef object preinit_args = None
cdef object output_spec = None

cdef dict channel_events = {}
cdef dict channel_queued = {}
cdef dict current_sounds = {}

cdef void channel_callback(int channel):
    cdef int etype = 0
    cdef SDL_Event e
    cdef Sound next_sound

    etype = channel_events.get(channel, 0)
    if etype != 0:
        memset(&e, 0, sizeof(SDL_Event))
        e.type = etype
        SDL_PushEvent(&e)

    next_sound = channel_queued.get(channel)
    if next_sound:
        # Prevent garbage collection.
        current_sounds[channel] = next_sound
        channel_queued[channel] = None

        Mix_PlayChannelTimed(channel, next_sound.chunk, 0, -1)

@pygame_sdl2.register_init
def init(frequency=22050, size=MIX_DEFAULT_FORMAT, channels=2, buffer=4096):
    if get_init() is not None:
        return

    for flag in (MIX_INIT_FLAC, MIX_INIT_MOD, MIX_INIT_MODPLUG,
                 MIX_INIT_MP3, MIX_INIT_OGG, MIX_INIT_FLUIDSYNTH):
        if Mix_Init(flag) != flag:
            sys.stderr.write("{}\n".format(SDL_GetError()))

    if preinit_args:
        frequency, size, channels, buffer = preinit_args

    if Mix_OpenAudio(frequency, size, channels, buffer) != 0:
        raise error()<commit_msg>Do not print an error on mixer init failure.<commit_after># Copyright 2014 <NAME> <<EMAIL>>
#
# This software is provided 'as-is', without any express or implied
# warranty.  In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
#    claim that you wrote the original software. If you use this software
#    in a product, an acknowledgment in the product documentation would be
#    appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
#    misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.

from sdl2 cimport *
from sdl2_mixer cimport *
from pygame_sdl2.rwobject cimport to_rwops
from libc.string cimport memset

import sys
from pygame_sdl2.error import error

import pygame_sdl2.mixer_music as music
import pygame_sdl2

cdef object preinit_args = None
cdef object output_spec = None

cdef dict channel_events = {}
cdef dict channel_queued = {}
cdef dict current_sounds = {}

cdef void channel_callback(int channel):
    cdef int etype = 0
    cdef SDL_Event e
    cdef Sound next_sound

    etype = channel_events.get(channel, 0)
    if etype != 0:
        memset(&e, 0, sizeof(SDL_Event))
        e.type = etype
        SDL_PushEvent(&e)

    next_sound = channel_queued.get(channel)
    if next_sound:
        # Prevent garbage collection.
        current_sounds[channel] = next_sound
        channel_queued[channel] = None

        Mix_PlayChannelTimed(channel, next_sound.chunk, 0, -1)

# A list of errors that occured during mixer initialization.
errors = [ ]

@pygame_sdl2.register_init
def init(frequency=22050, size=MIX_DEFAULT_FORMAT, channels=2, buffer=4096):
    if get_init() is not None:
        return

    for flag in (MIX_INIT_FLAC, MIX_INIT_MOD, MIX_INIT_MODPLUG,
                 MIX_INIT_MP3, MIX_INIT_OGG, MIX_INIT_FLUIDSYNTH):

        if Mix_Init(flag) != flag:
            errors.append("{}\n".format(SDL_GetError()))

    if preinit_args:
        frequency, size, channels, buffer = preinit_args

    if Mix_OpenAudio(frequency, size, channels, buffer) != 0:
        raise error()
{'fraction_non_alphanumeric': 0.06925956738768718, 'fraction_numerical': 0.013311148086522463, 'mean_word_length': 3.6063218390804597, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3918444', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1417, 'n_words': 539}