Mercurial > mplayer.hg
annotate libao2/ao_sun.c @ 36920:40ad45360c8a
Replace old item 'potmeter' by new item 'pimage'.
Recent versions of the X11/GTK GUI didn't allow to control a potmeter,
because that didn't seem to make any sense.
In order to get rid of the confusing potmeter that doesn't distinguish
from a hpotmeter and in order to allow the more useful behaviour recent
versions of the X11/GTK GUI have been utilized (and because we're still
supporting item 'potmeter' for reasons of compatibility with old skins),
introduce new item 'pimage' that reuses most of the current potmeter
code.
Additionally, remove remaining code and documentation of 'potmeter'.
author | ib |
---|---|
date | Mon, 17 Mar 2014 12:29:46 +0000 |
parents | 2468dc935bed |
children |
rev | line source |
---|---|
28343 | 1 /* |
2 * SUN audio output driver | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
20 | |
1041 | 21 #include <stdio.h> |
22 #include <stdlib.h> | |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
23 #include <string.h> |
1041 | 24 |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
25 #include <unistd.h> |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
26 #include <fcntl.h> |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
27 #include <errno.h> |
1041 | 28 #include <sys/ioctl.h> |
29 #include <sys/time.h> | |
30 #include <sys/types.h> | |
31 #include <sys/stat.h> | |
32 #include <sys/audioio.h> | |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
33 #ifdef AUDIO_SWFEATURE_MIXER /* solaris8 or newer? */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
34 # define HAVE_SYS_MIXER_H 1 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
35 #endif |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
36 #if HAVE_SYS_MIXER_H |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
37 # include <sys/mixer.h> |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
38 #endif |
1041 | 39 #ifdef __svr4__ |
40 #include <stropts.h> | |
41 #endif | |
42 | |
14123 | 43 #include "config.h" |
44 #include "mixer.h" | |
1041 | 45 |
46 #include "audio_out.h" | |
47 #include "audio_out_internal.h" | |
14247 | 48 #include "libaf/af_format.h" |
14123 | 49 #include "mp_msg.h" |
50 #include "help_mp.h" | |
1041 | 51 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
52 static const ao_info_t info = |
1041 | 53 { |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
54 "Sun audio output", |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
55 "sun", |
13549 | 56 "Juergen Keil", |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
57 "" |
1041 | 58 }; |
59 | |
60 LIBAO_EXTERN(sun) | |
61 | |
62 | |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
63 /* These defines are missing on NetBSD */ |
1041 | 64 #ifndef AUDIO_PRECISION_8 |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
65 #define AUDIO_PRECISION_8 8 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
66 #define AUDIO_PRECISION_16 16 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
67 #endif |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
68 #ifndef AUDIO_CHANNELS_MONO |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
69 #define AUDIO_CHANNELS_MONO 1 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
70 #define AUDIO_CHANNELS_STEREO 2 |
1041 | 71 #endif |
72 | |
73 | |
5893
6a6107da2d82
Default to the mixer device matching the audio device used for audio output.
jkeil
parents:
5872
diff
changeset
|
74 static char *sun_mixer_device = NULL; |
3492
24b0fad7fccc
Use $AUDIODEV environment variable as the default audio device on solaris, if
jkeil
parents:
3137
diff
changeset
|
75 static char *audio_dev = NULL; |
1041 | 76 static int queued_bursts = 0; |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
77 static int queued_samples = 0; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
78 static int bytes_per_sample = 0; |
3095 | 79 static int byte_per_sec = 0; |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
80 static int audio_fd = -1; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
81 static enum { |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
82 RTSC_UNKNOWN = 0, |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
83 RTSC_ENABLED, |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
84 RTSC_DISABLED |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
85 } enable_sample_timing; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
86 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
87 |
23334 | 88 static void flush_audio(int fd) { |
89 #ifdef AUDIO_FLUSH | |
90 ioctl(fd, AUDIO_FLUSH, 0); | |
91 #elif defined(__svr4__) | |
92 ioctl(fd, I_FLUSH, FLUSHW); | |
93 #endif | |
94 } | |
1041 | 95 |
1058 | 96 // convert an OSS audio format specification into a sun audio encoding |
14247 | 97 static int af2sunfmt(int format) |
1058 | 98 { |
14247 | 99 switch (format){ |
100 case AF_FORMAT_MU_LAW: | |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
101 return AUDIO_ENCODING_ULAW; |
14247 | 102 case AF_FORMAT_A_LAW: |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
103 return AUDIO_ENCODING_ALAW; |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
104 case AF_FORMAT_S16_NE: |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
105 return AUDIO_ENCODING_LINEAR; |
1346
d6e6132bff35
AUDIO_ENCODING_LINEAR8 format is not available on sunos 5.5. Format is
jkeil
parents:
1320
diff
changeset
|
106 #ifdef AUDIO_ENCODING_LINEAR8 // Missing on SunOS 5.5.1... |
14247 | 107 case AF_FORMAT_U8: |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
108 return AUDIO_ENCODING_LINEAR8; |
1346
d6e6132bff35
AUDIO_ENCODING_LINEAR8 format is not available on sunos 5.5. Format is
jkeil
parents:
1320
diff
changeset
|
109 #endif |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
110 case AF_FORMAT_S8: |
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
111 return AUDIO_ENCODING_LINEAR; |
1058 | 112 #ifdef AUDIO_ENCODING_DVI // Missing on NetBSD... |
14247 | 113 case AF_FORMAT_IMA_ADPCM: |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
114 return AUDIO_ENCODING_DVI; |
1058 | 115 #endif |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
116 default: |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
117 return AUDIO_ENCODING_NONE; |
1058 | 118 } |
119 } | |
120 | |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
121 // try to figure out, if the soundcard driver provides usable (precise) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
122 // sample counter information |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
123 static int realtime_samplecounter_available(char *dev) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
124 { |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
125 int fd = -1; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
126 audio_info_t info; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
127 int rtsc_ok = RTSC_DISABLED; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
128 int len; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
129 void *silence = NULL; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
130 struct timeval start, end; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
131 struct timespec delay; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
132 int usec_delay; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
133 unsigned last_samplecnt; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
134 unsigned increment; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
135 unsigned min_increment; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
136 |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
137 len = 44100 * 4 / 4; /* amount of data for 0.25sec of 44.1khz, stereo, |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
138 * 16bit. 44kbyte can be sent to all supported |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
139 * sun audio devices without blocking in the |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
140 * "write" below. |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
141 */ |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
142 silence = calloc(1, len); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
143 if (silence == NULL) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
144 goto error; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
145 |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
146 if ((fd = open(dev, O_WRONLY)) < 0) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
147 goto error; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
148 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
149 AUDIO_INITINFO(&info); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
150 info.play.sample_rate = 44100; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
151 info.play.channels = AUDIO_CHANNELS_STEREO; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
152 info.play.precision = AUDIO_PRECISION_16; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
153 info.play.encoding = AUDIO_ENCODING_LINEAR; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
154 info.play.samples = 0; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
155 if (ioctl(fd, AUDIO_SETINFO, &info)) { |
33828
d2a42640b9d7
ao_sun: print fatal error messages not only in verbose mode
diego
parents:
32537
diff
changeset
|
156 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscSetinfoFailed); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
157 goto error; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
158 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
159 |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
160 if (write(fd, silence, len) != len) { |
33828
d2a42640b9d7
ao_sun: print fatal error messages not only in verbose mode
diego
parents:
32537
diff
changeset
|
161 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_RtscWriteFailed); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
162 goto error; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
163 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
164 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
165 if (ioctl(fd, AUDIO_GETINFO, &info)) { |
33828
d2a42640b9d7
ao_sun: print fatal error messages not only in verbose mode
diego
parents:
32537
diff
changeset
|
166 perror("rtsc: GETINFO1"); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
167 goto error; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
168 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
169 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
170 last_samplecnt = info.play.samples; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
171 min_increment = ~0; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
172 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
173 gettimeofday(&start, NULL); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
174 for (;;) { |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
175 delay.tv_sec = 0; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
176 delay.tv_nsec = 10000000; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
177 nanosleep(&delay, NULL); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
178 gettimeofday(&end, NULL); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
179 usec_delay = (end.tv_sec - start.tv_sec) * 1000000 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
180 + end.tv_usec - start.tv_usec; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
181 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
182 // stop monitoring sample counter after 0.2 seconds |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
183 if (usec_delay > 200000) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
184 break; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
185 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
186 if (ioctl(fd, AUDIO_GETINFO, &info)) { |
33828
d2a42640b9d7
ao_sun: print fatal error messages not only in verbose mode
diego
parents:
32537
diff
changeset
|
187 perror("rtsc: GETINFO2 failed"); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
188 goto error; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
189 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
190 if (info.play.samples < last_samplecnt) { |
33829
2468dc935bed
Do not employ verbosity level MSGL_V for fatal errors.
diego
parents:
33828
diff
changeset
|
191 mp_msg(MSGT_AO, MSGL_ERR, "rtsc: %d > %d?\n", last_samplecnt, info.play.samples); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
192 goto error; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
193 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
194 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
195 if ((increment = info.play.samples - last_samplecnt) > 0) { |
17932 | 196 if ( mp_msg_test(MSGT_AO,MSGL_V) ) |
17933 | 197 mp_msg(MSGT_AO,MSGL_V,"ao_sun: sample counter increment: %d\n", increment); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
198 if (increment < min_increment) { |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
199 min_increment = increment; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
200 if (min_increment < 2000) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
201 break; // looks good |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
202 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
203 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
204 last_samplecnt = info.play.samples; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
205 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
206 |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
207 /* |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
208 * For 44.1kkz, stereo, 16-bit format we would send sound data in 16kbytes |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
209 * chunks (== 4096 samples) to the audio device. If we see a minimum |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
210 * sample counter increment from the soundcard driver of less than |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
211 * 2000 samples, we assume that the driver provides a useable realtime |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
212 * sample counter in the AUDIO_INFO play.samples field. Timing based |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
213 * on sample counts should be much more accurate than counting whole |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
214 * 16kbyte chunks. |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
215 */ |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
216 if (min_increment < 2000) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
217 rtsc_ok = RTSC_ENABLED; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
218 |
17932 | 219 if ( mp_msg_test(MSGT_AO,MSGL_V) ) |
17933 | 220 mp_msg(MSGT_AO,MSGL_V,"ao_sun: minimum sample counter increment per 10msec interval: %d\n" |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
221 "\t%susing sample counter based timing code\n", |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
222 min_increment, rtsc_ok == RTSC_ENABLED ? "" : "not "); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
223 |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
224 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
225 error: |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32424
diff
changeset
|
226 free(silence); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
227 if (fd >= 0) { |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
228 // remove the 0 bytes from the above measurement from the |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
229 // audio driver's STREAMS queue |
23334 | 230 flush_audio(fd); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
231 close(fd); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
232 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
233 |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
234 return rtsc_ok; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
235 } |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
236 |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
237 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
238 // match the requested sample rate |sample_rate| against the |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
239 // sample rates supported by the audio device |dev|. Return |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
240 // a supported sample rate, if that sample rate is close to |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
241 // (< 1% difference) the requested rate; return 0 otherwise. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
242 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
243 #define MAX_RATE_ERR 1 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
244 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
245 static unsigned |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
246 find_close_samplerate_match(int dev, unsigned sample_rate) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
247 { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
248 #if HAVE_SYS_MIXER_H |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
249 am_sample_rates_t *sr; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
250 unsigned i, num, err, best_err, best_rate; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
251 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
252 for (num = 16; num < 1024; num *= 2) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
253 sr = malloc(AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num)); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
254 if (!sr) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
255 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
256 sr->type = AUDIO_PLAY; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
257 sr->flags = 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
258 sr->num_samp_rates = num; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
259 if (ioctl(dev, AUDIO_MIXER_GET_SAMPLE_RATES, sr)) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
260 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
261 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
262 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
263 if (sr->num_samp_rates <= num) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
264 break; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
265 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
266 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
267 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
268 if (sr->flags & MIXER_SR_LIMITS) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
269 /* |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
270 * HW can playback any rate between |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
271 * sr->samp_rates[0] .. sr->samp_rates[1] |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
272 */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
273 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
274 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
275 } else { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
276 /* HW supports fixed sample rates only */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
277 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
278 best_err = 65535; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
279 best_rate = 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
280 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
281 for (i = 0; i < sr->num_samp_rates; i++) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
282 err = abs(sr->samp_rates[i] - sample_rate); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
283 if (err == 0) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
284 /* |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
285 * exact supported sample rate match, no need to |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
286 * retry something else |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
287 */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
288 best_rate = 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
289 break; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
290 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
291 if (err < best_err) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
292 best_err = err; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
293 best_rate = sr->samp_rates[i]; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
294 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
295 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
296 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
297 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
298 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
299 if (best_rate > 0 && (100/MAX_RATE_ERR)*best_err < sample_rate) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
300 /* found a supported sample rate with <1% error? */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
301 return best_rate; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
302 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
303 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
304 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
305 #else /* old audioio driver, cannot return list of supported rates */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
306 /* XXX: hardcoded sample rates */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
307 unsigned i, err; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
308 unsigned audiocs_rates[] = { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
309 5510, 6620, 8000, 9600, 11025, 16000, 18900, 22050, |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
310 27420, 32000, 33075, 37800, 44100, 48000, 0 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
311 }; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
312 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
313 for (i = 0; audiocs_rates[i]; i++) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
314 err = abs(audiocs_rates[i] - sample_rate); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
315 if (err == 0) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
316 /* |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
317 * exact supported sample rate match, no need to |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
318 * retry something elise |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
319 */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
320 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
321 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
322 if ((100/MAX_RATE_ERR)*err < audiocs_rates[i]) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
323 /* <1% error? */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
324 return audiocs_rates[i]; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
325 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
326 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
327 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
328 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
329 #endif |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
330 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
331 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
332 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
333 // return the highest sample rate supported by audio device |dev|. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
334 static unsigned |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
335 find_highest_samplerate(int dev) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
336 { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
337 #if HAVE_SYS_MIXER_H |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
338 am_sample_rates_t *sr; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
339 unsigned i, num, max_rate; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
340 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
341 for (num = 16; num < 1024; num *= 2) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
342 sr = malloc(AUDIO_MIXER_SAMP_RATES_STRUCT_SIZE(num)); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
343 if (!sr) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
344 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
345 sr->type = AUDIO_PLAY; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
346 sr->flags = 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
347 sr->num_samp_rates = num; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
348 if (ioctl(dev, AUDIO_MIXER_GET_SAMPLE_RATES, sr)) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
349 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
350 return 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
351 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
352 if (sr->num_samp_rates <= num) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
353 break; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
354 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
355 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
356 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
357 if (sr->flags & MIXER_SR_LIMITS) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
358 /* |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
359 * HW can playback any rate between |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
360 * sr->samp_rates[0] .. sr->samp_rates[1] |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
361 */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
362 max_rate = sr->samp_rates[1]; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
363 } else { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
364 /* HW supports fixed sample rates only */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
365 max_rate = 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
366 for (i = 0; i < sr->num_samp_rates; i++) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
367 if (sr->samp_rates[i] > max_rate) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
368 max_rate = sr->samp_rates[i]; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
369 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
370 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
371 free(sr); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
372 return max_rate; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
373 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
374 #else /* old audioio driver, cannot return list of supported rates */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
375 return 44100; /* should be supported even on old ISA SB cards */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
376 #endif |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
377 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
378 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
379 |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17933
diff
changeset
|
380 static void setup_device_paths(void) |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
381 { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
382 if (audio_dev == NULL) { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
383 if ((audio_dev = getenv("AUDIODEV")) == NULL) |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
384 audio_dev = "/dev/audio"; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
385 } |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
386 |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
387 if (sun_mixer_device == NULL) { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
388 if ((sun_mixer_device = mixer_device) == NULL || !sun_mixer_device[0]) { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
389 sun_mixer_device = malloc(strlen(audio_dev) + 4); |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
390 strcpy(sun_mixer_device, audio_dev); |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
391 strcat(sun_mixer_device, "ctl"); |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
392 } |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
393 } |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
394 |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
395 if (ao_subdevice) audio_dev = ao_subdevice; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
396 } |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
397 |
1041 | 398 // to set/get/query special features/parameters |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
8027
diff
changeset
|
399 static int control(int cmd,void *arg){ |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
400 switch(cmd){ |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
401 case AOCONTROL_SET_DEVICE: |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
402 audio_dev=(char*)arg; |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
403 return CONTROL_OK; |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
404 case AOCONTROL_QUERY_FORMAT: |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
405 return CONTROL_TRUE; |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
406 case AOCONTROL_GET_VOLUME: |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
407 { |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
408 int fd; |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
409 |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
410 if ( !sun_mixer_device ) /* control function is used before init? */ |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
411 setup_device_paths(); |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
412 |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
413 fd=open( sun_mixer_device,O_RDONLY ); |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
414 if ( fd != -1 ) |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
415 { |
4907 | 416 ao_control_vol_t *vol = (ao_control_vol_t *)arg; |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
417 float volume; |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
418 struct audio_info info; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
419 ioctl( fd,AUDIO_GETINFO,&info); |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
420 volume = info.play.gain * 100. / AUDIO_MAX_GAIN; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
421 if ( info.play.balance == AUDIO_MID_BALANCE ) { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
422 vol->right = vol->left = volume; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
423 } else if ( info.play.balance < AUDIO_MID_BALANCE ) { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
424 vol->left = volume; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
425 vol->right = volume * info.play.balance / AUDIO_MID_BALANCE; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
426 } else { |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
427 vol->left = volume * (AUDIO_RIGHT_BALANCE-info.play.balance) |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
428 / AUDIO_MID_BALANCE; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
429 vol->right = volume; |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
430 } |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
431 close( fd ); |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
432 return CONTROL_OK; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
433 } |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
434 return CONTROL_ERROR; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
435 } |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
436 case AOCONTROL_SET_VOLUME: |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
437 { |
4907 | 438 ao_control_vol_t *vol = (ao_control_vol_t *)arg; |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
439 int fd; |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
440 |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
441 if ( !sun_mixer_device ) /* control function is used before init? */ |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
442 setup_device_paths(); |
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
443 |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
444 fd=open( sun_mixer_device,O_RDONLY ); |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
445 if ( fd != -1 ) |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
446 { |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
447 struct audio_info info; |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
448 float volume; |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
449 AUDIO_INITINFO(&info); |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
450 volume = vol->right > vol->left ? vol->right : vol->left; |
7422
69d6da12bc30
*bsd doesn't have info.output_muted - patch by Bj¸«Órn Sandell <biorn@dce.chalmers.se>
arpi
parents:
7379
diff
changeset
|
451 if ( volume != 0 ) { |
7379
7b3c73a0c2dd
Reconstruct the muting state for the playback from a l/r volume of 0.0.
jkeil
parents:
7378
diff
changeset
|
452 info.play.gain = volume * AUDIO_MAX_GAIN / 100; |
7b3c73a0c2dd
Reconstruct the muting state for the playback from a l/r volume of 0.0.
jkeil
parents:
7378
diff
changeset
|
453 if ( vol->right == vol->left ) |
7b3c73a0c2dd
Reconstruct the muting state for the playback from a l/r volume of 0.0.
jkeil
parents:
7378
diff
changeset
|
454 info.play.balance = AUDIO_MID_BALANCE; |
7b3c73a0c2dd
Reconstruct the muting state for the playback from a l/r volume of 0.0.
jkeil
parents:
7378
diff
changeset
|
455 else |
7b3c73a0c2dd
Reconstruct the muting state for the playback from a l/r volume of 0.0.
jkeil
parents:
7378
diff
changeset
|
456 info.play.balance = (vol->right - vol->left + volume) * AUDIO_RIGHT_BALANCE / (2*volume); |
7b3c73a0c2dd
Reconstruct the muting state for the playback from a l/r volume of 0.0.
jkeil
parents:
7378
diff
changeset
|
457 } |
7422
69d6da12bc30
*bsd doesn't have info.output_muted - patch by Bj¸«Órn Sandell <biorn@dce.chalmers.se>
arpi
parents:
7379
diff
changeset
|
458 #if !defined (__OpenBSD__) && !defined (__NetBSD__) |
69d6da12bc30
*bsd doesn't have info.output_muted - patch by Bj¸«Órn Sandell <biorn@dce.chalmers.se>
arpi
parents:
7379
diff
changeset
|
459 info.output_muted = (volume == 0); |
69d6da12bc30
*bsd doesn't have info.output_muted - patch by Bj¸«Órn Sandell <biorn@dce.chalmers.se>
arpi
parents:
7379
diff
changeset
|
460 #endif |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
461 ioctl( fd,AUDIO_SETINFO,&info ); |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
462 close( fd ); |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
463 return CONTROL_OK; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
464 } |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
3492
diff
changeset
|
465 return CONTROL_ERROR; |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
466 } |
4907 | 467 } |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
468 return CONTROL_UNKNOWN; |
1041 | 469 } |
470 | |
471 // open & setup audio device | |
472 // return: 1=success 0=fail | |
473 static int init(int rate,int channels,int format,int flags){ | |
474 | |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
475 audio_info_t info; |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
476 int pass; |
1807
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
477 int ok; |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
478 int convert_u8_s8; |
1041 | 479 |
7378
9fb2113b4869
- gui version of mplayer is using the audio 'control' function before(!) the
jkeil
parents:
6630
diff
changeset
|
480 setup_device_paths(); |
1209 | 481 |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
482 if (enable_sample_timing == RTSC_UNKNOWN |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
483 && !getenv("AO_SUN_DISABLE_SAMPLE_TIMING")) { |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
484 enable_sample_timing = realtime_samplecounter_available(audio_dev); |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
485 } |
1041 | 486 |
17933 | 487 mp_msg(MSGT_AO,MSGL_STATUS,"ao2: %d Hz %d chans %s [0x%X]\n", |
14264 | 488 rate,channels,af_fmt2str_short(format),format); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
489 |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
490 audio_fd=open(audio_dev, O_WRONLY); |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
491 if(audio_fd<0){ |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12148
diff
changeset
|
492 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_CantOpenAudioDev, audio_dev, strerror(errno)); |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
493 return 0; |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
494 } |
1041 | 495 |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
496 if (af2sunfmt(format) == AUDIO_ENCODING_NONE) |
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
497 format = AF_FORMAT_S16_NE; |
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
498 |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
499 for (ok = pass = 0; pass <= 5; pass++) { /* pass 6&7 not useful */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
500 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
501 AUDIO_INITINFO(&info); |
14249 | 502 info.play.encoding = af2sunfmt(ao_data.format = format); |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
503 info.play.precision = |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
504 (format==AF_FORMAT_S16_NE |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
505 ? AUDIO_PRECISION_16 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
506 : AUDIO_PRECISION_8); |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
507 info.play.channels = ao_data.channels = channels; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
508 info.play.sample_rate = ao_data.samplerate = rate; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
509 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
510 convert_u8_s8 = 0; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
511 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
512 if (pass & 1) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
513 /* |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
514 * on some sun audio drivers, 8-bit unsigned LINEAR8 encoding is |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
515 * not supported, but 8-bit signed encoding is. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
516 * |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
517 * Try S8, and if it works, use our own U8->S8 conversion before |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
518 * sending the samples to the sound driver. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
519 */ |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
520 #ifdef AUDIO_ENCODING_LINEAR8 |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
521 if (info.play.encoding != AUDIO_ENCODING_LINEAR8) |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
522 #endif |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
523 continue; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
524 info.play.encoding = AUDIO_ENCODING_LINEAR; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
525 convert_u8_s8 = 1; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
526 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
527 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
528 if (pass & 2) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
529 /* |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
530 * on some sun audio drivers, only certain fixed sample rates are |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
531 * supported. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
532 * |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
533 * In case the requested sample rate is very close to one of the |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
534 * supported rates, use the fixed supported rate instead. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
535 */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
536 if (!(info.play.sample_rate = |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
537 find_close_samplerate_match(audio_fd, rate))) |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
538 continue; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
539 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
540 /* |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
541 * I'm not returning the correct sample rate in |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
542 * |ao_data.samplerate|, to avoid software resampling. |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
543 * |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
544 * ao_data.samplerate = info.play.sample_rate; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
545 */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
546 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
547 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
548 if (pass & 4) { |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
549 /* like "pass & 2", but use the highest supported sample rate */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
550 if (!(info.play.sample_rate |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
551 = ao_data.samplerate |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
552 = find_highest_samplerate(audio_fd))) |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
553 continue; |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
554 } |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
555 |
1807
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
556 ok = ioctl(audio_fd, AUDIO_SETINFO, &info) >= 0; |
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
557 if (ok) { |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
558 /* audio format accepted by audio driver */ |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
559 break; |
1807
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
560 } |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
561 |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
562 /* |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
563 * format not supported? |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
564 * retry with different encoding and/or sample rate |
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
565 */ |
1807
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
566 } |
7656
52009e5ef4fc
Handle playback of sample rates not supported by the sun audio hardware.
jkeil
parents:
7422
diff
changeset
|
567 |
1807
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
568 if (!ok) { |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
569 char buf[128]; |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12148
diff
changeset
|
570 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SUN_UnsupSampleRate, |
14255
137896e25c24
100l, buf etc. in af_fmt2str call are already pointers...
reimar
parents:
14249
diff
changeset
|
571 channels, af_fmt2str(format, buf, 128), rate); |
1807
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
572 return 0; |
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
573 } |
6da3b9428ff0
Sun audiocs HW does not support AFMT_U8, try to use AFMT_S8 instead. If AFMT_S8
jkeil
parents:
1456
diff
changeset
|
574 |
14409
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
575 if (convert_u8_s8) |
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
576 ao_data.format = AF_FORMAT_S8; |
6d8634c0bdfa
Cleanup, removing internal conversions. Testing welcome.
reimar
parents:
14264
diff
changeset
|
577 |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
578 bytes_per_sample = channels * info.play.precision / 8; |
10325 | 579 ao_data.bps = byte_per_sec = bytes_per_sample * ao_data.samplerate; |
3095 | 580 ao_data.outburst = byte_per_sec > 100000 ? 16384 : 8192; |
1041 | 581 |
28654
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
582 reset(); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
583 |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
584 return 1; |
1041 | 585 } |
586 | |
587 // close audio device | |
12145 | 588 static void uninit(int immed){ |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
589 // throw away buffered data in the audio driver's STREAMS queue |
12145 | 590 if (immed) |
23334 | 591 flush_audio(audio_fd); |
26312 | 592 else |
593 ioctl(audio_fd, AUDIO_DRAIN, 0); | |
1041 | 594 close(audio_fd); |
595 } | |
596 | |
597 // stop playing and empty buffers (for seeking/pause) | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17933
diff
changeset
|
598 static void reset(void){ |
28654
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
599 audio_info_t info; |
26313 | 600 flush_audio(audio_fd); |
28654
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
601 |
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
602 AUDIO_INITINFO(&info); |
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
603 info.play.samples = 0; |
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
604 info.play.eof = 0; |
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
605 info.play.error = 0; |
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
606 ioctl(audio_fd, AUDIO_SETINFO, &info); |
aa7af4c30429
Move resetting audio_info_t samples, eof and error in ao_sun.c to reset(), avoids
reimar
parents:
28343
diff
changeset
|
607 |
1041 | 608 queued_bursts = 0; |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
609 queued_samples = 0; |
1041 | 610 } |
611 | |
612 // stop playing, keep buffers (for pause) | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17933
diff
changeset
|
613 static void audio_pause(void) |
1041 | 614 { |
615 struct audio_info info; | |
616 AUDIO_INITINFO(&info); | |
617 info.play.pause = 1; | |
618 ioctl(audio_fd, AUDIO_SETINFO, &info); | |
619 } | |
620 | |
621 // resume playing, after audio_pause() | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17933
diff
changeset
|
622 static void audio_resume(void) |
1041 | 623 { |
624 struct audio_info info; | |
625 AUDIO_INITINFO(&info); | |
626 info.play.pause = 0; | |
627 ioctl(audio_fd, AUDIO_SETINFO, &info); | |
628 } | |
629 | |
630 | |
631 // return: how many bytes can be played without blocking | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17933
diff
changeset
|
632 static int get_space(void){ |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
633 audio_info_t info; |
1041 | 634 |
635 // check buffer | |
636 #ifdef HAVE_AUDIO_SELECT | |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
637 { |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
638 fd_set rfds; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
639 struct timeval tv; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
640 FD_ZERO(&rfds); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
641 FD_SET(audio_fd, &rfds); |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
642 tv.tv_sec = 0; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
643 tv.tv_usec = 0; |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
644 if(!select(audio_fd+1, NULL, &rfds, NULL, &tv)) return 0; // not block! |
1041 | 645 } |
646 #endif | |
647 | |
23336 | 648 ioctl(audio_fd, AUDIO_GETINFO, &info); |
6630
daf0d43ccde2
Patch to improve bufferhandling on OpenBSD and NetBSD, by Bj¸«Órn Sandell and Bernd Ernesti <mplayer at lists.veego.de>
atmos4
parents:
5893
diff
changeset
|
649 #if !defined (__OpenBSD__) && !defined(__NetBSD__) |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
650 if (queued_bursts - info.play.eof > 2) |
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
651 return 0; |
23593
1bb33276e2de
Fix r23353, it broke ao_sun on non-BSD due to accidentially removing
reimar
parents:
23336
diff
changeset
|
652 return ao_data.outburst; |
23335
69696caa0b1b
Clean up some unused code and #ifdef mess in ao_sun.c
reimar
parents:
23334
diff
changeset
|
653 #else |
6630
daf0d43ccde2
Patch to improve bufferhandling on OpenBSD and NetBSD, by Bj¸«Órn Sandell and Bernd Ernesti <mplayer at lists.veego.de>
atmos4
parents:
5893
diff
changeset
|
654 return info.hiwat * info.blocksize - info.play.seek; |
daf0d43ccde2
Patch to improve bufferhandling on OpenBSD and NetBSD, by Bj¸«Órn Sandell and Bernd Ernesti <mplayer at lists.veego.de>
atmos4
parents:
5893
diff
changeset
|
655 #endif |
daf0d43ccde2
Patch to improve bufferhandling on OpenBSD and NetBSD, by Bj¸«Órn Sandell and Bernd Ernesti <mplayer at lists.veego.de>
atmos4
parents:
5893
diff
changeset
|
656 |
1041 | 657 } |
658 | |
659 // plays 'len' bytes of 'data' | |
660 // it should round it down to outburst*n | |
661 // return: number of bytes played | |
662 static int play(void* data,int len,int flags){ | |
32423
4a3bfd196e17
Add support for AOPLAY_FINAL_CHUNK, reportedly also fixes a possible
reimar
parents:
30633
diff
changeset
|
663 if (!(flags & AOPLAY_FINAL_CHUNK)) { |
32424 | 664 len /= ao_data.outburst; |
665 len *= ao_data.outburst; | |
32423
4a3bfd196e17
Add support for AOPLAY_FINAL_CHUNK, reportedly also fixes a possible
reimar
parents:
30633
diff
changeset
|
666 } |
4a3bfd196e17
Add support for AOPLAY_FINAL_CHUNK, reportedly also fixes a possible
reimar
parents:
30633
diff
changeset
|
667 if (len <= 0) return 0; |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
668 |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
669 len = write(audio_fd, data, len); |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
670 if(len > 0) { |
1308
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
671 queued_samples += len / bytes_per_sample; |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
672 if (write(audio_fd,data,0) < 0) |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
673 perror("ao_sun: send EOF audio record"); |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
674 else |
ffd63a75700c
Support playback of AFMT_S16_LE audio data on a big endian machine
jkeil
parents:
1209
diff
changeset
|
675 queued_bursts ++; |
1041 | 676 } |
677 return len; | |
678 } | |
679 | |
680 | |
3095 | 681 // return: delay in seconds between first and last sample in buffer |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17933
diff
changeset
|
682 static float get_delay(void){ |
1041 | 683 audio_info_t info; |
684 ioctl(audio_fd, AUDIO_GETINFO, &info); | |
6630
daf0d43ccde2
Patch to improve bufferhandling on OpenBSD and NetBSD, by Bj¸«Órn Sandell and Bernd Ernesti <mplayer at lists.veego.de>
atmos4
parents:
5893
diff
changeset
|
685 #if defined (__OpenBSD__) || defined(__NetBSD__) |
5872 | 686 return (float) info.play.seek/ (float)byte_per_sec ; |
687 #else | |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
688 if (info.play.samples && enable_sample_timing == RTSC_ENABLED) |
7714
6973a985ac2a
- ao_data.bps not set, confuses the A-V sync computation when the audio filters
jkeil
parents:
7656
diff
changeset
|
689 return (float)(queued_samples - info.play.samples) / (float)ao_data.samplerate; |
1196
fc51929ec8ea
Applied patch by J¸«ärgen Keil (jk@tools.de), improves smoothness of video playback.
atmosfear
parents:
1058
diff
changeset
|
690 else |
3137 | 691 return (float)((queued_bursts - info.play.eof) * ao_data.outburst) / (float)byte_per_sec; |
5872 | 692 #endif |
1041 | 693 } |