<commit_before>#include <alloca.h>
#include <locale.h>
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <alsa/asoundlib.h>
#include <sys/ioctl.h>
#include <fftw3.h>
#define PI 3.14159265358979323846
#define max(a,b) \
   ({ __typeof__ (a) _a = (a); \
       __typeof__ (b) _b = (b); \
     _a > _b ? _a : _b; })
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include <getopt.h>
#include <pthread.h>

#ifdef __GNUC__
// curses.h or other sources may already define
#undef  GCC_UNUSED
#define GCC_UNUSED __attribute__((unused))
#else
#define GCC_UNUSED /* nothing */
#endif

struct sigaction old_action;
int M = 2048;
int shared[2048];
int format = -1;
unsigned int rate = 0;

void sigint_handler(int sig_no GCC_UNUSED)
{
	printf("\033[0m\n");
	system("setfont /usr/share/consolefonts/Lat2-Fixed16.psf.gz  >/dev/null 2>&1");
	system("setterm -cursor on");
	system("setterm -blank 10");
	system("clear");
	system("stty echo");
	printf("CTRL-C pressed -- goodbye\n");
	sigaction(SIGINT, &old_action, NULL);
	kill(0, SIGINT);
}

//ALSA audio listner
void*
music(void* data)
{
	signed char *buffer;
	snd_pcm_t *handle;
	snd_pcm_hw_params_t *params;
	unsigned int val;
	snd_pcm_uframes_t frames;
	char *device = ((char*)data);
	val = 44100;
	int i, n, o, size, dir, err, lo;
	int tempr, templ;
	int radj, ladj;

//**init sound device***//

	if ((err = snd_pcm_open(&handle, device,  SND_PCM_STREAM_CAPTURE , 0) < 0))
		printf("error opening stream:    %s\n", snd_strerror(err) );
#ifdef DEBUG
	else printf("open stream succes\n");
#endif

	snd_pcm_hw_params_alloca(&params);//assembling params
	snd_pcm_hw_params_any (handle, params);//setting defaults or something
	snd_pcm_hw_params_set_access(handle, params,
	                             SND_PCM_ACCESS_RW_INTERLEAVED);//interleeaved mode right left right left
	snd_pcm_hw_params_set_format(handle, params,
	                             SND_PCM_FORMAT_S16_LE); //trying to set 16bit
	snd_pcm_hw_params_set_channels(handle, params, 2);//asuming stereo
	val = 44100;
	snd_pcm_hw_params_set_rate_near(handle, params, &val, &dir);//trying 44100 rate
	frames = 256;
	snd_pcm_hw_params_set_period_size_near(handle, params, &frames,
	                                       &dir); //number of frames pr read

	err = snd_pcm_hw_params(handle, params); //atempting to set params
	if (err < 0) {
		fprintf(stderr,
		        "unable to set hw parameters: %s\n",
		        snd_strerror(err));
		exit(1);
	}

	snd_pcm_hw_params_get_format(params,
	                             (snd_pcm_format_t * )&val); //getting actual format
//convverting result to number of bits<commit_msg>fix Segmentation fault after failing to open stream<commit_after>#include <alloca.h>
#include <locale.h>
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <alsa/asoundlib.h>
#include <sys/ioctl.h>
#include <fftw3.h>
#define PI 3.14159265358979323846
#define max(a,b) \
   ({ __typeof__ (a) _a = (a); \
       __typeof__ (b) _b = (b); \
     _a > _b ? _a : _b; })
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include <getopt.h>
#include <pthread.h>

#ifdef __GNUC__
// curses.h or other sources may already define
#undef  GCC_UNUSED
#define GCC_UNUSED __attribute__((unused))
#else
#define GCC_UNUSED /* nothing */
#endif

struct sigaction old_action;
int M = 2048;
int shared[2048];
int format = -1;
unsigned int rate = 0;

void sigint_handler(int sig_no GCC_UNUSED)
{
	printf("\033[0m\n");
	system("setfont /usr/share/consolefonts/Lat2-Fixed16.psf.gz  >/dev/null 2>&1");
	system("setterm -cursor on");
	system("setterm -blank 10");
	system("clear");
	system("stty echo");
	printf("CTRL-C pressed -- goodbye\n");
	sigaction(SIGINT, &old_action, NULL);
	kill(0, SIGINT);
}

//ALSA audio listner
void*
music(void* data)
{
	signed char *buffer;
	snd_pcm_t *handle;
	snd_pcm_hw_params_t *params;
	unsigned int val;
	snd_pcm_uframes_t frames;
	char *device = ((char*)data);
	val = 44100;
	int i, n, o, size, dir, err, lo;
	int tempr, templ;
	int radj, ladj;

//**init sound device***//

	if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_CAPTURE, 0) < 0)) {
		fprintf(stderr,
		        "error opening stream: %s\n",
		        snd_strerror(err));
		exit(1);
	}
#ifdef DEBUG
	else printf("open stream successful\n");
#endif

	snd_pcm_hw_params_alloca(&params);//assembling params
	snd_pcm_hw_params_any (handle, params);//setting defaults or something
	snd_pcm_hw_params_set_access(handle, params,
	                             SND_PCM_ACCESS_RW_INTERLEAVED);//interleeaved mode right left right left
	snd_pcm_hw_params_set_format(handle, params,
	                             SND_PCM_FORMAT_S16_LE); //trying to set 16bit
	snd_pcm_hw_params_set_channels(handle, params, 2);//asuming stereo
	val = 44100;
	snd_pcm_hw_params_set_rate_near(handle, params, &val, &dir);//trying 44100 rate
	frames = 256;
	snd_pcm_hw_params_set_period_size_near(handle, params, &frames,
	                                       &dir); //number of frames pr read

	err = snd_pcm_hw_params(handle, params); //atempting to set params
	if (err < 0) {
		fprintf(stderr,
		        "unable to set hw parameters: %s\n",
		        snd_strerror(err));
		exit(1);
	}

	snd_pcm_hw_params_get_format(params,
	                             (snd_pcm_format_t * )&val); //getting actual format
//convverting result to number of bits
{'fraction_non_alphanumeric': 0.1350210970464135, 'fraction_numerical': 0.026233718583746103, 'mean_word_length': 3.671808054841474, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5761060', 'n_tokens_mistral': 2160, 'n_tokens_neox': 2020, 'n_words': 494}