annotate libao2/ao_pcm.c @ 1109:a013b2124f05

-Wall like fixes
author al3x
date Tue, 12 Jun 2001 14:03:18 +0000
parents 9d764880d989
children b1cf1087ec33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1107
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
1 #include <stdio.h>
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
2 #include <stdlib.h>
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
3
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
4 #include "audio_out.h"
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
5 #include "audio_out_internal.h"
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
6
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
7 static ao_info_t info =
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
8 {
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
9 "PCM writer audio output",
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
10 "pcm",
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
11 "Atmosfear",
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
12 ""
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
13 };
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
14
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
15 LIBAO_EXTERN(pcm)
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
16
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
17 // there are some globals:
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
18 // ao_samplerate
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
19 // ao_channels
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
20 // ao_format
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
21 // ao_bps
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
22 // ao_outburst
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
23 // ao_buffersize
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
24
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
25 static FILE *fp = NULL;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
26
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
27 // to set/get/query special features/parameters
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
28 static int control(int cmd,int arg){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
29 return -1;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
30 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
31
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
32 // open & setup audio device
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
33 // return: 1=success 0=fail
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
34 static int init(int rate,int channels,int format,int flags){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
35
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
36 printf("PCM: File: audiodump.pcm Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format));
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
37 printf("PCM: Info - fastest dumping is achieved with -vo null -hardframedrop.\n");
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
38 fp = fopen("audiodump.pcm", "wb");
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
39
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
40 ao_outburst = 4096;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
41
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
42
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
43 if(fp) return 1;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
44 printf("PCM: Failed to open audiodump.pcm for writing!\n");
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
45 return 0;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
46 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
47
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
48 // close audio device
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
49 static void uninit(){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
50 fclose(fp);
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
51 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
52
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
53 // stop playing and empty buffers (for seeking/pause)
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
54 static void reset(){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
55
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
56 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
57
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
58 // stop playing, keep buffers (for pause)
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
59 static void audio_pause()
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
60 {
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
61 // for now, just call reset();
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
62 reset();
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
63 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
64
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
65 // resume playing, after audio_pause()
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
66 static void audio_resume()
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
67 {
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
68 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
69
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
70 // return: how many bytes can be played without blocking
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
71 static int get_space(){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
72
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
73 return ao_outburst;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
74 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
75
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
76 // plays 'len' bytes of 'data'
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
77 // it should round it down to outburst*n
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
78 // return: number of bytes played
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
79 static int play(void* data,int len,int flags){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
80
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
81 //printf("PCM: Writing chunk!\n");
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
82 fwrite(data,len,1,fp);
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
83
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
84 return len;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
85 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
86
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
87 // return: how many unplayed bytes are in the buffer
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
88 static int get_delay(){
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
89
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
90 return 0;
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
91 }
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
92
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
93
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
94
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
95
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
96
9d764880d989 Added raw PCM writer ao driver.
atmosfear
parents:
diff changeset
97