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