# HG changeset patch # User nenolod # Date 1169794372 28800 # Node ID c0f69d57483b16af34f4ce6992029e35106958c5 # Parent 6e0751b8b2a1eaef4f461f58f85d2f1e2d6042bc [svn] - change some references for long to int, reported by and patch by Kazuki Oikawa, closes #769. diff -r 6e0751b8b2a1 -r c0f69d57483b ChangeLog --- a/ChangeLog Thu Jan 25 22:27:29 2007 -0800 +++ b/ChangeLog Thu Jan 25 22:52:52 2007 -0800 @@ -1,3 +1,11 @@ +2007-01-26 06:27:29 +0000 William Pitcock + revision [1186] + - who the fuck put that there + + trunk/src/sexypsf/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + 2007-01-26 05:44:10 +0000 William Pitcock revision [1184] - songchange: use asynchronous hooks instead of a polling event diff -r 6e0751b8b2a1 -r c0f69d57483b src/tta/crc32.h --- a/src/tta/crc32.h Thu Jan 25 22:27:29 2007 -0800 +++ b/src/tta/crc32.h Thu Jan 25 22:52:52 2007 -0800 @@ -31,7 +31,7 @@ #ifndef CRC32_H #define CRC32_H -const unsigned long crc32_table[256] = { +const unsigned int crc32_table[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -101,10 +101,10 @@ #define UPDATE_CRC32(x, crc) crc = \ (((crc>>8) & 0x00FFFFFF) ^ crc32_table[(crc^x) & 0xFF]) -static unsigned long -crc32 (unsigned char *buffer, unsigned long len) { - unsigned long i; - unsigned long crc = 0xFFFFFFFF; +static unsigned int +crc32 (unsigned char *buffer, unsigned int len) { + unsigned int i; + unsigned int crc = 0xFFFFFFFF; for (i = 0; i < len; i++) UPDATE_CRC32(buffer[i], crc); diff -r 6e0751b8b2a1 -r c0f69d57483b src/tta/filters.h --- a/src/tta/filters.h Thu Jan 25 22:27:29 2007 -0800 +++ b/src/tta/filters.h Thu Jan 25 22:52:52 2007 -0800 @@ -32,10 +32,10 @@ #define FILTERS_H ///////// Filter Settings ////////// -static long flt_set[3] = {10, 9, 10}; +static int flt_set[3] = {10, 9, 10}; __inline void -memshl (register long *pA, register long *pB) { +memshl (register int *pA, register int *pB) { *pA++ = *pB++; *pA++ = *pB++; *pA++ = *pB++; @@ -47,11 +47,11 @@ } __inline void -hybrid_filter (fltst *fs, long *in) { - register long *pA = fs->dl; - register long *pB = fs->qm; - register long *pM = fs->dx; - register long sum = fs->round; +hybrid_filter (fltst *fs, int *in) { + register int *pA = fs->dl; + register int *pB = fs->qm; + register int *pM = fs->dx; + register int sum = fs->round; if (!fs->error) { sum += *pA++ * *pB, pB++; @@ -100,7 +100,7 @@ } void -filter_init (fltst *fs, long shift) { +filter_init (fltst *fs, int shift) { memset (fs, 0, sizeof(fltst)); fs->shift = shift; fs->round = 1 << (shift - 1); diff -r 6e0751b8b2a1 -r c0f69d57483b src/tta/ttadec.c --- a/src/tta/ttadec.c Thu Jan 25 22:27:29 2007 -0800 +++ b/src/tta/ttadec.c Thu Jan 25 22:52:52 2007 -0800 @@ -41,28 +41,28 @@ static unsigned char isobuffers[ISO_BUFFERS_SIZE + 4]; static unsigned char *iso_buffers_end = isobuffers + ISO_BUFFERS_SIZE; -static unsigned long pcm_buffer_size; +static unsigned int pcm_buffer_size; static decoder tta[MAX_NCH]; // decoder state -static long cache[MAX_NCH]; // decoder cache +static int cache[MAX_NCH]; // decoder cache tta_info *ttainfo; // currently playing file info -static unsigned long fframes; // number of frames in file -static unsigned long framelen; // the frame length in samples -static unsigned long lastlen; // the length of the last frame in samples -static unsigned long data_pos; // currently playing frame index -static unsigned long data_cur; // the playing position in frame +static unsigned int fframes; // number of frames in file +static unsigned int framelen; // the frame length in samples +static unsigned int lastlen; // the length of the last frame in samples +static unsigned int data_pos; // currently playing frame index +static unsigned int data_cur; // the playing position in frame -static long maxvalue; // output data max value -static unsigned long *seek_table; // the playing position table -static unsigned long st_state; //seek table status +static int maxvalue; // output data max value +static unsigned int *seek_table; // the playing position table +static unsigned int st_state; //seek table status -static unsigned long frame_crc32; -static unsigned long bit_count; -static unsigned long bit_cache; +static unsigned int frame_crc32; +static unsigned int bit_count; +static unsigned int bit_cache; static unsigned char *bitpos; -static unsigned long bitrate; +static unsigned int bitrate; void get_id3v1_tag (tta_info *ttainfo); int get_id3v2_tag (tta_info *ttainfo); @@ -75,10 +75,10 @@ bitpos = iso_buffers_end; } -__inline void get_binary(unsigned long *value, unsigned long bits) { +__inline void get_binary(unsigned int *value, unsigned int bits) { while (bit_count < bits) { if (bitpos == iso_buffers_end) { - long res = fread(isobuffers, 1, + int res = fread(isobuffers, 1, ISO_BUFFERS_SIZE, ttainfo->HANDLE); if (!res) { ttainfo->STATE = READ_ERROR; @@ -99,12 +99,12 @@ bit_cache &= bit_mask[bit_count]; } -__inline void get_unary(unsigned long *value) { +__inline void get_unary(unsigned int *value) { *value = 0; while (!(bit_cache ^ bit_mask[bit_count])) { if (bitpos == iso_buffers_end) { - long res = fread(isobuffers, 1, + int res = fread(isobuffers, 1, ISO_BUFFERS_SIZE, ttainfo->HANDLE); if (!res) { ttainfo->STATE = READ_ERROR; @@ -129,12 +129,12 @@ bit_count--; } -static long done_buffer_read() { - unsigned long crc32, rbytes, res; +static int done_buffer_read() { + unsigned int crc32, rbytes, res; frame_crc32 ^= 0xFFFFFFFFUL; rbytes = iso_buffers_end - bitpos; - if (rbytes < sizeof(long)) { + if (rbytes < sizeof(int)) { memcpy(isobuffers, bitpos, 4); res = fread(isobuffers + rbytes, 1, ISO_BUFFERS_SIZE - rbytes, ttainfo->HANDLE); @@ -147,7 +147,7 @@ memcpy(&crc32, bitpos, 4); crc32 = ENDSWAP_INT32(crc32); - bitpos += sizeof(long); + bitpos += sizeof(int); res = (crc32 != frame_crc32); bit_cache = bit_count = 0; @@ -165,14 +165,14 @@ /************************* decoder functions ****************************/ -static long skip_id3v2_header (FILE *infile) { +static int skip_id3v2_header (FILE *infile) { struct { unsigned char id[3]; unsigned short version; unsigned char flags; unsigned char size[4]; } __ATTRIBUTE_PACKED__ id3v2; - unsigned long len = 0; + unsigned int len = 0; // read ID3V2 header if (fread (&id3v2, sizeof(id3v2), 1, infile) == 0) { @@ -200,10 +200,10 @@ return len; } -long open_tta_file (const char *filename, tta_info *info, unsigned long data_offset) { +int open_tta_file (const char *filename, tta_info *info, unsigned int data_offset) { FILE *infile; tta_hdr ttahdr; - unsigned long checksum; + unsigned int checksum; // clear the memory memset (info, 0, sizeof(tta_info)); @@ -241,7 +241,7 @@ ttahdr.CRC32 = ENDSWAP_INT32(ttahdr.CRC32); checksum = crc32((unsigned char *) &ttahdr, - sizeof(tta_hdr) - sizeof(long)); + sizeof(tta_hdr) - sizeof(int)); if (checksum != ttahdr.CRC32) { fclose (infile); info->STATE = FILE_ERROR; @@ -280,7 +280,7 @@ info->FORMAT = ttahdr.AudioFormat; info->SAMPLERATE = ttahdr.SampleRate; info->DATALENGTH = ttahdr.DataLength; - info->FRAMELEN = (long) (FRAME_TIME * ttahdr.SampleRate); + info->FRAMELEN = (int) (FRAME_TIME * ttahdr.SampleRate); info->LENGTH = ttahdr.DataLength / ttahdr.SampleRate; info->DATAPOS = data_offset; @@ -288,16 +288,16 @@ return 0; } -static void rice_init(adapt *rice, unsigned long k0, unsigned long k1) { +static void rice_init(adapt *rice, unsigned int k0, unsigned int k1) { rice->k0 = k0; rice->k1 = k1; rice->sum0 = shift_16[k0]; rice->sum1 = shift_16[k1]; } -static void decoder_init(decoder *tta, long nch, long byte_size) { - long shift = flt_set[byte_size - 1]; - long i; +static void decoder_init(decoder *tta, int nch, int byte_size) { + int shift = flt_set[byte_size - 1]; + int i; for (i = 0; i < nch; i++) { filter_init(&tta[i].fst, shift); @@ -306,9 +306,9 @@ } } -static void seek_table_init (unsigned long *seek_table, - unsigned long len, unsigned long data_offset) { - unsigned long *st, frame_len; +static void seek_table_init (unsigned int *seek_table, + unsigned int len, unsigned int data_offset) { + unsigned int *st, frame_len; for (st = seek_table; st < (seek_table + len); st++) { frame_len = ENDSWAP_INT32(*st); @@ -317,8 +317,8 @@ } } -long set_position (unsigned long pos) { - unsigned long seek_pos; +int set_position (unsigned int pos) { + unsigned int seek_pos; if (pos >= fframes) return 0; if (!st_state) { @@ -338,10 +338,10 @@ return 0; } -long player_init (tta_info *info) { - unsigned long checksum; - unsigned long data_offset; - unsigned long st_size; +int player_init (tta_info *info) { + unsigned int checksum; + unsigned int data_offset; + unsigned int st_size; ttainfo = info; @@ -352,9 +352,9 @@ lastlen = ttainfo->DATALENGTH % ttainfo->FRAMELEN; fframes = ttainfo->DATALENGTH / ttainfo->FRAMELEN + (lastlen ? 1:0); - st_size = (fframes + 1) * sizeof(long); + st_size = (fframes + 1) * sizeof(int); - seek_table = (unsigned long *) malloc(st_size); + seek_table = (unsigned int *) malloc(st_size); if (!seek_table) { ttainfo->STATE = MEMORY_ERROR; return -1; @@ -366,7 +366,7 @@ return -1; } - checksum = crc32((unsigned char *) seek_table, st_size - sizeof(long)); + checksum = crc32((unsigned char *) seek_table, st_size - sizeof(int)); st_state = (checksum == ENDSWAP_INT32(seek_table[fframes])); data_offset = sizeof(tta_hdr) + st_size; @@ -396,21 +396,21 @@ } } -long get_bitrate () { +int get_bitrate () { return bitrate; } -long get_samples (byte *buffer) { - unsigned long k, depth, unary, binary; +int get_samples (byte *buffer) { + unsigned int k, depth, unary, binary; byte *p = buffer; decoder *dec = tta; - long *prev = cache; - long value, res; + int *prev = cache; + int value, res; for (res = 0; p < buffer + pcm_buffer_size;) { fltst *fst = &dec->fst; adapt *rice = &dec->rice; - long *last = &dec->last; + int *last = &dec->last; if (data_cur == framelen) { if (data_pos == fframes) break; @@ -474,7 +474,7 @@ // check for errors if (abs(value) > maxvalue) { - unsigned long tail = + unsigned int tail = pcm_buffer_size / (ttainfo->BSIZE * ttainfo->NCH) - res; memset(buffer, 0, pcm_buffer_size); data_cur += tail; res += tail; @@ -486,7 +486,7 @@ } else { *prev = value; if (ttainfo->NCH > 1) { - long *r = prev - 1; + int *r = prev - 1; for (*prev += *r/2; r >= cache; r--) *r = *(r + 1) - *r; for (r = cache; r < prev; r++) diff -r 6e0751b8b2a1 -r c0f69d57483b src/tta/ttadec.h --- a/src/tta/ttadec.h Thu Jan 25 22:27:29 2007 -0800 +++ b/src/tta/ttadec.h Thu Jan 25 22:52:52 2007 -0800 @@ -49,10 +49,10 @@ #ifdef _WIN32 typedef unsigned __int64 uint64; #else - typedef unsigned long long uint64; + typedef unsigned long int uint64; #endif -const unsigned long bit_mask[] = { +const unsigned int bit_mask[] = { 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, @@ -64,7 +64,7 @@ 0xffffffff }; -const unsigned long bit_shift[] = { +const unsigned int bit_shift[] = { 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020, 0x00000040, 0x00000080, 0x00000100, 0x00000200, 0x00000400, 0x00000800, @@ -77,7 +77,7 @@ 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; -const unsigned long *shift_16 = bit_shift + 4; +const unsigned int *shift_16 = bit_shift + 4; typedef unsigned char byte; @@ -101,36 +101,36 @@ #define DEC(x) (((x)&1)?(++(x)>>1):(-(x)>>1)) typedef struct { - unsigned long TTAid; + unsigned int TTAid; unsigned short AudioFormat; unsigned short NumChannels; unsigned short BitsPerSample; - unsigned long SampleRate; - unsigned long DataLength; - unsigned long CRC32; + unsigned int SampleRate; + unsigned int DataLength; + unsigned int CRC32; } __ATTRIBUTE_PACKED__ tta_hdr; typedef struct { - unsigned long k0; - unsigned long k1; - unsigned long sum0; - unsigned long sum1; + unsigned int k0; + unsigned int k1; + unsigned int sum0; + unsigned int sum1; } adapt; typedef struct { - long shift; - long round; - long error; - long mutex; - long qm[MAX_ORDER+1]; - long dx[MAX_ORDER+1]; - long dl[MAX_ORDER+1]; + int shift; + int round; + int error; + int mutex; + int qm[MAX_ORDER+1]; + int dx[MAX_ORDER+1]; + int dl[MAX_ORDER+1]; } fltst; typedef struct { fltst fst; adapt rice; - long last; + int last; } decoder; #endif /* TTADEC_H_ */ diff -r 6e0751b8b2a1 -r c0f69d57483b src/tta/ttalib.h --- a/src/tta/ttalib.h Thu Jan 25 22:27:29 2007 -0800 +++ b/src/tta/ttalib.h Thu Jan 25 22:52:52 2007 -0800 @@ -60,12 +60,12 @@ unsigned short BPS; // bits per sample unsigned short BSIZE; // byte size unsigned short FORMAT; // audio format - unsigned long SAMPLERATE; // samplerate (sps) - unsigned long DATALENGTH; // data length in samples - unsigned long FRAMELEN; // frame length - unsigned long LENGTH; // playback time (sec) - unsigned long STATE; // return code - unsigned long DATAPOS; // size of ID3v2 header + unsigned int SAMPLERATE; // samplerate (sps) + unsigned int DATALENGTH; // data length in samples + unsigned int FRAMELEN; // frame length + unsigned int LENGTH; // playback time (sec) + unsigned int STATE; // return code + unsigned int DATAPOS; // size of ID3v2 header id3v1_data id3v1; id3v2_data id3v2; } tta_info; @@ -89,10 +89,10 @@ } #endif /* LIBTEST */ -long open_tta_file ( // FUNCTION: opens TTA file +int open_tta_file ( // FUNCTION: opens TTA file const char *filename, // file to open tta_info *info, // file info structure - unsigned long offset); // ID3v2 header size + unsigned int offset); // ID3v2 header size /* * RETURN VALUE * This function returns 0 if success. Otherwise, -1 is returned @@ -104,8 +104,8 @@ void close_tta_file ( // FUNCTION: closes currently playing file tta_info *info); // file info structure -long set_position ( // FUNCTION: sets playback position - unsigned long pos); // seek position = seek_time_ms / SEEK_STEP +int set_position ( // FUNCTION: sets playback position + unsigned int pos); // seek position = seek_time_ms / SEEK_STEP /* * RETURN VALUE * This function returns 0 if success. Otherwise, -1 is returned @@ -114,7 +114,7 @@ * */ -long player_init ( // FUNCTION: initializes TTA player +int player_init ( // FUNCTION: initializes TTA player tta_info *info); // file info structure /* * RETURN VALUE @@ -126,7 +126,7 @@ void player_stop (void); // FUNCTION: destroys memory pools -long get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples +int get_samples ( // FUNCTION: decode PCM_BUFFER_LENGTH samples unsigned char *buffer); // into the current PCM buffer position /* * RETURN VALUE @@ -136,7 +136,7 @@ * */ -long get_bitrate (void); // RETURN VALUE: TTA dynamic bitrate +int get_bitrate (void); // RETURN VALUE: TTA dynamic bitrate #endif /* TTALIB_H_ */