annotate libao2/ao_null.c @ 34613:b2c3288a3483

Remove no longer used message string.
author reimar
date Sun, 12 Feb 2012 18:52:38 +0000
parents ba55ceb04748
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28343
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
1 /*
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
2 * null audio output driver
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
3 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
4 * This file is part of MPlayer.
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
5 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
7 * it under the terms of the GNU General Public License as published by
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
9 * (at your option) any later version.
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
10 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
14 * GNU General Public License for more details.
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
15 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
16 * You should have received a copy of the GNU General Public License along
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
19 */
e45b08f2f5d3 Add standard license headers.
diego
parents: 25195
diff changeset
20
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
21 #include <stdio.h>
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
22 #include <stdlib.h>
4428
3e1378354c2e Compilation fixing
nick
parents: 4424
diff changeset
23 #include <sys/time.h>
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
24
14479
cae0dbeb44bb af_format.h needs config.h to be included first.
reimar
parents: 14245
diff changeset
25 #include "config.h"
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 13383
diff changeset
26 #include "libaf/af_format.h"
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
27 #include "audio_out.h"
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
28 #include "audio_out_internal.h"
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
29
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
30 static const ao_info_t info =
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
31 {
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
32 "Null audio output",
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
33 "null",
15755
b1b06adc5cd3 Fix email address
ranma
parents: 14479
diff changeset
34 "Tobias Diedrich <ranma+mplayer@tdiedrich.de>",
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
35 ""
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
36 };
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
37
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
38 LIBAO_EXTERN(null)
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
39
34265
ba55ceb04748 ao_null: mark global variables only used within the file as static
diego
parents: 29263
diff changeset
40 static struct timeval last_tv;
ba55ceb04748 ao_null: mark global variables only used within the file as static
diego
parents: 29263
diff changeset
41 static int buffer;
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
42
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 15755
diff changeset
43 static void drain(void){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
44
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
45 struct timeval now_tv;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
46 int temp, temp2;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
47
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
48 gettimeofday(&now_tv, 0);
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
49 temp = now_tv.tv_sec - last_tv.tv_sec;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
50 temp *= ao_data.bps;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
51
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
52 temp2 = now_tv.tv_usec - last_tv.tv_usec;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
53 temp2 /= 1000;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
54 temp2 *= ao_data.bps;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
55 temp2 /= 1000;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
56 temp += temp2;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
57
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
58 buffer-=temp;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
59 if (buffer<0) buffer=0;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
60
5946
9243f7464324 timer didn't update if mplayer is too fast (no video)
iive
parents: 4428
diff changeset
61 if(temp>0) last_tv = now_tv;//mplayer is fast
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
62 }
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
63
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
64 // to set/get/query special features/parameters
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 7472
diff changeset
65 static int control(int cmd,void *arg){
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
66 return -1;
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
67 }
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
68
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
69 // open & setup audio device
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
70 // return: 1=success 0=fail
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
71 static int init(int rate,int channels,int format,int flags){
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
72
25195
1aec672af2d2 Fix ao_null with float samples
uau
parents: 25194
diff changeset
73 int samplesize = af_fmt2bits(format) / 8;
25194
e816d546c4fe ao_null: Make duration of "buffered" audio constant
uau
parents: 25189
diff changeset
74 ao_data.outburst = 256 * channels * samplesize;
e816d546c4fe ao_null: Make duration of "buffered" audio constant
uau
parents: 25189
diff changeset
75 // A "buffer" for about 0.2 seconds of audio
e816d546c4fe ao_null: Make duration of "buffered" audio constant
uau
parents: 25189
diff changeset
76 ao_data.buffersize = (int)(rate * 0.2 / 256 + 1) * ao_data.outburst;
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
77 ao_data.channels=channels;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
78 ao_data.samplerate=rate;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
79 ao_data.format=format;
25194
e816d546c4fe ao_null: Make duration of "buffered" audio constant
uau
parents: 25189
diff changeset
80 ao_data.bps=channels*rate*samplesize;
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
81 buffer=0;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
82 gettimeofday(&last_tv, 0);
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
83
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
84 return 1;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
85 }
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
86
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
87 // close audio device
12145
99798c3cdb93 uninit immed flag
alex
parents: 9633
diff changeset
88 static void uninit(int immed){
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
89
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
90 }
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
91
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
92 // stop playing and empty buffers (for seeking/pause)
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 15755
diff changeset
93 static void reset(void){
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
94 buffer=0;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
95 }
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
96
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
97 // stop playing, keep buffers (for pause)
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 15755
diff changeset
98 static void audio_pause(void)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
99 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
100 // for now, just call reset();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
101 reset();
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
102 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
103
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
104 // resume playing, after audio_pause()
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 15755
diff changeset
105 static void audio_resume(void)
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
106 {
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
107 }
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1010
diff changeset
108
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
109 // return: how many bytes can be played without blocking
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 15755
diff changeset
110 static int get_space(void){
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
111
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
112 drain();
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
113 return ao_data.buffersize - buffer;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
114 }
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
115
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
116 // plays 'len' bytes of 'data'
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
117 // it should round it down to outburst*n
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
118 // return: number of bytes played
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
119 static int play(void* data,int len,int flags){
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
120
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
121 int maxbursts = (ao_data.buffersize - buffer) / ao_data.outburst;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
122 int playbursts = len / ao_data.outburst;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
123 int bursts = playbursts > maxbursts ? maxbursts : playbursts;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
124 buffer += bursts * ao_data.outburst;
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
125 return bursts * ao_data.outburst;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
126 }
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
127
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 1763
diff changeset
128 // return: delay in seconds between first and last sample in buffer
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 15755
diff changeset
129 static float get_delay(void){
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
130
4424
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
131 drain();
561de830fdf1 working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents: 3095
diff changeset
132 return (float) buffer / (float) ao_data.bps;
954
db20b90dd34d audio out drivers
arpi_esp
parents:
diff changeset
133 }