OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [first/] [mp3/] [sw/] [mad-xess/] [play.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 266 lampret
#ifdef HAVE_CONFIG_H
2
#include "config.h"
3
#endif
4
 
5
#ifndef EMBED
6
#include <stdio.h>
7
#include <stdlib.h>
8
#include <string.h>
9
#include <sys/types.h>
10
#include <sys/stat.h>
11
#include <unistd.h>
12
#include "audio.h"
13
#include "mad.h"
14
#include "fsyst.h"
15
 
16
FILE *fo = 0;
17
 
18
/* Root file location.  */
19
unsigned char *root_file;
20
 
21
int output_s(unsigned char const *ptr, unsigned int len);
22
 
23
int main (int argc, char *argv[]) {
24
  union audio_control control;
25
  FILE *fi;
26
  struct stat fi_stat;
27
  char *sdata;
28
 
29
  if (argc != 2)
30
    {
31
      printf ("Usage: play file.pcm\n");
32
      return 1;
33
    }
34
  fi = fopen (argv[1], "rb");
35
  if (!fi)
36
    {
37
      fprintf (stderr, "Error loading file '%s'\n", argv[1]);
38
      return 2;
39
    }
40
 
41
  control.command   = AUDIO_COMMAND_INIT;
42
  control.init.path = NULL;
43
  if (audio_oss(&control) == -1) {
44
    printf("audio %s\n", audio_error);
45
    return 3;
46
  }
47
 
48
  control.command = AUDIO_COMMAND_CONFIG;
49
  control.config.channels = 2;
50
  control.config.speed    = 22050;
51
 
52
  if (audio_oss(&control) == -1) {
53
    printf("audio");
54
    return 3;
55
  }
56
 
57
  stat (argv[1], &fi_stat);
58
  printf ("%s:%i\n", argv[1], (int)fi_stat.st_size);
59
 
60
  sdata = (char *)malloc (fi_stat.st_size);
61
  if (sdata) {
62
    int len = fread (sdata, 1, fi_stat.st_size, fi);
63
    printf ("(%i)", len);
64
    output_s(sdata, len);
65
    free (sdata);
66
  } else printf ("NULL");
67
 
68
  control.command = AUDIO_COMMAND_FINISH;
69
  if (audio_oss(&control) == -1) {
70
    printf("audio %s\n", audio_error);
71
    return 3;
72
  }
73
  printf ("Done.\n");
74
  fclose (fi);
75
 
76
  return 0;
77
}
78
 
79
# endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.