Mercurial > mplayer.hg
annotate libao2/ao_dxr2.c @ 32043:f6249bc89c38
Move extern declarations used by both mplayer.c and mencoder.c to mpcommon.h.
author | diego |
---|---|
date | Thu, 09 Sep 2010 18:52:56 +0000 |
parents | a3890036b137 |
children | 8ffbdf8429d8 |
rev | line source |
---|---|
28343 | 1 /* |
2 * DXR2 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 | |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
21 #include <math.h> |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
22 #include <stdio.h> |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
23 #include <stdlib.h> |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
24 #include <sys/ioctl.h> |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
25 #include <inttypes.h> |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
26 #include <dxr2ioctl.h> |
14123 | 27 #include "config.h" |
28 #include "mp_msg.h" | |
29 #include "help_mp.h" | |
21372 | 30 #include "libavutil/common.h" |
21507
fa99b3d31d13
Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents:
21372
diff
changeset
|
31 #include "mpbswap.h" |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
32 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
33 #include "audio_out.h" |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
34 #include "audio_out_internal.h" |
14245 | 35 #include "libaf/af_format.h" |
19151 | 36 #include "libmpdemux/mpeg_packetizer.h" |
31997
a3890036b137
Add proper include instead of declaring the vo_pts variable extern.
diego
parents:
30633
diff
changeset
|
37 #include "libvo/video_out.h" |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
38 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
39 |
28823 | 40 static const ao_info_t info = |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
41 { |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
42 "DXR2 audio output", |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
43 "dxr2", |
15755 | 44 "Tobias Diedrich <ranma+mplayer@tdiedrich.de>", |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
45 "" |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
46 }; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
47 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
48 LIBAO_EXTERN(dxr2) |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
49 |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
50 static int volume=19; |
19164 | 51 static int last_freq_id = -1; |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
52 extern int dxr2_fd; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
53 |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
54 // to set/get/query special features/parameters |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
6111
diff
changeset
|
55 static int control(int cmd,void *arg){ |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
56 switch(cmd){ |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
57 case AOCONTROL_GET_VOLUME: |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
58 if(dxr2_fd > 0) { |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
59 ao_control_vol_t* vol = (ao_control_vol_t*)arg; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
60 vol->left = vol->right = volume * 19.0 / 100.0; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
61 return CONTROL_OK; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
62 } |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
63 return CONTROL_ERROR; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
64 case AOCONTROL_SET_VOLUME: |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
65 if(dxr2_fd > 0) { |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
66 dxr2_oneArg_t v; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
67 float diff; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
68 ao_control_vol_t* vol = (ao_control_vol_t*)arg; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
69 // We need this trick because the volume stepping is often too small |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
70 diff = ((vol->left+vol->right) / 2 - (volume*19.0/100.0)) * 19.0 / 100.0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
71 v.arg = volume + (diff > 0 ? ceil(diff) : floor(diff)); |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
72 if(v.arg > 19) v.arg = 19; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
73 if(v.arg < 0) v.arg = 0; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
74 if(v.arg != volume) { |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
75 volume = v.arg; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
76 if( ioctl(dxr2_fd,DXR2_IOC_SET_AUDIO_VOLUME,&v) < 0) { |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
77 mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_DXR2_SetVolFailed,volume); |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
78 return CONTROL_ERROR; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
79 } |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
80 } |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
81 return CONTROL_OK; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
82 } |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
83 return CONTROL_ERROR; |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
84 } |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
85 return CONTROL_UNKNOWN; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
86 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
87 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
88 static int freq=0; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
89 static int freq_id=0; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
90 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
91 // open & setup audio device |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
92 // return: 1=success 0=fail |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
93 static int init(int rate,int channels,int format,int flags){ |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
94 |
6111
582960ab7cc7
Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents:
6074
diff
changeset
|
95 if(dxr2_fd <= 0) |
582960ab7cc7
Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents:
6074
diff
changeset
|
96 return 0; |
582960ab7cc7
Workaround the bug in x11 vo's (if it's one) wich let a window in the way
albeu
parents:
6074
diff
changeset
|
97 |
19164 | 98 last_freq_id = -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
99 |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
100 ao_data.outburst=2048; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
101 ao_data.samplerate=rate; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
102 ao_data.channels=channels; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
103 ao_data.buffersize=2048; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
104 ao_data.bps=rate*4; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
105 ao_data.format=format; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
106 freq=rate; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
107 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
108 switch(rate){ |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
109 case 48000: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
110 freq_id=DXR2_AUDIO_FREQ_48; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
111 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
112 case 96000: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
113 freq_id=DXR2_AUDIO_FREQ_96; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
114 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
115 case 44100: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
116 freq_id=DXR2_AUDIO_FREQ_441; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
117 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
118 case 32000: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
119 freq_id=DXR2_AUDIO_FREQ_32; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
120 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
121 case 22050: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
122 freq_id=DXR2_AUDIO_FREQ_2205; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
123 break; |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
124 #ifdef DXR2_AUDIO_FREQ_24 |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
125 // This is not yet in the dxr2 driver CVS |
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
126 // you can get the patch at |
17064 | 127 // http://www.tdiedrich.de/~ranma/patches/dxr2.pcm1723.20020513 |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
128 case 24000: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
129 freq_id=DXR2_AUDIO_FREQ_24; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
130 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
131 case 64000: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
132 freq_id=DXR2_AUDIO_FREQ_64; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
133 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
134 case 88200: |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
135 freq_id=DXR2_AUDIO_FREQ_882; |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
136 break; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
137 #endif |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
138 default: |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
139 mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_DXR2_UnsupSamplerate,rate); |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
140 return 0; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
141 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
142 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
143 return 1; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
144 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
145 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
146 // close audio device |
12145 | 147 static void uninit(int immed){ |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
148 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
149 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
150 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
151 // stop playing and empty buffers (for seeking/pause) |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17064
diff
changeset
|
152 static void reset(void){ |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
153 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
154 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
155 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
156 // stop playing, keep buffers (for pause) |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17064
diff
changeset
|
157 static void audio_pause(void) |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
158 { |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
159 // for now, just call reset(); |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
160 reset(); |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
161 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
162 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
163 // resume playing, after audio_pause() |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17064
diff
changeset
|
164 static void audio_resume(void) |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
165 { |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
166 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
167 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
168 // return: how many bytes can be played without blocking |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17064
diff
changeset
|
169 static int get_space(void){ |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
170 float x=(float)(vo_pts-ao_data.pts)/90000.0; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
171 int y; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
172 if(x<=0) return 0; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
173 y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
174 if(y>32768) y=32768; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
175 return y; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
176 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
177 |
19164 | 178 static void dxr2_send_lpcm_packet(unsigned char* data,int len,int id,unsigned int timestamp,int freq_id) |
179 { | |
28051 | 180 int write_dxr2(const unsigned char *data, int len); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
181 |
19164 | 182 if(dxr2_fd < 0) { |
183 mp_msg(MSGT_AO,MSGL_ERR,"DXR2 fd is not valid\n"); | |
184 return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
185 } |
19164 | 186 |
187 if(last_freq_id != freq_id) { | |
188 ioctl(dxr2_fd, DXR2_IOC_SET_AUDIO_SAMPLE_FREQUENCY, &freq_id); | |
189 last_freq_id = freq_id; | |
190 } | |
191 | |
192 send_mpeg_lpcm_packet (data, len, id, timestamp, freq_id, write_dxr2); | |
193 } | |
194 | |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
195 // plays 'len' bytes of 'data' |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
196 // it should round it down to outburst*n |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
197 // return: number of bytes played |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
198 static int play(void* data,int len,int flags){ |
28051 | 199 int write_dxr2(const unsigned char *data, int len); |
19151 | 200 |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
201 // MPEG and AC3 don't work :-( |
14245 | 202 if(ao_data.format==AF_FORMAT_MPEG2) |
19151 | 203 send_mpeg_ps_packet (data, len, 0xC0, ao_data.pts, 2, write_dxr2); |
30234 | 204 else if(AF_FORMAT_IS_AC3(ao_data.format)) |
19151 | 205 send_mpeg_ps_packet (data, len, 0x80, ao_data.pts, 2, write_dxr2); |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
206 else { |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
207 int i; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
208 //unsigned short *s=data; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
209 uint16_t *s=data; |
29401
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
29263
diff
changeset
|
210 #if !HAVE_BIGENDIAN |
6074
10a30eebafaf
Applied patch from Tobias Diedrich <ranma@gmx.at>, added volume setting
albeu
parents:
6069
diff
changeset
|
211 for(i=0;i<len/2;i++) s[i] = bswap_16(s[i]); |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
212 #endif |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
213 dxr2_send_lpcm_packet(data,len,0xA0,ao_data.pts-10000,freq_id); |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
214 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
215 return len; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
216 } |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
217 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
218 // return: delay in seconds between first and last sample in buffer |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
17064
diff
changeset
|
219 static float get_delay(void){ |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
220 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
221 return 0.0; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
diff
changeset
|
222 } |