Mercurial > mplayer.hg
annotate libao2/ao_null.c @ 11205:2d677eaa8aaa
Renamed to html-single.xsl.
author | diego |
---|---|
date | Tue, 21 Oct 2003 10:53:19 +0000 |
parents | 12b1790038b0 |
children | 99798c3cdb93 |
rev | line source |
---|---|
954 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
4428 | 3 #include <sys/time.h> |
954 | 4 |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
5 #include "afmt.h" |
954 | 6 #include "audio_out.h" |
7 #include "audio_out_internal.h" | |
8 | |
9 static ao_info_t info = | |
10 { | |
11 "Null audio output", | |
12 "null", | |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
13 "Tobias Diedrich", |
954 | 14 "" |
15 }; | |
16 | |
17 LIBAO_EXTERN(null) | |
18 | |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
19 struct timeval last_tv; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
20 int buffer; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
21 |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
5946
diff
changeset
|
22 static void drain(){ |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
23 |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
24 struct timeval now_tv; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
25 int temp, temp2; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
26 |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
27 gettimeofday(&now_tv, 0); |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
28 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
|
29 temp *= ao_data.bps; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
30 |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
31 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
|
32 temp2 /= 1000; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
33 temp2 *= ao_data.bps; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
34 temp2 /= 1000; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
35 temp += temp2; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
36 |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
37 buffer-=temp; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
38 if (buffer<0) buffer=0; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
39 |
5946
9243f7464324
timer didn't update if mplayer is too fast (no video)
iive
parents:
4428
diff
changeset
|
40 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
|
41 } |
954 | 42 |
43 // to set/get/query special features/parameters | |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
7472
diff
changeset
|
44 static int control(int cmd,void *arg){ |
954 | 45 return -1; |
46 } | |
47 | |
48 // open & setup audio device | |
49 // return: 1=success 0=fail | |
50 static int init(int rate,int channels,int format,int flags){ | |
51 | |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
52 ao_data.buffersize= 65536; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
53 ao_data.outburst=1024; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
54 ao_data.channels=channels; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
55 ao_data.samplerate=rate; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
56 ao_data.format=format; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
57 ao_data.bps=channels*rate; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
58 if (format != AFMT_U8 && format != AFMT_S8) |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
59 ao_data.bps*=2; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
60 buffer=0; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
61 gettimeofday(&last_tv, 0); |
954 | 62 |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
63 return 1; |
954 | 64 } |
65 | |
66 // close audio device | |
67 static void uninit(){ | |
68 | |
69 } | |
70 | |
71 // stop playing and empty buffers (for seeking/pause) | |
72 static void reset(){ | |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
73 buffer=0; |
954 | 74 } |
75 | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
76 // stop playing, keep buffers (for pause) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
77 static void audio_pause() |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
78 { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
79 // 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
|
80 reset(); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
81 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
82 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
83 // resume playing, after audio_pause() |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
84 static void audio_resume() |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
85 { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
86 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1010
diff
changeset
|
87 |
954 | 88 // return: how many bytes can be played without blocking |
89 static int get_space(){ | |
90 | |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
91 drain(); |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
92 return ao_data.buffersize - buffer; |
954 | 93 } |
94 | |
95 // plays 'len' bytes of 'data' | |
96 // it should round it down to outburst*n | |
97 // return: number of bytes played | |
98 static int play(void* data,int len,int flags){ | |
99 | |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 buffer += bursts * ao_data.outburst; |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
104 return bursts * ao_data.outburst; |
954 | 105 } |
106 | |
3095 | 107 // return: delay in seconds between first and last sample in buffer |
108 static float get_delay(){ | |
954 | 109 |
4424
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
110 drain(); |
561de830fdf1
working dummy audio driver, patch by Tobias Diedrich <td@informatik.uni-hannover.de>
arpi
parents:
3095
diff
changeset
|
111 return (float) buffer / (float) ao_data.bps; |
954 | 112 } |
113 | |
114 | |
115 | |
116 | |
117 | |
118 |