Permalink
Browse files

Write all console messages to STDOUT for the simplefrontend

  • Loading branch information...
1 parent ec0d82f commit 30932754518f67815591821b434e4cb9f5f3c463 @njh committed Jan 12, 2011
Showing with 25 additions and 25 deletions.
  1. +16 −16 simplefrontend/audio_wave.c
  2. +9 −9 simplefrontend/simplefrontend.c
@@ -46,7 +46,7 @@ static enum byte_order DetermineByteOrder(void)
probe.longval = 0x41424344L; /* ABCD in ASCII */
strncpy(s, probe.charval, sizeof(long));
s[sizeof(long)] = '\0';
- /* fprintf( stderr, "byte order is %s\n", s ); */
+ /* printf("byte order is %s\n", s ); */
if (strcmp(s, "ABCD") == 0)
return order_bigEndian;
@@ -122,7 +122,7 @@ wave_info_t *wave_init(char *inPath)
FILE *file;
if ((file = fopen(inPath, "rb")) == NULL) {
- fprintf(stdout, "WAV: cannot open input file: %s\n", inPath);
+ printf("WAV: cannot open input file: %s\n", inPath);
return (NULL);
}
@@ -147,11 +147,11 @@ wave_info_t *wave_init(char *inPath)
if (wave_header_buffer[8] == 'W' && wave_header_buffer[9] == 'A'
&& wave_header_buffer[10] == 'V' && wave_header_buffer[11] == 'E') {
- fprintf(stderr, "Parsing Wave File Header\n");
+ printf("Parsing Wave File Header\n");
if (NativeByteOrder == order_unknown) {
NativeByteOrder = DetermineByteOrder();
if (NativeByteOrder == order_unknown) {
- fprintf(stderr, "byte order not determined\n");
+ printf("byte order not determined\n");
fclose(file);
return (NULL);
}
@@ -174,53 +174,53 @@ wave_info_t *wave_init(char *inPath)
case 24000:
case 22050:
case 16000:
- fprintf(stderr, ">>> %ld Hz sampling freq selected\n", samplerate);
+ printf(">>> %ld Hz sampling freq selected\n", samplerate);
break;
default:
/* Unknown Unsupported Frequency */
- fprintf(stderr, ">>> Unknown samp freq %ld Hz in Wave Header\n", samplerate);
- fprintf(stderr, ">>> Default 44.1 kHz samp freq selected\n");
+ printf(">>> Unknown samp freq %ld Hz in Wave Header\n", samplerate);
+ printf(">>> Default 44.1 kHz samp freq selected\n");
samplerate = 44100;
break;
}
if ((long) wave_header_buffer[22] == 1) {
- fprintf(stderr, ">>> Input Wave File is Mono\n");
+ printf(">>> Input Wave File is Mono\n");
wave_header_stereo = 0;
}
if ((long) wave_header_buffer[22] == 2) {
- fprintf(stderr, ">>> Input Wave File is Stereo\n");
+ printf(">>> Input Wave File is Stereo\n");
wave_header_stereo = 1;
}
if ((long) wave_header_buffer[32] == 1) {
- fprintf(stderr, ">>> Input Wave File is 8 Bit\n");
+ printf(">>> Input Wave File is 8 Bit\n");
wave_header_16bit = 0;
- fprintf(stderr, "Input File must be 16 Bit! Please Re-sample");
+ printf("Input File must be 16 Bit! Please Re-sample");
fclose(file);
return (NULL);
}
if ((long) wave_header_buffer[32] == 2) {
if (wave_header_stereo == 1) {
- fprintf(stderr, ">>> Input Wave File is 8 Bit\n");
+ printf(">>> Input Wave File is 8 Bit\n");
wave_header_16bit = 0;
- fprintf(stderr, "Input File must be 16 Bit! Please Re-sample");
+ printf("Input File must be 16 Bit! Please Re-sample");
fclose(file);
return (NULL);
} else {
- /* fprintf(stderr, ">>> Input Wave File is 16 Bit\n" ); */
+ /* printf(">>> Input Wave File is 16 Bit\n" ); */
wave_header_16bit = 1;
}
}
if ((long) wave_header_buffer[32] == 4) {
- /* fprintf(stderr, ">>> Input Wave File is 16 Bit\n" ); */
+ /* printf(">>> Input Wave File is 16 Bit\n" ); */
wave_header_16bit = 1;
}
/* should probably use the wave header to determine size here FIXME MFC Feb 2003 */
if (fseek(file, 44, SEEK_SET) != 0) {
/* there's a way of calculating the size of the wave header. i'll just jump 44 to start
with */
- fprintf(stderr, "Could not seek to PCM sound data in \"%s\".\n", inPath);
+ printf("Could not seek to PCM sound data in \"%s\".\n", inPath);
fclose(file);
return (NULL);
}
@@ -37,7 +37,7 @@
static void usage(void)
{
- fprintf(stdout, "stwolame <input wavefile> <output mp2 file>\n");
+ printf("stwolame <input wavefile> <output mp2 file>\n");
exit(1);
}
@@ -61,13 +61,13 @@ int main(int argc, char **argv)
/* Allocate some space for the PCM audio data */
if ((pcmaudio = (short *) calloc(AUDIOBUFSIZE, sizeof(short))) == NULL) {
- fprintf(stdout, "pcmaudio alloc failed\n");
+ printf("pcmaudio alloc failed\n");
exit(99);
}
/* Allocate some space for the encoded MP2 audio data */
if ((mp2buffer = (unsigned char *) calloc(MP2BUFSIZE, sizeof(unsigned char))) == NULL) {
- fprintf(stdout, "mp2buffer alloc failed\n");
+ printf("mp2buffer alloc failed\n");
exit(99);
}
@@ -76,12 +76,12 @@ int main(int argc, char **argv)
/* grab a set of default encode options */
encodeOptions = twolame_init();
- fprintf(stdout, "Using libtwolame version %s.\n", get_twolame_version());
+ printf("Using libtwolame version %s.\n", get_twolame_version());
/* Open the wave file */
if ((wave_info = wave_init(inputfilename)) == NULL) {
- fprintf(stdout, "Not a recognised WAV file.\n");
+ printf("Not a recognised WAV file.\n");
exit(99);
}
// Use sound file to over-ride preferences for
@@ -104,13 +104,13 @@ int main(int argc, char **argv)
/* initialise twolame with this set of options */
if (twolame_init_params(encodeOptions) != 0) {
- fprintf(stderr, "Error: configuring libtwolame encoder failed.\n");
+ printf("Error: configuring libtwolame encoder failed.\n");
exit(99);
}
/* Open the output file for the encoded MP2 data */
if ((outfile = fopen(outputfilename, "wb")) == 0) {
- fprintf(stdout, "error opening output file %s\n", outputfilename);
+ printf("error opening output file %s\n", outputfilename);
exit(99);
}
// Read num_samples of audio data *per channel* from the input file
@@ -126,7 +126,7 @@ int main(int argc, char **argv)
// Display the number of MPEG audio frames we have encoded
frames += (num_samples / TWOLAME_SAMPLES_PER_FRAME);
- fprintf(stdout, "[%04i]\r", frames);
+ printf("[%04i]\r", frames);
fflush(stdout);
}
@@ -140,7 +140,7 @@ int main(int argc, char **argv)
twolame_close(&encodeOptions);
free(pcmaudio);
- fprintf(stdout, "\nFinished nicely.\n");
+ printf("\nFinished nicely.\n");
return (0);

0 comments on commit 3093275

Please sign in to comment.