long oggz_run (OGGZ * oggz) { long n = OGGZ_ERR_DISABLED; if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) { while ((n = oggz_write (oggz, oggz->run_blocksize)) > 0); } else if (OGGZ_CONFIG_READ) { while ((n = oggz_read (oggz, oggz->run_blocksize)) > 0); } return n; }
int main (int argc, char ** argv) { int i; char * infilename = NULL, * outfilename = NULL; int format, interleave = 0; FS_DecEnc * ed; int blocksize = 1024; long n; if (argc < 3) { usage (argv[0]); exit (1); } /* Set the default output format based on what's available */ format = HAVE_VORBIS ? FISH_SOUND_VORBIS : FISH_SOUND_SPEEX; for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "--vorbis")) { format = FISH_SOUND_VORBIS; } else if (!strcmp (argv[i], "--speex")) { format = FISH_SOUND_SPEEX; } else if (!strcmp (argv[i], "--flac")) { format = FISH_SOUND_FLAC; } else if (!strcmp (argv[i], "--interleave")) { interleave = 1; } else if (!strcmp (argv[i], "--help") || !strcmp (argv[i], "-h")) { usage(argv[0]); } else if (argv[i] && argv[i][0] != '-') { if (infilename == NULL) { infilename = argv[i]; } else { outfilename = argv[i]; } } } if (format == FISH_SOUND_VORBIS) { if (HAVE_VORBIS) { printf ("Using Vorbis as the output codec\n"); } else { fprintf (stderr, "Error: Vorbis support disabled\n"); exit (1); } } if (format == FISH_SOUND_SPEEX) { if (HAVE_SPEEX) { printf ("Using Speex as the output codec\n"); } else { fprintf (stderr, "Error: Speex support disabled\n"); exit (1); } } if (format == FISH_SOUND_FLAC) { if (HAVE_FLAC) { printf ("Using Flac as the output codec\n"); } else { fprintf (stderr, "Error: Flac support disabled\n"); exit (1); } } ed = fs_encdec_new (infilename, outfilename, format, interleave, blocksize); while ((n = oggz_read (ed->oggz_in, 1024)) > 0) while (oggz_write (ed->oggz_out, 1024) > 0); fs_encdec_delete (ed); exit (0); }