Some fixes and cleanups (still doesn't work here).
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1757 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -17,6 +17,13 @@ endif
|
|||||||
CFLAGS += -DUSE_SDLAUDIO=1 $(shell fltk-config --cxxflags)
|
CFLAGS += -DUSE_SDLAUDIO=1 $(shell fltk-config --cxxflags)
|
||||||
LDFLAGS += $(shell fltk-config --ldflags)
|
LDFLAGS += $(shell fltk-config --ldflags)
|
||||||
|
|
||||||
|
CFLAGS += -W -Wall \
|
||||||
|
-Wwrite-strings -Wimplicit -Wreturn-type -Wformat \
|
||||||
|
-Wswitch -Wcomment -Wchar-subscripts \
|
||||||
|
-Wparentheses -Wcast-align -Waggregate-return \
|
||||||
|
-Winline
|
||||||
|
# -Wcast-qual
|
||||||
|
|
||||||
# MacOS X apps need to have a resource fork applied, else the window
|
# MacOS X apps need to have a resource fork applied, else the window
|
||||||
# manager will refuse to manage them (which makes the app very
|
# manager will refuse to manage them (which makes the app very
|
||||||
# difficult to use) This rule should be ignored by all non-Mac
|
# difficult to use) This rule should be ignored by all non-Mac
|
||||||
|
|||||||
@@ -141,8 +141,6 @@ void fill_audio (void *u, Uint8 *stream, int len)
|
|||||||
void
|
void
|
||||||
fill_audio (void *u, Uint8 *stream, int len)
|
fill_audio (void *u, Uint8 *stream, int len)
|
||||||
{
|
{
|
||||||
Sint16 *b;
|
|
||||||
int l, i;
|
|
||||||
long amt_left;
|
long amt_left;
|
||||||
WAVESTRUCT *WaveData = (WAVESTRUCT *)u;
|
WAVESTRUCT *WaveData = (WAVESTRUCT *)u;
|
||||||
|
|
||||||
|
|||||||
+42
-34
@@ -31,9 +31,11 @@
|
|||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
# define MKDIR mkdir
|
# define MKDIR mkdir
|
||||||
|
# define PATH_MAX _MAX_PATH
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# define MKDIR(dir) mkdir((dir), 0777)
|
# define MKDIR(dir) mkdir((dir), 0777)
|
||||||
|
# include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@@ -194,8 +196,6 @@ void StartPlayback ()
|
|||||||
}
|
}
|
||||||
if (trackxtra->tracknum)
|
if (trackxtra->tracknum)
|
||||||
{
|
{
|
||||||
char *block;/* pointer to the block */
|
|
||||||
unsigned long blockSize;/* holds the size of the block */
|
|
||||||
char buf[80];
|
char buf[80];
|
||||||
AUDIOHDR audiohdr;
|
AUDIOHDR audiohdr;
|
||||||
trackxtra->paused = 0;
|
trackxtra->paused = 0;
|
||||||
@@ -264,7 +264,7 @@ void NextFrame ()
|
|||||||
StartPlayback();
|
StartPlayback();
|
||||||
else {
|
else {
|
||||||
curtime = get_clock();
|
curtime = get_clock();
|
||||||
printf ("Frame time: %d\n",curtime-trackxtra->time);
|
printf ("Frame time: %lu\n",curtime-trackxtra->time);
|
||||||
playing_clip = playing_clip->Next;
|
playing_clip = playing_clip->Next;
|
||||||
playing_clip->time = curtime-trackxtra->time;
|
playing_clip->time = curtime-trackxtra->time;
|
||||||
synch->TextScreen->value(playing_clip->str);
|
synch->TextScreen->value(playing_clip->str);
|
||||||
@@ -275,31 +275,33 @@ void NextFrame ()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wrapstr (char *dst, char *src)
|
void
|
||||||
|
wrapstr (char *dst, const char *src)
|
||||||
{
|
{
|
||||||
int i,j,last=0;
|
size_t i,j,last=0;
|
||||||
for (i = 0; i < strlen (src); i++) {
|
size_t src_len = strlen(src);
|
||||||
|
for (i = 0; i < src_len; i++) {
|
||||||
*dst++ = src[i];
|
*dst++ = src[i];
|
||||||
if (i == last) {
|
if (i == last) {
|
||||||
if (i != 0) {
|
if (i != 0)
|
||||||
*dst++ = '\n';
|
*dst++ = '\n';
|
||||||
}
|
|
||||||
last = strlen(src);
|
last = src_len;
|
||||||
for (j=i+1; j < strlen (src); j++) {
|
for (j=i+1; j < src_len; j++) {
|
||||||
if (j -i > WRAP_LEN)
|
if (j -i > WRAP_LEN)
|
||||||
break;
|
break;
|
||||||
if (src[j] == ' ') {
|
if (src[j] == ' ')
|
||||||
last = j;
|
last = j;
|
||||||
}
|
}
|
||||||
}
|
if (j == src_len)
|
||||||
if (j == strlen (src))
|
|
||||||
last = j;
|
last = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*dst = 0;
|
*dst = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PauseFrame ()
|
void
|
||||||
|
PauseFrame ()
|
||||||
{
|
{
|
||||||
unsigned long curtime;
|
unsigned long curtime;
|
||||||
if(trackxtra->paused)
|
if(trackxtra->paused)
|
||||||
@@ -311,10 +313,11 @@ void PauseFrame ()
|
|||||||
trackxtra->paused = ! trackxtra->paused;
|
trackxtra->paused = ! trackxtra->paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetTracks (int value)
|
void
|
||||||
|
GetTracks (int value)
|
||||||
{
|
{
|
||||||
const char *race;
|
const char *race;
|
||||||
char buf[80];
|
char speechFileName[PATH_MAX];
|
||||||
char str[MAX_LEN];
|
char str[MAX_LEN];
|
||||||
int i = 0, read_data = 0;
|
int i = 0, read_data = 0;
|
||||||
CLIPTXTDATA *curclip;
|
CLIPTXTDATA *curclip;
|
||||||
@@ -323,15 +326,12 @@ void GetTracks (int value)
|
|||||||
race = races[value - 1];
|
race = races[value - 1];
|
||||||
CleanUp();
|
CleanUp();
|
||||||
sprintf (path, "comm/%s", race);
|
sprintf (path, "comm/%s", race);
|
||||||
sprintf (buf, "%s/%s.txt",path, race);
|
sprintf (speechFileName, "%s/%s.txt", path, race);
|
||||||
fh = fopen (buf, "r");
|
fh = fopen (speechFileName, "r");
|
||||||
if (!fh) {
|
if (!fh) {
|
||||||
char buf1[100];
|
fl_alert ("Could not find %s!", speechFileName);
|
||||||
sprintf (buf1, "Could not find %s!",buf);
|
|
||||||
fl_alert (buf1);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char tmp[80];
|
|
||||||
MKDIR ("timestamp");
|
MKDIR ("timestamp");
|
||||||
sprintf(savepath,"timestamp/%s",race);
|
sprintf(savepath,"timestamp/%s",race);
|
||||||
MKDIR (savepath);
|
MKDIR (savepath);
|
||||||
@@ -344,7 +344,8 @@ void GetTracks (int value)
|
|||||||
char *tmp;
|
char *tmp;
|
||||||
read_data = 0;
|
read_data = 0;
|
||||||
tmp = strtok (str, "\t ");
|
tmp = strtok (str, "\t ");
|
||||||
if ((tmp = strtok (NULL, "\t ")) != NULL)
|
tmp = strtok (NULL, "\t ");
|
||||||
|
if (tmp != NULL)
|
||||||
{
|
{
|
||||||
#ifdef SKIP_SINGLE_LINES
|
#ifdef SKIP_SINGLE_LINES
|
||||||
if (i && racedata[i-1]->num_lines < 2) {
|
if (i && racedata[i-1]->num_lines < 2) {
|
||||||
@@ -353,7 +354,7 @@ void GetTracks (int value)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (i && ! racedata[i-1]->tracktime) {
|
if (i && ! racedata[i-1]->tracktime) {
|
||||||
char buf[80];
|
char buf[PATH_MAX];
|
||||||
sprintf(buf,"%s/%s", path, racedata[i-1]->filename);
|
sprintf(buf,"%s/%s", path, racedata[i-1]->filename);
|
||||||
racedata[i-1]->tracktime = get_ogg_runtime(buf);
|
racedata[i-1]->tracktime = get_ogg_runtime(buf);
|
||||||
synch->TrackSelector->add (racedata[i-1]->filename);
|
synch->TrackSelector->add (racedata[i-1]->filename);
|
||||||
@@ -364,12 +365,13 @@ void GetTracks (int value)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
racedata[i-1] = new FILEDATA;
|
racedata[i-1] = new FILEDATA;
|
||||||
strcpy (racedata[i-1]->filename, tmp);
|
strncpy (racedata[i-1]->filename, tmp, PATH_MAX);
|
||||||
|
racedata[i-1]->filename[PATH_MAX - 1] = '\0';
|
||||||
curclip = NULL;
|
curclip = NULL;
|
||||||
read_data = 1;
|
read_data = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (read_data && strlen (str))
|
else if (read_data && str[0] != '\0')
|
||||||
{
|
{
|
||||||
if (racedata[i-1]->clip == NULL) {
|
if (racedata[i-1]->clip == NULL) {
|
||||||
racedata[i-1]->clip = new CLIPTXTDATA;
|
racedata[i-1]->clip = new CLIPTXTDATA;
|
||||||
@@ -393,7 +395,7 @@ void GetTracks (int value)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (i && ! racedata[i-1]->tracktime) {
|
if (i && ! racedata[i-1]->tracktime) {
|
||||||
char buf[80];
|
char buf[PATH_MAX];
|
||||||
sprintf(buf,"%s/%s",path, racedata[i-1]->filename);
|
sprintf(buf,"%s/%s",path, racedata[i-1]->filename);
|
||||||
racedata[i-1]->tracktime = get_ogg_runtime(buf);
|
racedata[i-1]->tracktime = get_ogg_runtime(buf);
|
||||||
synch->TrackSelector->add (racedata[i-1]->filename);
|
synch->TrackSelector->add (racedata[i-1]->filename);
|
||||||
@@ -402,9 +404,8 @@ void GetTracks (int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
get_ogg_runtime (char *filename) {
|
get_ogg_runtime (const char *filename) {
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
vorbis_info *vi;
|
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
unsigned long runtime;
|
unsigned long runtime;
|
||||||
double rt;
|
double rt;
|
||||||
@@ -420,12 +421,12 @@ get_ogg_runtime (char *filename) {
|
|||||||
printf("%s : %lu (%f)\n", filename, runtime, rt);
|
printf("%s : %lu (%f)\n", filename, runtime, rt);
|
||||||
return(runtime);
|
return(runtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
read_ogg (char *filename, AUDIOHDR *audiohdr) {
|
read_ogg (const char *filename, AUDIOHDR *audiohdr) {
|
||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
vorbis_info *vi;
|
vorbis_info *vi;
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
char *wav;
|
|
||||||
int current_section;
|
int current_section;
|
||||||
|
|
||||||
fh = fopen(filename, "rb");
|
fh = fopen(filename, "rb");
|
||||||
@@ -444,20 +445,23 @@ read_ogg (char *filename, AUDIOHDR *audiohdr) {
|
|||||||
{
|
{
|
||||||
const unsigned int extra = 10000;
|
const unsigned int extra = 10000;
|
||||||
unsigned int numsamples = extra + (unsigned int)ov_pcm_total(&vf,0);
|
unsigned int numsamples = extra + (unsigned int)ov_pcm_total(&vf,0);
|
||||||
unsigned int numbytes = numsamples*vi->channels*2; // 16bit output wav
|
unsigned int numbytes = numsamples * vi->channels * 2;
|
||||||
|
// 16bit output wav
|
||||||
char *wavptr;
|
char *wavptr;
|
||||||
int eof = 0;
|
int eof = 0;
|
||||||
unsigned long readbytes = 0;
|
unsigned long readbytes = 0;
|
||||||
audiohdr->data = new char[numbytes];
|
audiohdr->data = new char[numbytes];
|
||||||
wavptr = audiohdr->data;
|
wavptr = audiohdr->data;
|
||||||
while(!eof){
|
while(!eof){
|
||||||
long ret=ov_read(&vf,wavptr,numbytes-readbytes,0,2,1,¤t_section);
|
long ret = ov_read(&vf, wavptr, numbytes - readbytes,
|
||||||
|
0, 2, 1, ¤t_section);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
eof = 1;
|
eof = 1;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
readbytes += ret;
|
readbytes += ret;
|
||||||
wavptr += ret;
|
wavptr += ret;
|
||||||
}
|
}
|
||||||
|
// XXX - What if ret < 0 - SvdB
|
||||||
}
|
}
|
||||||
audiohdr->data_len = readbytes;
|
audiohdr->data_len = readbytes;
|
||||||
}
|
}
|
||||||
@@ -466,7 +470,8 @@ read_ogg (char *filename, AUDIOHDR *audiohdr) {
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long checksum(char *filename)
|
unsigned long
|
||||||
|
checksum(const char *filename)
|
||||||
{
|
{
|
||||||
int fh;
|
int fh;
|
||||||
unsigned long chk = 0, buf = 0;
|
unsigned long chk = 0, buf = 0;
|
||||||
@@ -474,7 +479,10 @@ unsigned long checksum(char *filename)
|
|||||||
if (fh == -1)
|
if (fh == -1)
|
||||||
return 0;
|
return 0;
|
||||||
while (read(fh, &buf, sizeof(buf)) > 0)
|
while (read(fh, &buf, sizeof(buf)) > 0)
|
||||||
|
// XXX Not endianness-safe - SvdB
|
||||||
chk = ((chk << 1) | (chk >> 31)) ^ buf;
|
chk = ((chk << 1) | (chk >> 31)) ^ buf;
|
||||||
close(fh);
|
close(fh);
|
||||||
return (chk);
|
return (chk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -44,7 +44,7 @@ typedef struct CLIPTXTDATA {
|
|||||||
} CLIPTXTDATA;
|
} CLIPTXTDATA;
|
||||||
|
|
||||||
typedef struct FILEDATA {
|
typedef struct FILEDATA {
|
||||||
char filename[20];
|
char filename[PATH_MAX];
|
||||||
int num_lines;
|
int num_lines;
|
||||||
long chksum;
|
long chksum;
|
||||||
unsigned long tracktime;
|
unsigned long tracktime;
|
||||||
@@ -76,9 +76,9 @@ typedef struct XTRATRACKDATA {
|
|||||||
}
|
}
|
||||||
} XTRATRACKDATA;
|
} XTRATRACKDATA;
|
||||||
|
|
||||||
int read_ogg (char *filename, AUDIOHDR *audiohdr);
|
int read_ogg (const char *filename, AUDIOHDR *audiohdr);
|
||||||
unsigned long get_ogg_runtime (char *filename);
|
unsigned long get_ogg_runtime (const char *filename);
|
||||||
unsigned long checksum(char *filename);
|
unsigned long checksum(const char *filename);
|
||||||
|
|
||||||
|
|
||||||
unsigned long get_clock();
|
unsigned long get_clock();
|
||||||
|
|||||||
Reference in New Issue
Block a user