annotate libao2/ao_mpegpes.c @ 33747:e5959dcf8fe6

Remove config related variables from interface.[ch]. Move them to cfg.[ch] instead.
author ib
date Thu, 07 Jul 2011 14:09:57 +0000
parents dd75bae40633
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28343
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
1 /*
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
2 * MPEG-PES audio output driver
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
3 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
4 * This file is part of MPlayer.
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
5 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
7 * it under the terms of the GNU General Public License as published by
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
9 * (at your option) any later version.
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
10 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
14 * GNU General Public License for more details.
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
15 *
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
16 * You should have received a copy of the GNU General Public License along
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
19 */
e45b08f2f5d3 Add standard license headers.
diego
parents: 27431
diff changeset
20
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
21 #include <stdio.h>
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
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
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
29 #include <errno.h>
9411
arpi
parents: 9265
diff changeset
30
14123
a92101a7eb49 Make include paths consistent.
diego
parents: 13383
diff changeset
31 #include "config.h"
9411
arpi
parents: 9265
diff changeset
32
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
33 #include "audio_out.h"
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
34 #include "audio_out_internal.h"
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
35
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
36 #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
37 #include "libmpdemux/mpeg_packetizer.h"
32087
dd75bae40633 Add explanatory comment for video_out.h #inclusion in libao2/.
diego
parents: 32070
diff changeset
38 #include "libvo/video_out.h" /* only for vo_pts */
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
39 #include "subopt-helper.h"
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
40
14123
a92101a7eb49 Make include paths consistent.
diego
parents: 13383
diff changeset
41 #include "mp_msg.h"
a92101a7eb49 Make include paths consistent.
diego
parents: 13383
diff changeset
42 #include "help_mp.h"
7161
13bc391fc19c mp_msg'ized
alex
parents: 6856
diff changeset
43
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
44 #ifdef CONFIG_DVB
30776
d9bbd1844876 Drop support for old-style DVB code.
diego
parents: 30664
diff changeset
45 #include <poll.h>
d9bbd1844876 Drop support for old-style DVB code.
diego
parents: 30664
diff changeset
46 #include <sys/ioctl.h>
9411
arpi
parents: 9265
diff changeset
47 #include <linux/dvb/audio.h>
8594
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 7609
diff changeset
48 audio_mixer_t dvb_mixer={255,255};
00326905484b DVB-HEAD (aka. NEWSTRUCT) detection & support
arpi
parents: 7609
diff changeset
49 #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
50
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
51 #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
52 #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
53
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
54 extern int vo_mpegpes_fd;
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
55 int ao_mpegpes_fd = -1;
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
56
7164
6175f7d18f8c added needed errno.h
alex
parents: 7161
diff changeset
57 #include <errno.h>
6175f7d18f8c added needed errno.h
alex
parents: 7161
diff changeset
58
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
59 static const ao_info_t info =
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
60 {
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
61 #ifdef CONFIG_DVB
4792
c85ee559fc3d compilation fixed
arpi
parents: 4788
diff changeset
62 "DVB audio output",
c85ee559fc3d compilation fixed
arpi
parents: 4788
diff changeset
63 #else
27368
a50cc6945dfd cosmetics: typo fixes
diego
parents: 25962
diff changeset
64 "MPEG-PES audio output",
4792
c85ee559fc3d compilation fixed
arpi
parents: 4788
diff changeset
65 #endif
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
66 "mpegpes",
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
67 "A'rpi",
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
68 ""
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
69 };
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
70
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
71 LIBAO_EXTERN(mpegpes)
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
72
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
73
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
74 // to set/get/query special features/parameters
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 9411
diff changeset
75 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
76 #ifdef CONFIG_DVB
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
77 switch(cmd){
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
78 case AOCONTROL_GET_VOLUME:
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
79 if(ao_mpegpes_fd >= 0){
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
80 ((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
81 ((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
82 return CONTROL_OK;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
83 }
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
84 return CONTROL_ERROR;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
85 case AOCONTROL_SET_VOLUME:
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
86 if(ao_mpegpes_fd >= 0){
5060
485ef815e786 10l - config.h should be included...
arpi
parents: 4792
diff changeset
87 dvb_mixer.volume_left=((ao_control_vol_t*)(arg))->left*2.56;
485ef815e786 10l - config.h should be included...
arpi
parents: 4792
diff changeset
88 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
89 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
90 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
91 // printf("Setting DVB volume: %d ; %d \n",dvb_mixer.volume_left,dvb_mixer.volume_right);
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
92 if ( (ioctl(ao_mpegpes_fd, AUDIO_SET_MIXER, &dvb_mixer) < 0)){
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
93 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_CantSetMixer,
7161
13bc391fc19c mp_msg'ized
alex
parents: 6856
diff changeset
94 strerror(errno));
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
95 return CONTROL_ERROR;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
96 }
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
97 return CONTROL_OK;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
98 }
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
99 return CONTROL_ERROR;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
100 }
4792
c85ee559fc3d compilation fixed
arpi
parents: 4788
diff changeset
101 #endif
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4331
diff changeset
102 return CONTROL_UNKNOWN;
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
103 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
104
4331
ce1e3668fa2b freq fix, removed muxer delay
arpi
parents: 4305
diff changeset
105 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
106 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
107
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
108 #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
109 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
110 {
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
111 char ao_file[30];
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
112 sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card);
31793
9fdee6f96925 Avoid code duplication, use the generate file name instead of generating it twice.
reimar
parents: 31155
diff changeset
113 mp_msg(MSGT_VO,MSGL_INFO, "Opening %s\n", ao_file);
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
114 if((ao_mpegpes_fd = open(ao_file,O_RDWR|O_NONBLOCK)) < 0)
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
115 {
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
116 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
117 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
118 }
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
119 if( (ioctl(ao_mpegpes_fd, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0))
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 {
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
121 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SELECT SOURCE: %s\n", strerror(errno));
31794
543698dab5d2 Properly close file on error or uninit.
reimar
parents: 31793
diff changeset
122 goto fail;
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
123 }
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
124 if((ioctl(ao_mpegpes_fd, AUDIO_PLAY) < 0))
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
125 {
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
126 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO PLAY: %s\n", strerror(errno));
31794
543698dab5d2 Properly close file on error or uninit.
reimar
parents: 31793
diff changeset
127 goto fail;
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
128 }
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
129 if((ioctl(ao_mpegpes_fd, AUDIO_SET_AV_SYNC, true) < 0))
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
130 {
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
131 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET AV SYNC: %s\n", strerror(errno));
31794
543698dab5d2 Properly close file on error or uninit.
reimar
parents: 31793
diff changeset
132 goto fail;
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
133 }
25962
afa125da85cf typo fix: inited --> initialized
diego
parents: 25558
diff changeset
134 //FIXME: in vo_mpegpes audio was initialized as MUTEd
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
135 if((ioctl(ao_mpegpes_fd, AUDIO_SET_MUTE, false) < 0))
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
136 {
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
137 mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET MUTE: %s\n", strerror(errno));
31794
543698dab5d2 Properly close file on error or uninit.
reimar
parents: 31793
diff changeset
138 goto fail;
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 }
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
140 return ao_mpegpes_fd;
31794
543698dab5d2 Properly close file on error or uninit.
reimar
parents: 31793
diff changeset
141 fail:
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
142 close(ao_mpegpes_fd);
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
143 ao_mpegpes_fd = -1;
31794
543698dab5d2 Properly close file on error or uninit.
reimar
parents: 31793
diff changeset
144 return -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
145 }
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
146 #endif
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
147
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
148 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
149 {
25558
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
150 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
151 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
152
29586
2eff450157cd The suboption parser now takes a const options list, so mark them all const.
reimar
parents: 29263
diff changeset
153 const opt_t subopts[] = {
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
154 {"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
155 {"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
156 {NULL}
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
157 };
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
158
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
159 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
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 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
162 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
163 }
25558
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
164 if(card==-1)
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
165 {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
166 //search the first usable card
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
167 int n;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
168 char file[30];
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
169 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
170 {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
171 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
172 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
173 {
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
174 card = n+1;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
175 break;
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
176 }
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
177 }
634dfaa85718 when :card isn't specified by the user search the first available card
nicodvb
parents: 24522
diff changeset
178 }
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
179 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
180 {
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
181 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
182 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
183 }
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
184 card--;
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
185
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
186 #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
187 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
188 return init_device(card);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28823
diff changeset
189 #else
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
190 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
191 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
192 #endif
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
193
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
194 ao_mpegpes_fd = open(ao_file, O_WRONLY | O_CREAT, 0666);
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
195 if(ao_mpegpes_fd < 0)
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
196 {
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
197 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
198 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
199 }
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
200 return ao_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
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
30664
d21d50b4b9ce Mark data argument of my_ao_write() function as const.
diego
parents: 30513
diff changeset
203 static int my_ao_write(const unsigned char* data,int len){
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
204 int orig_len = len;
27430
8bc08d1b115d 100l: Rename missed preprocessor directives from a HAVE_ prefix to CONFIG_.
diego
parents: 27369
diff changeset
205 #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
206 #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
207 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
208
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
209 pfd[0].fd = ao_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
210 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
211
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
212 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
213 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
214 if(pfd[0].revents & POLLOUT){
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
215 int ret = write(ao_mpegpes_fd, data, len);
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
216 if(ret<=0){
19362
3a998ae2f952 replace calls to perror() with calls to mp_msg()
ivo
parents: 19222
diff changeset
217 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
218 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
219 } else {
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
220 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
221 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
222 }
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
223 } 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
224 }
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
225 }
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
226
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
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
228 if(ao_mpegpes_fd < 0) return 0; // no file
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
229 write(ao_mpegpes_fd, data, len); // write to file
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
230 #endif
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
231 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
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
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
235 // open & setup audio device
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
236 // return: 1=success 0=fail
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
237 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
238 if(preinit(NULL)<0) return 0;
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
239
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
240 ao_data.channels=2;
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2708
diff changeset
241 ao_data.outburst=2000;
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
242 switch(format){
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
243 case AF_FORMAT_S16_BE:
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
244 case AF_FORMAT_MPEG2:
30241
02b9c1a452e1 Add support for distinguishing between little- and big-endian SPDIF AC3
reimar
parents: 29586
diff changeset
245 case AF_FORMAT_AC3_BE:
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
246 ao_data.format=format;
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
247 break;
30241
02b9c1a452e1 Add support for distinguishing between little- and big-endian SPDIF AC3
reimar
parents: 29586
diff changeset
248 case AF_FORMAT_AC3_LE:
02b9c1a452e1 Add support for distinguishing between little- and big-endian SPDIF AC3
reimar
parents: 29586
diff changeset
249 ao_data.format=AF_FORMAT_AC3_BE;
02b9c1a452e1 Add support for distinguishing between little- and big-endian SPDIF AC3
reimar
parents: 29586
diff changeset
250 break;
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
251 default:
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
252 ao_data.format=AF_FORMAT_S16_BE;
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
253 }
24356
44984ad9f6c3 warning fix:
diego
parents: 19362
diff changeset
254
4300
4ebab79785b7 passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents: 3095
diff changeset
255 switch(rate){
4ebab79785b7 passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents: 3095
diff changeset
256 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
257 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
258 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
259 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
260 default:
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
261 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate);
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
262 #if 0
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
263 if(rate>48000) rate=96000; else
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
264 if(rate>44100) rate=48000; else
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
265 if(rate>32000) rate=44100; else
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
266 rate=32000;
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
267 goto retry;
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
268 #else
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
269 rate=48000; freq_id=0;
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
270 #endif
4300
4ebab79785b7 passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents: 3095
diff changeset
271 }
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
272
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
273 ao_data.bps=rate*2*2;
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
274 freq=ao_data.samplerate=rate;
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
275
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
276 return 1;
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
277 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
278
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
279 // close audio device
12145
99798c3cdb93 uninit immed flag
alex
parents: 9633
diff changeset
280 static void uninit(int immed){
32070
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
281 if (ao_mpegpes_fd >= 0)
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
282 close(ao_mpegpes_fd);
acb0f1b02040 Rename vo_mpegpes_fd2 variable to ao_mpegpes_fd.
diego
parents: 31997
diff changeset
283 ao_mpegpes_fd = -1;
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
284 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
285
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
286 // stop playing and empty buffers (for seeking/pause)
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 14245
diff changeset
287 static void reset(void){
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
288
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
289 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
290
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
291 // stop playing, keep buffers (for pause)
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 14245
diff changeset
292 static void audio_pause(void)
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
293 {
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
294 // for now, just call reset();
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
295 reset();
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
296 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
297
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
298 // resume playing, after audio_pause()
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 14245
diff changeset
299 static void audio_resume(void)
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
300 {
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
301 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
302
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
303 // return: how many bytes can be played without blocking
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 14245
diff changeset
304 static int get_space(void){
4331
ce1e3668fa2b freq fix, removed muxer delay
arpi
parents: 4305
diff changeset
305 float x=(float)(vo_pts-ao_data.pts)/90000.0;
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
306 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
307 //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
308 if(vo_mpegpes_fd < 0) return 32000; //not using -vo mpegpes
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
309 // printf("vo_pts: %5.3f ao_pts: %5.3f\n",vo_pts/90000.0,ao_data.pts/90000.0);
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
310 if(x<=0) return 0;
4331
ce1e3668fa2b freq fix, removed muxer delay
arpi
parents: 4305
diff changeset
311 y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst;
ce1e3668fa2b freq fix, removed muxer delay
arpi
parents: 4305
diff changeset
312 if(y>32000) y=32000;
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
313 // printf("diff: %5.3f -> %d \n",x,y);
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
314 return y;
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
315 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
316
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
317 // plays 'len' bytes of 'data'
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
318 // it should round it down to outburst*n
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
319 // return: number of bytes played
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
320 static int play(void* data,int len,int flags){
7607
8d73a0292932 - init fails if no -vo mpegpes
arpi
parents: 7472
diff changeset
321 // printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id);
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 14123
diff changeset
322 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
323 send_mpeg_pes_packet (data, len, 0x1C0, ao_data.pts, 1, my_ao_write);
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
324 else {
4300
4ebab79785b7 passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents: 3095
diff changeset
325 // if(len>2000) len=2000;
4305
624c73ec1c54 10l, debug printf removed
arpi
parents: 4300
diff changeset
326 // printf("ao_mpegpes: len=%d \n",len);
19184
3f2de7ba8aa0 split the incestous intercourse between ao_mpegpes and vo_mpegpes; now the devices can be used separately
nicodvb
parents: 17566
diff changeset
327 send_mpeg_lpcm_packet(data, len, 0xA0, ao_data.pts, freq_id, my_ao_write);
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
328 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
329 return len;
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
330 }
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
331
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2708
diff changeset
332 // 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
333 static float get_delay(void){
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
334
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2708
diff changeset
335 return 0.0;
2708
b24661a9924e ao_mpegpes
arpi
parents:
diff changeset
336 }