84
97
static int freq_id=0;
100
static int init_device(int card)
103
#ifndef HAVE_DVB_HEAD
104
mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/ost/audio\n");
105
sprintf(ao_file, "/dev/ost/audio");
107
mp_msg(MSGT_VO,MSGL_INFO, "Opening /dev/dvb/adapter%d/audio0\n", card);
108
sprintf(ao_file, "/dev/dvb/adapter%d/audio0", card);
110
if((vo_mpegpes_fd2 = open(ao_file,O_RDWR|O_NONBLOCK)) < 0)
112
mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO DEVICE: %s\n", strerror(errno));
115
if( (ioctl(vo_mpegpes_fd2,AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY) < 0))
117
mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SELECT SOURCE: %s\n", strerror(errno));
120
if((ioctl(vo_mpegpes_fd2,AUDIO_PLAY) < 0))
122
mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO PLAY: %s\n", strerror(errno));
125
if((ioctl(vo_mpegpes_fd2,AUDIO_SET_AV_SYNC, true) < 0))
127
mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET AV SYNC: %s\n", strerror(errno));
130
//FIXME: in vo_mpegpes audio was inited as MUTEd
131
if((ioctl(vo_mpegpes_fd2,AUDIO_SET_MUTE, false) < 0))
133
mp_msg(MSGT_VO, MSGL_ERR, "DVB AUDIO SET MUTE: %s\n", strerror(errno));
136
return vo_mpegpes_fd2;
140
static int preinit(const char *arg)
143
char *ao_file = NULL;
146
{"card", OPT_ARG_INT, &card, NULL},
147
{"file", OPT_ARG_MSTRZ, &ao_file, NULL},
151
if(subopt_parse(ao_subdevice, subopts) != 0)
153
mp_msg(MSGT_VO, MSGL_ERR, "AO_MPEGPES, Unrecognized options\n");
156
if((card < 1) || (card > 4))
158
mp_msg(MSGT_VO, MSGL_ERR, "DVB card number must be between 1 and 4\n");
165
return init_device(card);
168
return vo_mpegpes_fd; //video fd
171
vo_mpegpes_fd2=open(ao_file,O_WRONLY|O_CREAT,0666);
174
mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes: %s\n", strerror(errno));
177
return vo_mpegpes_fd2;
180
static int my_ao_write(unsigned char* data,int len){
184
struct pollfd pfd[NFD];
186
pfd[0].fd = vo_mpegpes_fd2;
187
pfd[0].events = POLLOUT;
191
if(pfd[0].revents & POLLOUT){
192
int ret=write(vo_mpegpes_fd2,data,len);
194
mp_msg(MSGT_VO, MSGL_ERR, "ao_mpegpes write: %s\n", strerror(errno));
205
if(vo_mpegpes_fd2<0) return 0; // no file
206
write(vo_mpegpes_fd2,data,len); // write to file
86
212
// open & setup audio device
87
213
// return: 1=success 0=fail
88
214
static int init(int rate,int channels,int format,int flags){
91
if(vo_mpegpes_fd2<0) return 0; // couldn't open audio dev
93
if(vo_mpegpes_fd<0) return 0; // no file
215
if(preinit(NULL)<0) return 0;
96
217
ao_data.channels=2;
97
218
ao_data.outburst=2000;
175
298
static int play(void* data,int len,int flags){
176
299
// printf("\nao_mpegpes: play(%d) freq=%d\n",len,freq_id);
177
300
if(ao_data.format==AF_FORMAT_MPEG2)
178
send_pes_packet(data,len,0x1C0,ao_data.pts);
301
send_mpeg_pes_packet (data, len, 0x1C0, ao_data.pts, 1, my_ao_write);
181
304
unsigned short *s=data;