<commit_before>/**
 * Copyright {2016} <NAME> aka Aeronica
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.aeronica.mods.mxtune.sound;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import net.aeronica.mods.mxtune.MXTuneMain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ClientAudio
{

    private static final int THREAD_POOL_SIZE = 10;
    private static AudioFormat audioFormat;
    private static ConcurrentLinkedQueue<Integer> entityIDQueue01;
    private static ConcurrentLinkedQueue<Integer> entityIDQueue02;
    private static Map<Integer, AudioData> entityAudioData;
    
    private final static ThreadFactory threadFactory; 
    private final static ExecutorService executorService; 
    private static  ClientAudio instance;

    private ClientAudio(){instance = new ClientAudio();}
    public static ClientAudio getInstance() {return instance;}
    
    static {
        /* Used to track which player/entity queued up music to be played */
        entityIDQueue01 = new ConcurrentLinkedQueue<Integer>();
        entityIDQueue02 = new ConcurrentLinkedQueue<Integer>();
        /* PCM Signed Monaural little endian */
        audioFormat = new AudioFormat(48000, 16, 1, true, false);
        entityAudioData = new HashMap<Integer, AudioData>();
        
        threadFactory = (ThreadFactory) new ThreadFactoryBuilder()
                .setNameFormat("mxTune-ClientAudio-%d")
                .setDaemon(true)
                .build();
        executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE, (java.util.concurrent.ThreadFactory) threadFactory);<commit_msg>Adding comments<commit_after>/**
 * Copyright {2016} <NAME> aka Aeronica
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.aeronica.mods.mxtune.sound;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import net.aeronica.mods.mxtune.MXTuneMain;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ClientAudio
{

    private static final int THREAD_POOL_SIZE = 10;
    private static AudioFormat audioFormat;
    private static ConcurrentLinkedQueue<Integer> entityIDQueue01;
    private static ConcurrentLinkedQueue<Integer> entityIDQueue02;
    private static Map<Integer, AudioData> entityAudioData;
    
    private final static ThreadFactory threadFactory; 
    private final static ExecutorService executorService; 
    private static  ClientAudio instance;

    private ClientAudio(){instance = new ClientAudio();}
    public static ClientAudio getInstance() {return instance;}
    
    static {
        /* Used to track which player/entity queued up music to be played */
        entityIDQueue01 = new ConcurrentLinkedQueue<Integer>(); // Polled in SoundEventHandler#PlaySoundEvent
        entityIDQueue02 = new ConcurrentLinkedQueue<Integer>(); // Polled in CodecPCM
        /* PCM Signed Monaural little endian */
        audioFormat = new AudioFormat(48000, 16, 1, true, false);
        entityAudioData = new HashMap<Integer, AudioData>();
        
        threadFactory = (ThreadFactory) new ThreadFactoryBuilder()
                .setNameFormat("mxTune-ClientAudio-%d")
                .setDaemon(true)
                .build();
        executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE, (java.util.concurrent.ThreadFactory) threadFactory);
{'fraction_non_alphanumeric': 0.08261196838539707, 'fraction_numerical': 0.00978547233722243, 'mean_word_length': 4.0331439393939394, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1692183', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1405, 'n_words': 426}