URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [tags/] [first/] [mp3/] [sw/] [mad-xess/] [play.c] - Rev 1765
Compare with Previous | Blame | View Log
#ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef EMBED #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include "audio.h" #include "mad.h" #include "fsyst.h" FILE *fo = 0; /* Root file location. */ unsigned char *root_file; int output_s(unsigned char const *ptr, unsigned int len); int main (int argc, char *argv[]) { union audio_control control; FILE *fi; struct stat fi_stat; char *sdata; if (argc != 2) { printf ("Usage: play file.pcm\n"); return 1; } fi = fopen (argv[1], "rb"); if (!fi) { fprintf (stderr, "Error loading file '%s'\n", argv[1]); return 2; } control.command = AUDIO_COMMAND_INIT; control.init.path = NULL; if (audio_oss(&control) == -1) { printf("audio %s\n", audio_error); return 3; } control.command = AUDIO_COMMAND_CONFIG; control.config.channels = 2; control.config.speed = 22050; if (audio_oss(&control) == -1) { printf("audio"); return 3; } stat (argv[1], &fi_stat); printf ("%s:%i\n", argv[1], (int)fi_stat.st_size); sdata = (char *)malloc (fi_stat.st_size); if (sdata) { int len = fread (sdata, 1, fi_stat.st_size, fi); printf ("(%i)", len); output_s(sdata, len); free (sdata); } else printf ("NULL"); control.command = AUDIO_COMMAND_FINISH; if (audio_oss(&control) == -1) { printf("audio %s\n", audio_error); return 3; } printf ("Done.\n"); fclose (fi); return 0; } # endif