Mercurial > mplayer.hg
annotate libao2/ao_mpegpes.c @ 29228:0c351ed09bb0
sync with en/mplayer.1 r29252
author | jrash |
---|---|
date | Thu, 07 May 2009 13:13:54 +0000 |
parents | 9a5b8c2ed6de |
children | 0f1b5b68af32 |
rev | line source |
---|---|
28343 | 1 /* |
2 * MPEG-PES 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 | |
2708 | 21 #include <stdio.h> |
22 #include <stdlib.h> | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7164
diff
changeset
|
23 #include <string.h> |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
24 #include <sys/types.h> |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
25 #include <sys/stat.h> |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
26 #include <fcntl.h> |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
27 #include <unistd.h> |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
28 #include <inttypes.h> |
19362 | 29 #include <errno.h> |
9411 | 30 |
14123 | 31 #include "config.h" |
9411 | 32 |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
33 #ifdef CONFIG_DVB |
27431
bb738b9ea7c4
Use '#include <poll.h>' instead of '#include <sys/poll.h>'.
diego
parents:
27430
diff
changeset
|
34 #include <poll.h> |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
35 #include <sys/ioctl.h> |
6856 | 36 #endif |
2708 | 37 |
38 #include "audio_out.h" | |
39 #include "audio_out_internal.h" | |
40 | |
14245 | 41 #include "libaf/af_format.h" |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
42 #include "libmpdemux/mpeg_packetizer.h" |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
43 #include "subopt-helper.h" |
2708 | 44 |
14123 | 45 #include "mp_msg.h" |
46 #include "help_mp.h" | |
7161 | 47 |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
48 #ifdef CONFIG_DVB |
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
49 #ifndef CONFIG_DVB_HEAD |
4792 | 50 #include <ost/audio.h> |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
51 audioMixer_t dvb_mixer={255,255}; |
8594 | 52 #else |
9411 | 53 #include <linux/dvb/audio.h> |
8594 | 54 audio_mixer_t dvb_mixer={255,255}; |
55 #endif | |
7609 | 56 #endif |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
57 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
58 #define true 1 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
59 #define false 0 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
60 |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
61 extern int vo_mpegpes_fd; |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
62 int vo_mpegpes_fd2 = -1; |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
63 |
7164 | 64 #include <errno.h> |
65 | |
28823 | 66 static const ao_info_t info = |
2708 | 67 { |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
68 #ifdef CONFIG_DVB |
4792 | 69 "DVB audio output", |
70 #else | |
27368 | 71 "MPEG-PES audio output", |
4792 | 72 #endif |
2708 | 73 "mpegpes", |
74 "A'rpi", | |
75 "" | |
76 }; | |
77 | |
78 LIBAO_EXTERN(mpegpes) | |
79 | |
80 | |
81 // to set/get/query special features/parameters | |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
9411
diff
changeset
|
82 static int control(int cmd,void *arg){ |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
83 #ifdef CONFIG_DVB |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
84 switch(cmd){ |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
85 case AOCONTROL_GET_VOLUME: |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
86 if(vo_mpegpes_fd2>=0){ |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
87 ((ao_control_vol_t*)(arg))->left=dvb_mixer.volume_left/2.56; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
88 ((ao_control_vol_t*)(arg))->right=dvb_mixer.volume_right/2.56; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
89 return CONTROL_OK; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
90 } |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
91 return CONTROL_ERROR; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
92 case AOCONTROL_SET_VOLUME: |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
93 if(vo_mpegpes_fd2>=0){ |
5060 | 94 dvb_mixer.volume_left=((ao_control_vol_t*)(arg))->left*2.56; |
95 dvb_mixer.volume_right=((ao_control_vol_t*)(arg))->right*2.56; | |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
96 if(dvb_mixer.volume_left>255) dvb_mixer.volume_left=255; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
97 if(dvb_mixer.volume_right>255) dvb_mixer.volume_right=255; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
98 // printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right); |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
99 if ( (ioctl(vo_mpegpes_fd2,AUDIO_SET_MIXER, &dvb_mixer) < 0)){ |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
100 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_CantSetMixer, |
7161 | 101 strerror(errno)); |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
102 return CONTROL_ERROR; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
103 } |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
104 return CONTROL_OK; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
105 } |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
106 return CONTROL_ERROR; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
107 } |
4792 | 108 #endif |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4331
diff
changeset
|
109 return CONTROL_UNKNOWN; |
2708 | 110 } |
111 | |
4331 | 112 static int freq=0; |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
113 static int freq_id=0; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
114 |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
115 #ifdef CONFIG_DVB |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
116 static int init_device(int card) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
117 { |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
118 char ao_file[30]; |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
119 #ifndef CONFIG_DVB_HEAD |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
120 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/ost/audio\n"); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
121 sprintf(ao_file, "/dev/ost/audio"); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
122 #else |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
123 mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/dvb/adapter%d/audio0\n", card); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
124 sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
125 #endif |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
126 if((vo_mpegpes_fd2 = open(ao_file,O_RDWR|O_NONBLOCK)) < 0) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
127 { |
19362 | 128 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO DEVICE: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
129 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
130 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
131 if( (ioctl(vo_mpegpes_fd2,AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0)) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
132 { |
19362 | 133 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SELECT SOURCE: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
134 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
135 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
136 if((ioctl(vo_mpegpes_fd2,AUDIO_PLAY) < 0)) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
137 { |
19362 | 138 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO PLAY: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
139 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
140 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
141 if((ioctl(vo_mpegpes_fd2,AUDIO_SET_AV_SYNC, true) < 0)) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
142 { |
19362 | 143 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET AV SYNC: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
144 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
145 } |
25962 | 146 //FIXME: in vo_mpegpes audio was initialized as MUTEd |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
147 if((ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, false) < 0)) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
148 { |
19362 | 149 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET MUTE: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
150 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
151 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
152 return vo_mpegpes_fd2; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
153 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
154 #endif |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
155 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
156 static int preinit(const char *arg) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
157 { |
25558
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
158 int card = -1; |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
159 char *ao_file = NULL; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
160 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
161 opt_t subopts[] = { |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
162 {"card", OPT_ARG_INT, &card, NULL}, |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
163 {"file", OPT_ARG_MSTRZ, &ao_file, NULL}, |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
164 {NULL} |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
165 }; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
166 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
167 if(subopt_parse(ao_subdevice, subopts) != 0) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
168 { |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
169 mp_msg(MSGT_VO, MSGL_ERR, "AO_MPEGPES, Unrecognized options\n"); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
170 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
171 } |
25558
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
172 if(card==-1) |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
173 { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
174 //search the first usable card |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
175 int n; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
176 char file[30]; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
177 for(n=0; n<4; n++) |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
178 { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
179 sprintf(file, "/dev/dvb/adapter%d/audio0", n); |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
180 if(access(file, F_OK | W_OK)==0) |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
181 { |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
182 card = n+1; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
183 break; |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
184 } |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
185 } |
634dfaa85718
when :card isn't specified by the user search the first available card
nicodvb
parents:
24522
diff
changeset
|
186 } |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
187 if((card < 1) || (card > 4)) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
188 { |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
189 mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n"); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
190 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
191 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
192 card--; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
193 |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
194 #ifdef CONFIG_DVB |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
195 if(!ao_file) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
196 return init_device(card); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
197 #else |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
198 if(!ao_file) |
19222
5500b7fa33c0
if HAVE_DVB isn't set don't fall back to outputting audiograb.mpg by default, fail instead
nicodvb
parents:
19215
diff
changeset
|
199 return vo_mpegpes_fd; //video fd |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
200 #endif |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
201 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
202 vo_mpegpes_fd2=open(ao_file,O_WRONLY|O_CREAT,0666); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
203 if(vo_mpegpes_fd2<0) |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
204 { |
19362 | 205 mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
206 return -1; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
207 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
208 return vo_mpegpes_fd2; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
209 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
210 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
211 static int my_ao_write(unsigned char* data,int len){ |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
212 int orig_len = len; |
27430
8bc08d1b115d
100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents:
27369
diff
changeset
|
213 #ifdef CONFIG_DVB |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
214 #define NFD 1 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
215 struct pollfd pfd[NFD]; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
216 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
217 pfd[0].fd = vo_mpegpes_fd2; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
218 pfd[0].events = POLLOUT; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
219 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
220 while(len>0){ |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
221 if(poll(pfd,NFD,1)){ |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
222 if(pfd[0].revents & POLLOUT){ |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
223 int ret=write(vo_mpegpes_fd2,data,len); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
224 if(ret<=0){ |
19362 | 225 mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes write: %s\n", strerror(errno)); |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
226 usleep(0); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
227 } else { |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
228 len-=ret; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
229 data+=ret; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
230 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
231 } else usleep(1000); |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
232 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
233 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
234 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
235 #else |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
236 if(vo_mpegpes_fd2<0) return 0; // no file |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
237 write(vo_mpegpes_fd2,data,len); // write to file |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
238 #endif |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
239 return orig_len; |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
240 } |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
241 |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
242 |
2708 | 243 // open & setup audio device |
244 // return: 1=success 0=fail | |
245 static int init(int rate,int channels,int format,int flags){ | |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
246 if(preinit(NULL)<0) return 0; |
7607 | 247 |
248 ao_data.channels=2; | |
3095 | 249 ao_data.outburst=2000; |
7607 | 250 switch(format){ |
14245 | 251 case AF_FORMAT_S16_BE: |
252 case AF_FORMAT_MPEG2: | |
253 case AF_FORMAT_AC3: | |
7607 | 254 ao_data.format=format; |
255 break; | |
256 default: | |
14245 | 257 ao_data.format=AF_FORMAT_S16_BE; |
7607 | 258 } |
24356 | 259 |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
260 switch(rate){ |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
261 case 48000: freq_id=0;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
262 case 96000: freq_id=1;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
263 case 44100: freq_id=2;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
264 case 32000: freq_id=3;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
265 default: |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
266 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate); |
7607 | 267 #if 0 |
268 if(rate>48000) rate=96000; else | |
269 if(rate>44100) rate=48000; else | |
270 if(rate>32000) rate=44100; else | |
271 rate=32000; | |
272 goto retry; | |
273 #else | |
274 rate=48000; freq_id=0; | |
275 #endif | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
276 } |
2708 | 277 |
7607 | 278 ao_data.bps=rate*2*2; |
279 freq=ao_data.samplerate=rate; | |
280 | |
2708 | 281 return 1; |
282 } | |
283 | |
284 // close audio device | |
12145 | 285 static void uninit(int immed){ |
2708 | 286 |
287 } | |
288 | |
289 // stop playing and empty buffers (for seeking/pause) | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
14245
diff
changeset
|
290 static void reset(void){ |
2708 | 291 |
292 } | |
293 | |
294 // stop playing, keep buffers (for pause) | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
14245
diff
changeset
|
295 static void audio_pause(void) |
2708 | 296 { |
297 // for now, just call reset(); | |
298 reset(); | |
299 } | |
300 | |
301 // resume playing, after audio_pause() | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
14245
diff
changeset
|
302 static void audio_resume(void) |
2708 | 303 { |
304 } | |
305 | |
306 void send_pes_packet(unsigned char* data,int len,int id,int timestamp); | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
307 void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id); |
2708 | 308 extern int vo_pts; |
309 | |
310 // return: how many bytes can be played without blocking | |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
14245
diff
changeset
|
311 static int get_space(void){ |
4331 | 312 float x=(float)(vo_pts-ao_data.pts)/90000.0; |
2708 | 313 int y; |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
314 //FIXME: is it correct? |
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
315 if(vo_mpegpes_fd < 0) return 32000; //not using -vo mpegpes |
7607 | 316 // printf("vo_pts: %5.3f ao_pts: %5.3f\n",vo_pts/90000.0,ao_data.pts/90000.0); |
2708 | 317 if(x<=0) return 0; |
4331 | 318 y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst; |
319 if(y>32000) y=32000; | |
2708 | 320 // printf("diff: %5.3f -> %d \n",x,y); |
321 return y; | |
322 } | |
323 | |
324 // plays 'len' bytes of 'data' | |
325 // it should round it down to outburst*n | |
326 // return: number of bytes played | |
327 static int play(void* data,int len,int flags){ | |
7607 | 328 // printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id); |
14245 | 329 if(ao_data.format==AF_FORMAT_MPEG2) |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
330 send_mpeg_pes_packet (data, len, 0x1C0, ao_data.pts, 1, my_ao_write); |
2708 | 331 else { |
332 int i; | |
333 unsigned short *s=data; | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
334 // if(len>2000) len=2000; |
4305 | 335 // printf("ao_mpegpes: len=%d \n",len); |
24522
89bae6fd11fe
ao_mpegpes does not support S16_LE format, do not claim it does!
reimar
parents:
24356
diff
changeset
|
336 if(ao_data.format==AF_FORMAT_AC3) |
7607 | 337 for(i=0;i<len/2;i++) s[i]=(s[i]>>8)|(s[i]<<8); // le<->be |
19184
3f2de7ba8aa0
split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents:
17566
diff
changeset
|
338 send_mpeg_lpcm_packet(data, len, 0xA0, ao_data.pts, freq_id, my_ao_write); |
2708 | 339 } |
340 return len; | |
341 } | |
342 | |
3095 | 343 // return: delay in seconds between first and last sample in buffer |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
14245
diff
changeset
|
344 static float get_delay(void){ |
2708 | 345 |
3095 | 346 return 0.0; |
2708 | 347 } |