<commit_before>/*
 * ePaper integration.
 */
#include <stdio.h>
#include <sys/time.h>
#include "mpepa.h"
#include "config.h"
#include "player.h"
#include "utils.h"
#define TOSLEEP 25

#define EPS_PARTIAL 1

/* the button modes
	 -1 - not initialized
	  0 - default (pause/next/DNP)
	  1 - stream  (pause/up/down)
*/
static int _epmode=-1;

/* update mode
	-1 - full
	 0 - none
	 1 - play/pause
	 2 - buttons
	 4 - title
*/
static int _umode=-1;

/*
 * the last known state. Used to avoid updating too much.
 * set to mpc_start to force update.
 */
static mpcmd last=mpc_start;
static int _updating=0;
static struct timeval lastevent;
static pthread_mutex_t _debouncelock=PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _updatelock=PTHREAD_MUTEX_INITIALIZER;
static unsigned ucount=0;
static char lasttitle[MAXPATHLEN+1];

/*
 * update the display with the current title and buttons
 * runs in it's own thread to not block updating
 */
static void *_update( ) {
	mpplaylist *current=NULL;

	blockSigint();

	while( getConfig()->command != mpc_quit ) {
		pthread_mutex_lock( &_updatelock );
		current=getConfig()->current;
		epsWipeFull( epm_both );

		if( current != NULL ) {
			if( current->prev != NULL ) {
				epsDrawString( epm_red, 40, 159, current->prev->title->display, 0 );
			}<commit_msg>fix race condition in ePaper support<commit_after>/*
 * ePaper integration.
 */
#include <stdio.h>
#include <sys/time.h>
#include "mpepa.h"
#include "config.h"
#include "player.h"
#include "utils.h"
#define TOSLEEP 25

#define EPS_PARTIAL 1

/* the button modes
	 -1 - not initialized
	  0 - default (pause/next/DNP)
	  1 - stream  (pause/up/down)
*/
static int _epmode=-1;

/* update mode
	-1 - full
	 0 - none
	 1 - play/pause
	 2 - buttons
	 4 - title
*/
static int _umode=-1;

/*
 * the last known state. Used to avoid updating too much.
 * set to mpc_start to force update.
 */
static mpcmd last=mpc_start;
static int _updating=0;
static struct timeval lastevent;
static pthread_mutex_t _debouncelock=PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t _updatelock=PTHREAD_MUTEX_INITIALIZER;
static unsigned ucount=0;
static char lasttitle[MAXPATHLEN+1];

/*
 * update the display with the current title and buttons
 * runs in it's own thread to not block updating
 */
static void *_update( ) {
	mpplaylist *current=NULL;

	blockSigint();

	while( getConfig()->command != mpc_quit ) {
		pthread_mutex_lock( &_updatelock );
		/* don't update on exit! */
		if( getConfig()->command == mpc_quit ) {
			continue;
		}
		current=getConfig()->current;
		epsWipeFull( epm_both );

		if( current != NULL ) {
			if( current->prev != NULL ) {
				epsDrawString( epm_red, 40, 159, current->prev->title->display, 0 );
			}
{'fraction_non_alphanumeric': 0.12283290298782737, 'fraction_numerical': 0.016230173367760975, 'mean_word_length': 3.7746478873239435, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, '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': '6831917', 'n_tokens_mistral': 1051, 'n_tokens_neox': 957, 'n_words': 279}