annotate libao2/ao_sgi.c @ 29276:ff43e2263d6d

cosmetics: alphabetically sort SRCS_MPLAYER
author diego
date Thu, 21 May 2009 08:46:24 +0000
parents 0f1b5b68af32
children 32725ca88fed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
1 /*
28343
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
2 * SGI/IRIX audio output driver
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
3 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
4 * copyright (c) 2001 oliver.schoenbrunner@jku.at
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
5 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
6 * This file is part of MPlayer.
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
7 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
9 * it under the terms of the GNU General Public License as published by
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
11 * (at your option) any later version.
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
12 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
16 * GNU General Public License for more details.
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
17 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
18 * You should have received a copy of the GNU General Public License along
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e45b08f2f5d3 Add standard license headers.
diego
parents: 24595
diff changeset
21 */
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
22
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
23 #include <stdio.h>
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
24 #include <stdlib.h>
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
25 #include <unistd.h>
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
26 #include <errno.h>
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
27 #include <dmedia/audio.h>
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
28
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
29 #include "audio_out.h"
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
30 #include "audio_out_internal.h"
14123
a92101a7eb49 Make include paths consistent.
diego
parents: 13549
diff changeset
31 #include "mp_msg.h"
a92101a7eb49 Make include paths consistent.
diego
parents: 13549
diff changeset
32 #include "help_mp.h"
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
33 #include "libaf/af_format.h"
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
34
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
35 static const ao_info_t info =
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
36 {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
37 "sgi audio output",
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
38 "sgi",
13549
4604fc855b3a fixing authors
alex
parents: 13383
diff changeset
39 "Oliver Schoenbrunner",
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
40 ""
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
41 };
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
42
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
43 LIBAO_EXTERN(sgi)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
44
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
45
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
46 static ALconfig ao_config;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
47 static ALport ao_port;
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
48 static int sample_rate;
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
49 static int queue_size;
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
50 static int bytes_per_frame;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
51
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
52 /**
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
53 * \param [in/out] format
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
54 * \param [out] width
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
55 *
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
56 * \return the closest matching SGI AL sample format
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
57 *
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
58 * \note width is set to required per-channel sample width
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
59 * format is updated to match the SGI AL sample format
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
60 */
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
61 static int fmt2sgial(int *format, int *width) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
62 int smpfmt = AL_SAMPFMT_TWOSCOMP;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
63
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
64 /* SGI AL only supports float and signed integers in native
24595
85f669a84e7a cosmetics: misc typo fixes
diego
parents: 18915
diff changeset
65 * endianness. If this is something else, we must rely on the audio
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
66 * filter to convert it to a compatible format. */
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
67
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
68 /* 24-bit audio is supported, but only with 32-bit alignment.
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
69 * mplayer's 24-bit format is packed, unfortunately.
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
70 * So we must upgrade 24-bit requests to 32 bits. Then we drop the
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
71 * lowest 8 bits during playback. */
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
72
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
73 switch(*format) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
74 case AF_FORMAT_U8:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
75 case AF_FORMAT_S8:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
76 *width = AL_SAMPLE_8;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
77 *format = AF_FORMAT_S8;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
78 break;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
79
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
80 case AF_FORMAT_U16_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
81 case AF_FORMAT_U16_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
82 case AF_FORMAT_S16_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
83 case AF_FORMAT_S16_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
84 *width = AL_SAMPLE_16;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
85 *format = AF_FORMAT_S16_NE;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
86 break;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
87
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
88 case AF_FORMAT_U24_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
89 case AF_FORMAT_U24_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
90 case AF_FORMAT_S24_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
91 case AF_FORMAT_S24_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
92 case AF_FORMAT_U32_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
93 case AF_FORMAT_U32_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
94 case AF_FORMAT_S32_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
95 case AF_FORMAT_S32_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
96 *width = AL_SAMPLE_24;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
97 *format = AF_FORMAT_S32_NE;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
98 break;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
99
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
100 case AF_FORMAT_FLOAT_LE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
101 case AF_FORMAT_FLOAT_BE:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
102 *width = 4;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
103 *format = AF_FORMAT_FLOAT_NE;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
104 smpfmt = AL_SAMPFMT_FLOAT;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
105 break;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
106
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
107 default:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
108 *width = AL_SAMPLE_16;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
109 *format = AF_FORMAT_S16_NE;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
110 break;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
111
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
112 }
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
113
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
114 return smpfmt;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
115 }
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
116
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
117 // to set/get/query special features/parameters
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 3095
diff changeset
118 static int control(int cmd, void *arg){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
119
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
120 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_INFO);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
121
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
122 switch(cmd) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
123 case AOCONTROL_QUERY_FORMAT:
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
124 /* Do not reject any format: return the closest matching
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
125 * format if the request is not supported natively. */
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
126 return CONTROL_TRUE;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
127 }
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
128
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
129 return CONTROL_UNKNOWN;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
130 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
131
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
132 // open & setup audio device
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
133 // return: 1=success 0=fail
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
134 static int init(int rate, int channels, int format, int flags) {
14249
8f59f661f317 hopefully final fix
alex
parents: 14123
diff changeset
135
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
136 int smpwidth, smpfmt;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
137 int rv = AL_DEFAULT_OUTPUT;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
138
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
139 smpfmt = fmt2sgial(&format, &smpwidth);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
140
14264
cb5fbade8a5c af_fmt2str_short
alex
parents: 14255
diff changeset
141 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_InitInfo, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
142
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
143 { /* from /usr/share/src/dmedia/audio/setrate.c */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
144
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
145 double frate, realrate;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
146 ALpv x[2];
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
147
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
148 if(ao_subdevice) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
149 rv = alGetResourceByName(AL_SYSTEM, ao_subdevice, AL_OUTPUT_DEVICE_TYPE);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
150 if (!rv) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
151 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InvalidDevice);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
152 return 0;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
153 }
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
154 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
155
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
156 frate = rate;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
157
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
158 x[0].param = AL_RATE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
159 x[0].value.ll = alDoubleToFixed(rate);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
160 x[1].param = AL_MASTER_CLOCK;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
161 x[1].value.i = AL_CRYSTAL_MCLK_TYPE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
162
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
163 if (alSetParams(rv,x, 2)<0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
164 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetParms_Samplerate, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
165 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
166
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
167 if (x[0].sizeOut < 0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
168 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetAlRate);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
169 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
170
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
171 if (alGetParams(rv,x, 1)<0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
172 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantGetParms, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
173 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
174
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
175 realrate = alFixedToDouble(x[0].value.ll);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
176 if (frate != realrate) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
177 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_SampleRateInfo, realrate, frate);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
178 }
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
179 sample_rate = (int)realrate;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
180 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
181
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
182 bytes_per_frame = channels * smpwidth;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
183
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
184 ao_data.samplerate = sample_rate;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
185 ao_data.channels = channels;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
186 ao_data.format = format;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
187 ao_data.bps = sample_rate * bytes_per_frame;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
188 ao_data.buffersize=131072;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
189 ao_data.outburst = ao_data.buffersize/16;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
190
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
191 ao_config = alNewConfig();
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
192
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
193 if (!ao_config) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
194 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
195 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
196 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
197
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
198 if(alSetChannels(ao_config, channels) < 0 ||
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
199 alSetWidth(ao_config, smpwidth) < 0 ||
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
200 alSetSampFmt(ao_config, smpfmt) < 0 ||
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
201 alSetQueueSize(ao_config, sample_rate) < 0 ||
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
202 alSetDevice(ao_config, rv) < 0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
203 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
204 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
205 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
206
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
207 ao_port = alOpenPort("mplayer", "w", ao_config);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
208
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
209 if (!ao_port) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
210 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitOpenAudioFailed, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
211 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
212 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
213
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
214 // printf("ao_sgi, init: port %d config %d\n", ao_port, ao_config);
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
215 queue_size = alGetQueueSize(ao_config);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
216 return 1;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
217
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
218 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
219
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
220 // close audio device
12145
99798c3cdb93 uninit immed flag
alex
parents: 11323
diff changeset
221 static void uninit(int immed) {
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
222
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
223 /* TODO: samplerate should be set back to the value before mplayer was started! */
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
224
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
225 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Uninit);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
226
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
227 if (ao_config) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
228 alFreeConfig(ao_config);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
229 ao_config = NULL;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
230 }
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
231
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
232 if (ao_port) {
14849
d313f591d1a4 aos should respect the immed uninit flag (quit immediatly vs waiting till file
reimar
parents: 14264
diff changeset
233 if (!immed)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
234 while(alGetFilled(ao_port) > 0) sginap(1);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
235 alClosePort(ao_port);
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
236 ao_port = NULL;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
237 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
238
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
239 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
240
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
241 // stop playing and empty buffers (for seeking/pause)
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 16667
diff changeset
242 static void reset(void) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
243
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
244 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Reset);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
245
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
246 alDiscardFrames(ao_port, queue_size);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
247 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
248
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
249 // stop playing, keep buffers (for pause)
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 16667
diff changeset
250 static void audio_pause(void) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
251
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
252 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_PauseInfo);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
253
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
254 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
255
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
256 // resume playing, after audio_pause()
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 16667
diff changeset
257 static void audio_resume(void) {
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
258
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
259 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_ResumeInfo);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
260
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
261 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
262
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
263 // return: how many bytes can be played without blocking
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 16667
diff changeset
264 static int get_space(void) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
265
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
266 // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_data.outburst);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
267 // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
268
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
269 return alGetFillable(ao_port) * bytes_per_frame;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
270
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
271 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
272
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
273
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
274 // plays 'len' bytes of 'data'
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
275 // it should round it down to outburst*n
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
276 // return: number of bytes played
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
277 static int play(void* data, int len, int flags) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
278
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
279 /* Always process data in quadword-aligned chunks (64-bits). */
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
280 const int plen = len / (sizeof(uint64_t) * bytes_per_frame);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
281 const int framecount = plen * sizeof(uint64_t);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
282
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
283 // printf("ao_sgi, play: len %d flags %d (%d %d)\n", len, flags, ao_port, ao_config);
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
284 // printf("channels %d\n", ao_data.channels);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
285
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
286 if(ao_data.format == AF_FORMAT_S32_NE) {
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
287 /* The zen of this is explained in fmt2sgial() */
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
288 int32_t *smpls = data;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
289 const int32_t *smple = smpls + (framecount * ao_data.channels);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
290 while(smpls < smple)
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
291 *smpls++ >>= 8;
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
292 }
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
293
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
294 alWriteFrames(ao_port, data, framecount);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
295
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
296 return framecount * bytes_per_frame;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
297
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
298 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
299
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
300 // return: delay in seconds between first and last sample in buffer
18915
99e20a22d5d0 modifies function declarations without parameters from ()
reynaldo
parents: 16667
diff changeset
301 static float get_delay(void){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
302
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
303 // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
304
16667
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
305 // return (float)queue_size/((float)sample_rate);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
306 const int outstanding = alGetFilled(ao_port);
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
307 return (float)((outstanding < 0) ? queue_size : outstanding) /
27a2bc4aad72 General bug fixes, like missing includes, formats that were incorrectly
reimar
parents: 14849
diff changeset
308 ((float)sample_rate);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
309 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
310
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
311
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
312
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
313
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
314
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
315