Mercurial > mplayer.hg
annotate stream/tvi_v4l.c @ 34448:6dc79618ec0e
Fix directory creation in refupdate script.
author | reimar |
---|---|
date | Sun, 08 Jan 2012 15:38:22 +0000 |
parents | c15dabfa2380 |
children | 389d43c448b3 |
rev | line source |
---|---|
2802 | 1 /* |
30426
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
2 * Video 4 Linux input |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
3 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
4 * Copyright (C) 2001 Alex Beregszaszi |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
5 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
6 * Some ideas are based on xawtv/libng's grab-v4l.c written by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
7 * Gerd Knorr <kraxel@bytesex.org> |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
8 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
9 * Multithreading, a/v sync and native ALSA support by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
10 * Jindrich Makovicka <makovick@gmail.com> |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
11 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
12 * MJPEG hardware encoding support by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
13 * Ivan Szanto <szivan@freemail.hu> |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
14 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
15 * CODE IS UNDER DEVELOPMENT, NO FEATURE REQUESTS PLEASE! |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
16 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
17 * This file is part of MPlayer. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
18 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
19 * MPlayer is free software; you can redistribute it and/or modify |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
20 * it under the terms of the GNU General Public License as published by |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
21 * the Free Software Foundation; either version 2 of the License, or |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
22 * (at your option) any later version. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
23 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
24 * MPlayer is distributed in the hope that it will be useful, |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
27 * GNU General Public License for more details. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
28 * |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
29 * You should have received a copy of the GNU General Public License along |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
30 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
31 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
ce0122361a39
Add license header to all files missing it in the stream subdirectory.
diego
parents:
29809
diff
changeset
|
32 */ |
2802 | 33 |
2790 | 34 #include "config.h" |
35 | |
36 #include <stdio.h> | |
37 #include <errno.h> | |
38 #include <fcntl.h> | |
39 #include <sys/ioctl.h> | |
40 #include <sys/types.h> | |
6553
d000112bd06e
Paul Ortyl's patch - tv4l timestamps (not so precise :()
alex
parents:
6529
diff
changeset
|
41 #include <sys/time.h> |
10621
9f4af7d95d87
this small patch allows to compile the file libmpdemux/tvi_v4l.c properly,
diego
parents:
10593
diff
changeset
|
42 |
9f4af7d95d87
this small patch allows to compile the file libmpdemux/tvi_v4l.c properly,
diego
parents:
10593
diff
changeset
|
43 /* Necessary to prevent collisions between <linux/time.h> and <sys/time.h> when V4L2 is installed. */ |
9f4af7d95d87
this small patch allows to compile the file libmpdemux/tvi_v4l.c properly,
diego
parents:
10593
diff
changeset
|
44 #define _LINUX_TIME_H |
9f4af7d95d87
this small patch allows to compile the file libmpdemux/tvi_v4l.c properly,
diego
parents:
10593
diff
changeset
|
45 |
2790 | 46 #include <linux/videodev.h> |
47 #include <unistd.h> | |
48 #include <sys/mman.h> | |
2931 | 49 #include <stdlib.h> |
50 #include <string.h> | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
51 #include <pthread.h> |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
52 #ifdef HAVE_SYS_SYSINFO_H |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
53 #include <sys/sysinfo.h> |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
54 #endif |
2790 | 55 |
2830 | 56 #include "mp_msg.h" |
17012 | 57 #include "libaf/af_format.h" |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
19271
diff
changeset
|
58 #include "libmpcodecs/img_format.h" |
29759
d287e2785570
Move teletext specific code from stream into libmpcodecs.
cehoyos
parents:
29263
diff
changeset
|
59 #include "libmpcodecs/dec_teletext.h" |
17012 | 60 #include "libvo/fastmemcpy.h" |
61 #include "libvo/videodev_mjpeg.h" | |
2830 | 62 |
2790 | 63 #include "tv.h" |
64 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
65 #include "audio_in.h" |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
66 |
23883 | 67 static tvi_handle_t *tvi_init_v4l(tv_param_t* tv_param); |
22381
6cabac4d35b5
tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents:
20646
diff
changeset
|
68 |
25689 | 69 const tvi_info_t tvi_info_v4l = { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
70 tvi_init_v4l, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
71 "Video 4 Linux input", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
72 "v4l", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
73 "Alex Beregszaszi", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
74 "under development" |
2802 | 75 }; |
76 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
77 #define PAL_WIDTH 768 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
78 #define PAL_HEIGHT 576 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
79 #define PAL_FPS 25 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
80 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
81 #define NTSC_WIDTH 640 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
82 #define NTSC_HEIGHT 480 |
16273 | 83 #define NTSC_FPS (30000.0/1001.0) |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
84 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
85 #define MAX_AUDIO_CHANNELS 10 |
3815 | 86 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
87 #define VID_BUF_SIZE_IMMEDIATE 2 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
88 #define VIDEO_AVG_BUFFER_SIZE 600 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
89 |
31322
016194f71de3
Fix function pointer types in tvi_functions struct
reimar
parents:
30426
diff
changeset
|
90 typedef struct priv { |
2802 | 91 /* general */ |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
92 char *video_device; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
93 int video_fd; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
94 struct video_capability capability; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
95 struct video_channel *channels; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
96 int act_channel; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
97 struct video_tuner tuner; |
2802 | 98 |
99 /* video */ | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
100 struct video_picture picture; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
101 int format; /* output format */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
102 int width; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
103 int height; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
104 int bytesperline; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
105 float fps; |
2802 | 106 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
107 struct video_mbuf mbuf; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
108 unsigned char *mmap; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
109 struct video_mmap *buf; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
110 int nbuf; |
2802 | 111 |
112 /* audio */ | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
113 char *audio_device; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
114 audio_in_t audio_in; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
115 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
116 int audio_id; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
117 struct video_audio audio[MAX_AUDIO_CHANNELS]; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
118 int audio_channels[MAX_AUDIO_CHANNELS]; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
119 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
120 /* buffering stuff */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
121 int immediate_mode; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
122 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
123 int audio_buffer_size; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
124 int aud_skew_cnt; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
125 unsigned char *audio_ringbuffer; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
126 long long *audio_skew_buffer; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
127 volatile int audio_head; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
128 volatile int audio_tail; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
129 volatile int audio_cnt; |
8131 | 130 volatile long long audio_skew; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
131 volatile double audio_skew_factor; |
8131 | 132 volatile long long audio_skew_measure_time; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
133 volatile int audio_drop; |
6553
d000112bd06e
Paul Ortyl's patch - tv4l timestamps (not so precise :()
alex
parents:
6529
diff
changeset
|
134 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
135 int first; |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
136 int video_buffer_size_max; |
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
137 volatile int video_buffer_size_current; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
138 unsigned char **video_ringbuffer; |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
139 long long *video_timebuffer; |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
140 long long *video_avg_buffer; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
141 int video_avg_ptr; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
142 int video_interval_sum; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
143 volatile int video_head; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
144 volatile int video_tail; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
145 volatile int video_cnt; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
146 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
147 volatile int shutdown; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
148 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
149 pthread_t audio_grabber_thread; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
150 pthread_t video_grabber_thread; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
151 pthread_mutex_t audio_starter; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
152 pthread_mutex_t skew_mutex; |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
153 pthread_mutex_t video_buffer_mutex; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
154 |
8131 | 155 long long starttime; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
156 double audio_secs_per_block; |
8131 | 157 long long audio_skew_total; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
158 long audio_recv_blocks_total; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
159 long audio_sent_blocks_total; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
160 long mjpeg_bufsize; |
23926 | 161 char *vbi_dev; |
162 int vbi_fd; | |
163 int vbi_bufsize; | |
164 int vbi_shutdown; | |
165 pthread_t vbi_grabber_thread; | |
166 void *priv_vbi; | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
167 |
23883 | 168 tv_param_t *tv_param; |
2790 | 169 } priv_t; |
170 | |
171 #include "tvi_def.h" | |
172 | |
2841 | 173 static const char *device_cap2name[] = { |
2790 | 174 "capture", "tuner", "teletext", "overlay", "chromakey", "clipping", |
2802 | 175 "frameram", "scales", "monochrome", "subcapture", "mpeg-decoder", |
176 "mpeg-encoder", "mjpeg-decoder", "mjpeg-encoder", NULL | |
177 }; | |
178 | |
2841 | 179 static const char *device_palette2name[] = { |
2802 | 180 "-", "grey", "hi240", "rgb16", "rgb24", "rgb32", "rgb15", "yuv422", |
181 "yuyv", "uyvy", "yuv420", "yuv411", "raw", "yuv422p", "yuv411p", | |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
182 "yuv420p", "yuv410p" |
2802 | 183 }; |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
184 #define PALETTE(x) ((x < sizeof(device_palette2name)/sizeof(char*)) ? device_palette2name[x] : "UNKNOWN") |
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
185 |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
186 static const struct { |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
187 char* name; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
188 int normid; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
189 int tuner_flags; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
190 int tuner_mode; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
191 int input_norm; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
192 float fps; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
193 } supported_norms[]={ |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
194 {"pal", TV_NORM_PAL, VIDEO_TUNER_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, PAL_FPS }, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
195 {"ntsc", TV_NORM_NTSC, VIDEO_TUNER_NTSC, VIDEO_MODE_NTSC, VIDEO_MODE_NTSC, NTSC_FPS}, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
196 {"secam", TV_NORM_SECAM, VIDEO_TUNER_SECAM, VIDEO_MODE_SECAM,VIDEO_MODE_SECAM,PAL_FPS }, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
197 {"palnc", TV_NORM_PALNC, VIDEO_TUNER_PAL, VIDEO_MODE_PAL, 3, PAL_FPS }, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
198 {"palm", TV_NORM_PALM, VIDEO_TUNER_NTSC, VIDEO_MODE_NTSC, 4, NTSC_FPS}, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
199 {"paln", TV_NORM_PALN, VIDEO_TUNER_PAL, VIDEO_MODE_PAL, 5, PAL_FPS }, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
200 {"ntscjp",TV_NORM_NTSCJP, VIDEO_TUNER_NTSC, VIDEO_MODE_NTSC, 6, NTSC_FPS}, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
201 {"auto", -1, -1, -1, VIDEO_MODE_AUTO, -1 }, |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
202 {NULL, -1, -1, -1, -1 } |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
203 }; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
204 |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
205 static const char *norm2name(int mode) |
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
206 { |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
207 int i; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
208 for(i=0;supported_norms[i].name; i++) |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
209 if(supported_norms[i].input_norm==mode) |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
210 return supported_norms[i].name; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
211 return "unknown"; |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
212 }; |
2802 | 213 |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
214 static const char *audio_mode2name(int mode) |
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
215 { |
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
216 switch (mode) { |
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
217 case VIDEO_SOUND_MONO: |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
218 return "mono"; |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
219 case VIDEO_SOUND_STEREO: |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
220 return "stereo"; |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
221 case VIDEO_SOUND_LANG1: |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
222 return "language1"; |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
223 case VIDEO_SOUND_LANG2: |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
224 return "language2"; |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
225 default: |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
226 return "unknown"; |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
227 } |
2841 | 228 }; |
229 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
230 static void *audio_grabber(void *data); |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
231 static void *video_grabber(void *data); |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
232 |
2802 | 233 static int palette2depth(int palette) |
234 { | |
2810 | 235 switch(palette) |
236 { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
237 /* component */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
238 case VIDEO_PALETTE_RGB555: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
239 return 15; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
240 case VIDEO_PALETTE_RGB565: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
241 return 16; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
242 case VIDEO_PALETTE_RGB24: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
243 return 24; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
244 case VIDEO_PALETTE_RGB32: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
245 return 32; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
246 /* planar */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
247 case VIDEO_PALETTE_YUV411P: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
248 case VIDEO_PALETTE_YUV420P: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
249 case VIDEO_PALETTE_YUV410P: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
250 return 12; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
251 /* packed */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
252 case VIDEO_PALETTE_YUV422P: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
253 case VIDEO_PALETTE_YUV422: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
254 case VIDEO_PALETTE_YUYV: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
255 case VIDEO_PALETTE_UYVY: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
256 case VIDEO_PALETTE_YUV420: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
257 case VIDEO_PALETTE_YUV411: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
258 return 16; |
2810 | 259 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
260 return -1; |
2802 | 261 } |
262 | |
263 static int format2palette(int format) | |
264 { | |
2810 | 265 switch(format) |
266 { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
267 case IMGFMT_BGR15: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
268 return VIDEO_PALETTE_RGB555; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
269 case IMGFMT_BGR16: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
270 return VIDEO_PALETTE_RGB565; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
271 case IMGFMT_BGR24: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
272 return VIDEO_PALETTE_RGB24; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
273 case IMGFMT_BGR32: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
274 return VIDEO_PALETTE_RGB32; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
275 case IMGFMT_YV12: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
276 case IMGFMT_I420: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
277 return VIDEO_PALETTE_YUV420P; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
278 case IMGFMT_YUY2: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
279 return VIDEO_PALETTE_YUV422; |
11656
1bd451a6d4ae
make outfmt=uyvy work with rivatv patch by Stephen Beahm
faust3
parents:
10776
diff
changeset
|
280 case IMGFMT_UYVY: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
281 return VIDEO_PALETTE_UYVY; |
2810 | 282 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
283 return -1; |
2802 | 284 } |
285 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
286 // sets and sanitizes audio buffer/block sizes |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
287 static void setup_audio_buffer_sizes(priv_t *priv) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
288 { |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
289 int bytes_per_sample = priv->audio_in.bytes_per_sample; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
290 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
291 // make the audio buffer at least 5 seconds long |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
292 priv->audio_buffer_size = 1 + 5*priv->audio_in.samplerate |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
293 *priv->audio_in.channels |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
294 *bytes_per_sample/priv->audio_in.blocksize; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
295 if (priv->audio_buffer_size < 256) priv->audio_buffer_size = 256; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
296 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
297 // make the skew buffer at least 1 second long |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
298 priv->aud_skew_cnt = 1 + 1*priv->audio_in.samplerate |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
299 *priv->audio_in.channels |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
300 *bytes_per_sample/priv->audio_in.blocksize; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
301 if (priv->aud_skew_cnt < 16) priv->aud_skew_cnt = 16; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
302 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
303 mp_msg(MSGT_TV, MSGL_V, "Audio capture - buffer %d blocks of %d bytes, skew average from %d meas.\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
304 priv->audio_buffer_size, priv->audio_in.blocksize, priv->aud_skew_cnt); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
305 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
306 |
23883 | 307 static tvi_handle_t *tvi_init_v4l(tv_param_t* tv_param) |
2790 | 308 { |
309 tvi_handle_t *h; | |
310 priv_t *priv; | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
311 |
32141
2802b8095bf7
Move TV input new_handle static function to tv.c and make it non-static.
diego
parents:
32090
diff
changeset
|
312 h = tv_new_handle(sizeof(priv_t), &functions); |
2790 | 313 if (!h) |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
314 return NULL; |
2790 | 315 |
316 priv = h->priv; | |
317 | |
2802 | 318 /* set video device name */ |
23883 | 319 if (!tv_param->device) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
320 priv->video_device = strdup("/dev/video0"); |
2790 | 321 else |
23883 | 322 priv->video_device = strdup(tv_param->device); |
3611 | 323 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
324 /* set video device name */ |
23883 | 325 if (!tv_param->adevice) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
326 priv->audio_device = NULL; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
327 else { |
23883 | 328 priv->audio_device = strdup(tv_param->adevice); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
329 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
330 |
3611 | 331 /* allocation failed */ |
332 if (!priv->video_device) { | |
32090
535ebcd085e4
Move TV input free_handle static function to tv.c and make it non-static.
diego
parents:
31834
diff
changeset
|
333 tv_free_handle(h); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
334 return NULL; |
2790 | 335 } |
336 | |
23925
f54903679ad0
10l: wrong pointer was initialized (causes crash during startup).
voroshil
parents:
23885
diff
changeset
|
337 priv->tv_param=tv_param; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
338 return h; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
339 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
340 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
341 /* retrieves info about audio channels from the BTTV */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
342 static void init_v4l_audio(priv_t *priv) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
343 { |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
344 int i; |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
345 int reqmode; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
346 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
347 if (!priv->capability.audios) return; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
348 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
349 /* audio chanlist */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
350 |
7318
85897ab199a4
changed message leveles (too many non-sense info messages)
alex
parents:
7317
diff
changeset
|
351 mp_msg(MSGT_TV, MSGL_V, " Audio devices: %d\n", priv->capability.audios); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
352 |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
353 mp_msg(MSGT_TV, MSGL_V, "Video capture card reports the audio setup as follows:\n"); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
354 for (i = 0; i < priv->capability.audios; i++) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
355 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
356 if (i >= MAX_AUDIO_CHANNELS) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
357 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
358 mp_msg(MSGT_TV, MSGL_ERR, "no space for more audio channels (increase in source!) (%d > %d)\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
359 i, MAX_AUDIO_CHANNELS); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
360 i = priv->capability.audios; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
361 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
362 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
363 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
364 priv->audio[i].audio = i; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
365 if (ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
366 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
367 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
368 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
369 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
370 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
371 /* mute all channels */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
372 priv->audio[i].flags |= VIDEO_AUDIO_MUTE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
373 reqmode = -1; |
23885 | 374 if (priv->tv_param->amode >= 0) { |
375 switch (priv->tv_param->amode) { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
376 case 0: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
377 reqmode = VIDEO_SOUND_MONO; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
378 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
379 case 1: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
380 reqmode = VIDEO_SOUND_STEREO; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
381 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
382 case 2: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
383 reqmode = VIDEO_SOUND_LANG1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
384 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
385 case 3: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
386 reqmode = VIDEO_SOUND_LANG2; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
387 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
388 default: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
389 mp_msg(MSGT_TV, MSGL_ERR, "Unknown audio mode requested.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
390 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
391 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
392 if (reqmode >= 0) priv->audio[i].mode = reqmode; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
393 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
394 ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[i]); |
3815 | 395 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
396 // get the parameters back |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
397 if (ioctl(priv->video_fd, VIDIOCGAUDIO, &priv->audio[i]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
398 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
399 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
400 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
401 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
402 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
403 switch(priv->audio[i].mode) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
404 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
405 case VIDEO_SOUND_MONO: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
406 case VIDEO_SOUND_LANG1: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
407 case VIDEO_SOUND_LANG2: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
408 priv->audio_channels[i] = 1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
409 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
410 case VIDEO_SOUND_STEREO: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
411 priv->audio_channels[i] = 2; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
412 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
413 default: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
414 mp_msg(MSGT_TV, MSGL_ERR, "Card reports an unknown audio mode !\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
415 mp_msg(MSGT_TV, MSGL_ERR, "Trying two channel audio. Use forcechan to override.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
416 priv->audio_channels[i] = 2; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
417 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
418 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
419 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
420 if (reqmode >= 0 && priv->audio[i].mode != reqmode) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
421 mp_msg(MSGT_TV, MSGL_ERR, "Audio mode setup warning!\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
422 mp_msg(MSGT_TV, MSGL_ERR, "Requested mode was %s, but v4l still reports %s.\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
423 audio_mode2name(reqmode), audio_mode2name(priv->audio[i].mode)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
424 mp_msg(MSGT_TV, MSGL_ERR, "You may need \"forcechan\" option to force stereo/mono audio recording.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
425 } |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
426 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
427 /* display stuff */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
428 mp_msg(MSGT_TV, MSGL_V, " %d: %s: ", priv->audio[i].audio, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
429 priv->audio[i].name); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
430 if (priv->audio[i].flags & VIDEO_AUDIO_MUTABLE) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
431 mp_msg(MSGT_TV, MSGL_V, "muted=%s ", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
432 (priv->audio[i].flags & VIDEO_AUDIO_MUTE) ? "yes" : "no"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
433 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
434 mp_msg(MSGT_TV, MSGL_V, "vol=%d bass=%d treble=%d balance=%d mode=%s", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
435 priv->audio[i].volume, priv->audio[i].bass, priv->audio[i].treble, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
436 priv->audio[i].balance, audio_mode2name(priv->audio[i].mode)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
437 mp_msg(MSGT_TV, MSGL_V, " chan=%d\n", priv->audio_channels[i]); |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
438 |
23885 | 439 if (priv->tv_param->forcechan >= 0) |
440 priv->audio_channels[i] = priv->tv_param->forcechan; | |
7163
a193df8b275b
v4l audio fixes by Jindrich Makovicka <makovick@KMLinux.fjfi.cvut.cz>
alex
parents:
7070
diff
changeset
|
441 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
442 // we'll call VIDIOCSAUDIO again when starting capture |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
443 // let's set audio mode to requested mode again for the case |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
444 // when VIDIOCGAUDIO just cannot report the mode correctly |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
445 if (reqmode >= 0) priv->audio[i].mode = reqmode; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
446 } |
2790 | 447 } |
448 | |
11814 | 449 #if !defined(__LINUX_VIDEODEV2_H) && !defined(VIDIOC_QUERYCAP) |
10593 | 450 struct v4l2_capability |
451 { | |
452 __u8 driver[16]; /* i.e. "bttv" */ | |
453 __u8 card[32]; /* i.e. "Hauppauge WinTV" */ | |
454 __u8 bus_info[32]; /* "PCI:" + pci_dev->slot_name */ | |
455 __u32 version; /* should use KERNEL_VERSION() */ | |
456 __u32 capabilities; /* Device capabilities */ | |
457 __u32 reserved[4]; | |
458 }; | |
459 | |
460 #define VIDIOC_QUERYCAP _IOR ('V', 0, struct v4l2_capability) | |
10621
9f4af7d95d87
this small patch allows to compile the file libmpdemux/tvi_v4l.c properly,
diego
parents:
10593
diff
changeset
|
461 #endif |
10593 | 462 |
3815 | 463 static int init(priv_t *priv) |
2790 | 464 { |
465 int i; | |
466 | |
23885 | 467 if (priv->tv_param->immediate == 1) |
468 priv->tv_param->noaudio = 1; | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
469 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
470 priv->video_ringbuffer = NULL; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
471 priv->video_timebuffer = NULL; |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
472 priv->video_avg_buffer = NULL; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
473 priv->audio_ringbuffer = NULL; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
474 priv->audio_skew_buffer = NULL; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
475 |
3815 | 476 priv->video_fd = open(priv->video_device, O_RDWR); |
17366 | 477 mp_msg(MSGT_TV, MSGL_DBG2, "Video fd: %d, %p\n", priv->video_fd, |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
478 priv->video_device); |
3815 | 479 if (priv->video_fd == -1) |
2790 | 480 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
481 mp_msg(MSGT_TV, MSGL_ERR, "unable to open '%s': %s\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
482 priv->video_device, strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
483 goto err; |
2790 | 484 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
485 |
10593 | 486 /* check for v4l2 */ |
487 if (ioctl(priv->video_fd, VIDIOC_QUERYCAP, &priv->capability) == 0) { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
488 mp_msg(MSGT_TV, MSGL_ERR, "=================================================================\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
489 mp_msg(MSGT_TV, MSGL_ERR, " WARNING: YOU ARE USING V4L DEMUXER WITH V4L2 DRIVERS!!!\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
490 mp_msg(MSGT_TV, MSGL_ERR, " As the V4L1 compatibility layer is broken, this may not work.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
491 mp_msg(MSGT_TV, MSGL_ERR, " If you encounter any problems, use driver=v4l2 instead.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
492 mp_msg(MSGT_TV, MSGL_ERR, " Bugreports on driver=v4l with v4l2 drivers will be ignored.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
493 mp_msg(MSGT_TV, MSGL_ERR, "=================================================================\n"); |
10593 | 494 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
495 |
2802 | 496 /* get capabilities (priv->capability is needed!) */ |
3815 | 497 if (ioctl(priv->video_fd, VIDIOCGCAP, &priv->capability) == -1) |
2790 | 498 { |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31322
diff
changeset
|
499 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get capabilities failed: %s\n", strerror(errno)); |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
500 goto err; |
2790 | 501 } |
502 | |
3815 | 503 fcntl(priv->video_fd, F_SETFD, FD_CLOEXEC); |
2802 | 504 |
2818 | 505 mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.name); |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31322
diff
changeset
|
506 mp_msg(MSGT_TV, MSGL_INFO, " Capabilities: "); |
2841 | 507 for (i = 0; device_cap2name[i] != NULL; i++) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
508 if (priv->capability.type & (1 << i)) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
509 mp_msg(MSGT_TV, MSGL_INFO, "%s ", device_cap2name[i]); |
2818 | 510 mp_msg(MSGT_TV, MSGL_INFO, "\n"); |
511 mp_msg(MSGT_TV, MSGL_INFO, " Device type: %d\n", priv->capability.type); | |
512 mp_msg(MSGT_TV, MSGL_INFO, " Supported sizes: %dx%d => %dx%d\n", | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
513 priv->capability.minwidth, priv->capability.minheight, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
514 priv->capability.maxwidth, priv->capability.maxheight); |
2790 | 515 priv->width = priv->capability.minwidth; |
516 priv->height = priv->capability.minheight; | |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
517 |
23885 | 518 /* somewhere here could disable priv->tv_param->mjpeg, if it is not a capability */ |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
519 |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
520 /* initialize if necessary */ |
23885 | 521 if ( priv->tv_param->mjpeg ) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
522 { |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
523 struct mjpeg_params bparm; |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
524 struct mjpeg_requestbuffers breq; /* buffer requests */ |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
525 |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
526 if (ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0) |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
527 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
528 mp_msg(MSGT_TV, MSGL_ERR, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
529 " MJP: Error getting video parameters: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
530 goto err; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
531 } |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
532 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
533 mp_msg(MSGT_TV, MSGL_INFO, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
534 " MJP: previous params: x: %d, y: %d, w: %d, h: %d, decim: %d, fields: %d,\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
535 bparm.img_x, bparm.img_y, bparm.img_width, bparm.img_height, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
536 bparm.decimation, bparm.field_per_buff); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
537 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
538 mp_msg(MSGT_TV, MSGL_INFO, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
539 " MJP: HorDcm: %d, VerDcm: %d, TmpDcm: %d\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
540 bparm.HorDcm, bparm.VerDcm, bparm.TmpDcm); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
541 |
23885 | 542 bparm.input = priv->tv_param->input; /* tv */ |
543 if (!strcasecmp(priv->tv_param->norm, "pal")) | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
544 bparm.norm = 0; /* PAL */ |
23885 | 545 else if (!strcasecmp(priv->tv_param->norm, "ntsc")) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
546 bparm.norm = 1; /* NTSC */ |
23885 | 547 else if (!strcasecmp(priv->tv_param->norm, "secam")) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
548 bparm.norm = 2; /* SECAM */ |
23885 | 549 bparm.quality = priv->tv_param->quality; |
550 bparm.decimation = priv->tv_param->decimation; | |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
551 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
552 mp_msg(MSGT_TV, MSGL_INFO, " MJP: setting params to decimation: %d, quality: %d\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
553 bparm.decimation, bparm.quality); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
554 |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
555 if (ioctl(priv->video_fd, MJPIOC_S_PARAMS, &bparm) < 0) |
23149 | 556 { |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
557 mp_msg(MSGT_TV, MSGL_ERR, |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
558 " MJP: Error setting video parameters: %s\n", strerror(errno)); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
559 goto err; |
23149 | 560 } |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
561 |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
562 if (ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0) |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
563 { |
23149 | 564 mp_msg(MSGT_TV, MSGL_ERR, |
565 " MJP: Error getting video parameters: %s\n", strerror(errno)); | |
566 goto err; | |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
567 } |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
568 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
569 mp_msg(MSGT_TV, MSGL_INFO, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
570 " MJP: current params: x: %d, y: %d, w: %d, h: %d, decim: %d, fields: %d,\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
571 bparm.img_x, bparm.img_y, bparm.img_width, bparm.img_height, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
572 bparm.decimation, bparm.field_per_buff); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
573 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
574 mp_msg(MSGT_TV, MSGL_INFO, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
575 " MJP: HorDcm: %d, VerDcm: %d, TmpDcm: %d\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
576 bparm.HorDcm, bparm.VerDcm, bparm.TmpDcm); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
577 |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
578 |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
579 breq.count = 64; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
580 priv -> nbuf = breq.count; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
581 priv->mbuf.frames = priv -> nbuf; |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
582 priv->mjpeg_bufsize = 256*1024; |
23885 | 583 if (priv->tv_param->buffer_size >= 0) |
584 priv->mjpeg_bufsize = priv->tv_param->buffer_size*1024; | |
23142
4978352462a0
cosmetics: Fix one more stray wrongly indented line.
diego
parents:
23141
diff
changeset
|
585 breq.size = priv -> mjpeg_bufsize; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
586 if (ioctl(priv->video_fd, MJPIOC_REQBUFS,&(breq)) < 0) |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
587 { |
23149 | 588 mp_msg (MSGT_TV, MSGL_ERR, |
589 " MJP: Error requesting video buffers: %s\n", strerror(errno)); | |
590 goto err; | |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
591 } |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
592 mp_msg(MSGT_TV, MSGL_INFO, |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
593 " MJP: Got %ld buffers of size %ld KB\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
594 breq.count, breq.size/1024); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
595 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
596 priv -> mmap = mmap(0, breq.count * breq.size, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
597 PROT_READ|PROT_WRITE, MAP_SHARED, priv->video_fd, 0); |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
598 if (priv -> mmap == MAP_FAILED) |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
599 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
600 mp_msg(MSGT_TV, MSGL_INFO, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
601 " MJP: Error mapping video buffers: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
602 goto err; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
603 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
604 } |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
605 |
2818 | 606 mp_msg(MSGT_TV, MSGL_INFO, " Inputs: %d\n", priv->capability.channels); |
18885 | 607 priv->channels = calloc(priv->capability.channels, sizeof(struct video_channel)); |
3611 | 608 if (!priv->channels) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
609 goto malloc_failed; |
2790 | 610 memset(priv->channels, 0, sizeof(struct video_channel)*priv->capability.channels); |
611 for (i = 0; i < priv->capability.channels; i++) | |
612 { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
613 priv->channels[i].channel = i; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
614 if (ioctl(priv->video_fd, VIDIOCGCHAN, &priv->channels[i]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
615 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
616 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
617 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
618 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
619 mp_msg(MSGT_TV, MSGL_INFO, " %d: %s: %s%s%s%s (tuner:%d, norm:%s)\n", i, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
620 priv->channels[i].name, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
621 (priv->channels[i].flags & VIDEO_VC_TUNER) ? "tuner " : "", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
622 (priv->channels[i].flags & VIDEO_VC_AUDIO) ? "audio " : "", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
623 (priv->channels[i].flags & VIDEO_TYPE_TV) ? "tv " : "", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
624 (priv->channels[i].flags & VIDEO_TYPE_CAMERA) ? "camera " : "", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
625 priv->channels[i].tuners, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
626 norm2name(priv->channels[i].norm)); |
2802 | 627 } |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
628 priv->act_channel = 0; |
2802 | 629 |
630 if (!(priv->capability.type & VID_TYPE_CAPTURE)) | |
631 { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
632 mp_msg(MSGT_TV, MSGL_ERR, "Only grabbing supported (for overlay use another program)\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
633 goto err; |
2802 | 634 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
635 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
636 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
637 /* init v4l audio even when we don't capture */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
638 init_v4l_audio(priv); |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
639 |
23885 | 640 if (!priv->capability.audios && !priv->tv_param->force_audio) priv->tv_param->noaudio = 1; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
641 |
3815 | 642 /* audio init */ |
23885 | 643 if (!priv->tv_param->noaudio) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
644 |
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27387
diff
changeset
|
645 #ifdef CONFIG_ALSA |
23885 | 646 if (priv->tv_param->alsa) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
647 audio_in_init(&priv->audio_in, AUDIO_IN_ALSA); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
648 else |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
649 audio_in_init(&priv->audio_in, AUDIO_IN_OSS); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
650 #else |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
651 audio_in_init(&priv->audio_in, AUDIO_IN_OSS); |
3815 | 652 #endif |
653 | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
654 if (priv->audio_device) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
655 audio_in_set_device(&priv->audio_in, priv->audio_device); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
656 } |
7070
aaac9080b8a3
v4l capture update by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
arpi
parents:
7058
diff
changeset
|
657 |
23885 | 658 if (priv->tv_param->audio_id < priv->capability.audios) |
659 priv->audio_id = priv->tv_param->audio_id; | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
660 else |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
661 priv->audio_id = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
662 audio_in_set_samplerate(&priv->audio_in, 44100); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
663 if (priv->capability.audios) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
664 audio_in_set_channels(&priv->audio_in, priv->audio_channels[priv->audio_id]); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
665 } else { |
23885 | 666 if (priv->tv_param->forcechan >= 0) { |
667 audio_in_set_channels(&priv->audio_in, priv->tv_param->forcechan); | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
668 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
669 audio_in_set_channels(&priv->audio_in, 2); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
670 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
671 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
672 if (audio_in_setup(&priv->audio_in) < 0) return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
673 setup_audio_buffer_sizes(priv); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
674 } |
3815 | 675 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
676 return 1; |
2790 | 677 |
3611 | 678 malloc_failed: |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
679 free(priv->channels); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
680 free(priv->buf); |
2790 | 681 err: |
3815 | 682 if (priv->video_fd != -1) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
683 close(priv->video_fd); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
684 return 0; |
2790 | 685 } |
686 | |
2802 | 687 static int uninit(priv_t *priv) |
2790 | 688 { |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
689 unsigned long num; |
23926 | 690 |
691 priv->vbi_shutdown=1; | |
692 if(priv->vbi_grabber_thread) | |
693 pthread_join(priv->vbi_grabber_thread, NULL); | |
694 | |
695 teletext_control(priv->priv_vbi,TV_VBI_CONTROL_STOP,(void*)1); | |
696 priv->priv_vbi=NULL; | |
697 | |
698 if(priv->vbi_fd){ | |
699 close(priv->vbi_fd); | |
700 priv->vbi_fd=0; | |
701 } | |
702 | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
703 free(priv->vbi_dev); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
704 priv->vbi_dev = NULL; |
23926 | 705 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
706 priv->shutdown = 1; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
707 |
7318
85897ab199a4
changed message leveles (too many non-sense info messages)
alex
parents:
7317
diff
changeset
|
708 mp_msg(MSGT_TV, MSGL_V, "Waiting for threads to finish... "); |
23885 | 709 if (!priv->tv_param->noaudio) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
710 pthread_join(priv->audio_grabber_thread, NULL); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
711 pthread_mutex_destroy(&priv->audio_starter); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
712 pthread_mutex_destroy(&priv->skew_mutex); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
713 } |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
714 pthread_mutex_destroy(&priv->video_buffer_mutex); |
24759
cdd41bcc9603
Fix mplayer segfault when v4l driver initialization (at setting norm
voroshil
parents:
24105
diff
changeset
|
715 if(priv->video_grabber_thread) |
cdd41bcc9603
Fix mplayer segfault when v4l driver initialization (at setting norm
voroshil
parents:
24105
diff
changeset
|
716 pthread_join(priv->video_grabber_thread, NULL); |
cdd41bcc9603
Fix mplayer segfault when v4l driver initialization (at setting norm
voroshil
parents:
24105
diff
changeset
|
717 |
7318
85897ab199a4
changed message leveles (too many non-sense info messages)
alex
parents:
7317
diff
changeset
|
718 mp_msg(MSGT_TV, MSGL_V, "done\n"); |
3815 | 719 |
8703 | 720 if (priv->capability.audios) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
721 priv->audio[priv->audio_id].flags |= VIDEO_AUDIO_MUTE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
722 ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]); |
8703 | 723 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
724 |
23885 | 725 if ( priv->tv_param->mjpeg ) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
726 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
727 num = -1; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
728 if (ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0) |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
729 mp_msg(MSGT_TV, MSGL_ERR, "\n MJP: ioctl MJPIOC_QBUF_CAPT failed: %s\n", strerror(errno)); |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
730 } |
9745 | 731 else |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
732 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
733 // We need to munmap as close don't close mem mappings |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
734 if(munmap(priv->mmap,priv->mbuf.size)) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
735 mp_msg(MSGT_TV, MSGL_ERR, "Munmap failed: %s\n",strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
736 } |
9745 | 737 |
738 if(close(priv->video_fd)) | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
739 mp_msg(MSGT_TV, MSGL_ERR, "Close tv failed: %s\n",strerror(errno)); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
740 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
741 audio_in_uninit(&priv->audio_in); |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
742 |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
743 if (priv->video_ringbuffer) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
744 int i; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
745 for (i = 0; i < priv->video_buffer_size_current; i++) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
746 free(priv->video_ringbuffer[i]); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
747 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
748 free(priv->video_ringbuffer); |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
749 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
750 |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
751 free(priv->video_timebuffer); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
752 free(priv->video_avg_buffer); |
23885 | 753 if (!priv->tv_param->noaudio) { |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
754 free(priv->audio_ringbuffer); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32352
diff
changeset
|
755 free(priv->audio_skew_buffer); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
756 } |
2931 | 757 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
758 return 1; |
2790 | 759 } |
760 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
761 static int get_capture_buffer_size(priv_t *priv) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
762 { |
33644
c15dabfa2380
Do a proper calculation of free RAM to be used as V4L buffers.
iive
parents:
32511
diff
changeset
|
763 uint64_t bufsize; |
c15dabfa2380
Do a proper calculation of free RAM to be used as V4L buffers.
iive
parents:
32511
diff
changeset
|
764 int cnt; |
7905
b062996d9794
added an option for specifying the size of capture buffer
henry
parents:
7844
diff
changeset
|
765 |
23885 | 766 if (priv->tv_param->buffer_size >= 0) { |
767 bufsize = priv->tv_param->buffer_size*1024*1024; | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
768 } else { |
7905
b062996d9794
added an option for specifying the size of capture buffer
henry
parents:
7844
diff
changeset
|
769 #ifdef HAVE_SYS_SYSINFO_H |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
770 struct sysinfo si; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
771 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
772 sysinfo(&si); |
33644
c15dabfa2380
Do a proper calculation of free RAM to be used as V4L buffers.
iive
parents:
32511
diff
changeset
|
773 bufsize = (si.freeram/2)*si.mem_unit; |
c15dabfa2380
Do a proper calculation of free RAM to be used as V4L buffers.
iive
parents:
32511
diff
changeset
|
774 if (bufsize < 16*1024*1024) |
c15dabfa2380
Do a proper calculation of free RAM to be used as V4L buffers.
iive
parents:
32511
diff
changeset
|
775 #endif |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
776 bufsize = 16*1024*1024; |
7905
b062996d9794
added an option for specifying the size of capture buffer
henry
parents:
7844
diff
changeset
|
777 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
778 |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
779 cnt = bufsize/(priv->height*priv->bytesperline); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
780 if (cnt < 2) cnt = 2; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
781 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
782 return cnt; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
783 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
784 |
23926 | 785 static int vbi_init(priv_t* priv,char* device) |
786 { | |
787 int vbi_fd=0; | |
788 struct video_capability cap; | |
789 | |
790 if(!device) | |
791 return TVI_CONTROL_FALSE; | |
792 | |
793 priv->vbi_dev=strdup(device); | |
794 | |
795 vbi_fd=open(priv->vbi_dev,O_RDWR); | |
796 if(vbi_fd<0){ | |
797 mp_msg(MSGT_TV,MSGL_ERR,"vbi: could not open device %s\n",priv->vbi_dev); | |
798 return TVI_CONTROL_FALSE; | |
799 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27390
diff
changeset
|
800 |
23926 | 801 if(ioctl(vbi_fd,VIDIOCGCAP,&cap)<0){ |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31322
diff
changeset
|
802 mp_msg(MSGT_TV,MSGL_ERR,"vbi: Query capabilities failed for %s\n",priv->vbi_dev); |
23926 | 803 close(vbi_fd); |
804 return TVI_CONTROL_FALSE; | |
805 } | |
806 if(!cap.type & VID_TYPE_CAPTURE){ | |
807 mp_msg(MSGT_TV,MSGL_ERR,"vbi: %s is not capture device\n",priv->vbi_dev); | |
808 close(vbi_fd); | |
809 return TVI_CONTROL_FALSE; | |
810 } | |
811 | |
812 priv->vbi_fd=vbi_fd; | |
813 mp_msg(MSGT_TV,MSGL_DBG3,"vbi: init ok\n"); | |
814 return TVI_CONTROL_TRUE; | |
815 } | |
816 | |
817 static int vbi_get_props(priv_t* priv,tt_stream_props* ptsp) | |
818 { | |
819 struct vbi_format fmt; | |
820 int res; | |
821 if(!priv || !ptsp) | |
822 return TVI_CONTROL_FALSE; | |
823 | |
824 memset(&fmt,0,sizeof(struct vbi_format)); | |
825 if((res=ioctl(priv->vbi_fd,VIDIOCGVBIFMT,&fmt))<0){ | |
826 mp_msg(MSGT_TV,MSGL_ERR,"vbi_get_props: Query format failed: %x\n",res); | |
827 return TVI_CONTROL_FALSE; | |
828 } | |
829 | |
830 ptsp->interlaced=(fmt.flags& VBI_INTERLACED?1:0); | |
831 if(fmt.start[1]>0 && fmt.count[1]){ | |
832 if(fmt.start[1]>=286) | |
833 //625 | |
834 ptsp->offset=10.2e-6*fmt.sampling_rate; | |
835 else | |
836 //525 | |
837 ptsp->offset=9.2e-6*fmt.sampling_rate; | |
838 }else | |
839 ptsp->offset=9.7e-6*fmt.sampling_rate; | |
840 | |
841 ptsp->sampling_rate=fmt.sampling_rate; | |
842 ptsp->samples_per_line=fmt.samples_per_line, | |
843 | |
844 ptsp->count[0]=fmt.count[0]; | |
845 ptsp->count[1]=fmt.count[1]; | |
846 ptsp->bufsize = ptsp->samples_per_line * (ptsp->count[0] + ptsp->count[1]); | |
847 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27390
diff
changeset
|
848 mp_msg(MSGT_TV,MSGL_V,"vbi_get_props: sampling_rate=%d,offset:%d,samples_per_line: %d\n interlaced:%s, count=[%d,%d]\n", |
23926 | 849 ptsp->sampling_rate, |
850 ptsp->offset, | |
851 ptsp->samples_per_line, | |
852 ptsp->interlaced?"Yes":"No", | |
853 ptsp->count[0], | |
854 ptsp->count[1]); | |
855 | |
856 return TVI_CONTROL_TRUE; | |
857 } | |
858 | |
859 static void *vbi_grabber(void *data) | |
860 { | |
861 priv_t *priv = (priv_t *) data; | |
862 int bytes,seq,prev_seq; | |
863 unsigned char* buf; | |
864 tt_stream_props tsp; | |
865 | |
866 if(!priv->priv_vbi){ | |
867 mp_msg(MSGT_TV,MSGL_WARN,"vbi: vbi not initialized. stopping thread.\n"); | |
868 return NULL; | |
869 } | |
870 | |
871 if(vbi_get_props(priv,&tsp)!=TVI_CONTROL_TRUE) | |
872 return NULL; | |
873 | |
874 buf=malloc(tsp.bufsize); | |
875 seq=0; | |
876 prev_seq=0; | |
877 mp_msg(MSGT_TV,MSGL_V,"vbi: vbi capture thread started.\n"); | |
878 | |
879 while (!priv->vbi_shutdown){ | |
880 bytes=read(priv->vbi_fd,buf,tsp.bufsize); | |
24763
5d7f6e5e0847
After receiving EINTR 'read' syscall should be restarted.
voroshil
parents:
24759
diff
changeset
|
881 if(bytes<0 && errno==EINTR) |
5d7f6e5e0847
After receiving EINTR 'read' syscall should be restarted.
voroshil
parents:
24759
diff
changeset
|
882 continue; |
23926 | 883 if (bytes!=tsp.bufsize){ |
884 mp_msg(MSGT_TV,MSGL_WARN,"vbi: expecting bytes: %d, got: %d",tsp.bufsize,bytes); | |
885 break; | |
886 } | |
887 seq=*(int*)(buf+bytes-4); | |
888 if(seq<=1) continue; | |
889 if (prev_seq && seq!=prev_seq+1){ | |
890 prev_seq=0; | |
891 seq=0; | |
892 } | |
893 prev_seq=seq; | |
894 teletext_control(priv->priv_vbi,TV_VBI_CONTROL_DECODE_PAGE,&buf); | |
895 mp_msg(MSGT_TV,MSGL_DBG3,"grabber: seq:%d\n",seq); | |
896 } | |
897 free(buf); | |
898 return NULL; | |
899 } | |
900 | |
2802 | 901 static int start(priv_t *priv) |
2790 | 902 { |
2802 | 903 int i; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
904 int bytes_per_sample; |
23354 | 905 struct video_window win; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
906 |
3815 | 907 if (ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1) |
2790 | 908 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
909 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
910 return 0; |
2790 | 911 } |
912 | |
2802 | 913 priv->picture.palette = format2palette(priv->format); |
914 priv->picture.depth = palette2depth(priv->picture.palette); | |
3815 | 915 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
916 if (priv->format != IMGFMT_BGR15) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
917 priv->bytesperline = priv->width * priv->picture.depth / 8; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
918 } else { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
919 priv->bytesperline = priv->width * 2; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
920 } |
3815 | 921 |
7318
85897ab199a4
changed message leveles (too many non-sense info messages)
alex
parents:
7317
diff
changeset
|
922 mp_msg(MSGT_TV, MSGL_V, "Picture values:\n"); |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
923 mp_msg(MSGT_TV, MSGL_V, " Depth: %d, Palette: %s (Format: %s)\n", priv->picture.depth, |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
924 PALETTE(priv->picture.palette), vo_format_name(priv->format)); |
7318
85897ab199a4
changed message leveles (too many non-sense info messages)
alex
parents:
7317
diff
changeset
|
925 mp_msg(MSGT_TV, MSGL_V, " Brightness: %d, Hue: %d, Colour: %d, Contrast: %d\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
926 priv->picture.brightness, priv->picture.hue, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
927 priv->picture.colour, priv->picture.contrast); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
928 |
3815 | 929 if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1) |
2790 | 930 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
931 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno)); |
23354 | 932 mp_msg(MSGT_TV, MSGL_ERR, "The 'outfmt' of '%s' is likely not supported by your card\n", |
933 vo_format_name(priv->format)); | |
934 return 0; | |
935 } | |
936 | |
937 /* Set capture size */ | |
938 win.x = 0; | |
939 win.y = 0; | |
940 win.width = priv->width; | |
941 win.height = priv->height; | |
942 win.chromakey = -1; | |
943 win.flags = 0; | |
944 win.clipcount = 0; | |
945 if (ioctl(priv->video_fd, VIDIOCSWIN, &win) == -1) | |
946 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set window failed: %s\n", strerror(errno)); | |
947 | |
23885 | 948 if ( !priv->tv_param->mjpeg ) |
23354 | 949 { |
950 /* map grab buffer */ | |
951 if (ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1) | |
952 { | |
953 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno)); | |
954 return 0; | |
955 } | |
956 | |
957 mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n", | |
958 priv->mbuf.size, priv->mbuf.frames); | |
959 priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE, | |
960 MAP_SHARED, priv->video_fd, 0); | |
961 if (priv->mmap == (unsigned char *)-1) | |
962 { | |
963 mp_msg(MSGT_TV, MSGL_ERR, "Unable to map memory for buffers: %s\n", strerror(errno)); | |
964 return 0; | |
965 } | |
966 mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap); | |
967 | |
968 /* num of buffers */ | |
969 priv->nbuf = priv->mbuf.frames; | |
970 | |
971 /* video buffers */ | |
972 priv->buf = calloc(priv->nbuf, sizeof(struct video_mmap)); | |
973 if (!priv->buf) | |
974 return 0; | |
975 memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap)); | |
2790 | 976 } |
977 | |
23885 | 978 if ( !priv->tv_param->mjpeg ) |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
979 { |
23149 | 980 priv->nbuf = priv->mbuf.frames; |
981 for (i=0; i < priv->nbuf; i++) | |
982 { | |
983 priv->buf[i].format = priv->picture.palette; | |
984 priv->buf[i].frame = i; | |
985 priv->buf[i].width = priv->width; | |
986 priv->buf[i].height = priv->height; | |
987 mp_msg(MSGT_TV, MSGL_DBG2, "buffer: %d => %p\n", i, &priv->buf[i]); | |
988 } | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
989 } |
2837 | 990 |
2931 | 991 #if 0 |
992 { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
993 struct video_play_mode pmode; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
994 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
995 pmode.mode = VID_PLAY_NORMAL; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
996 pmode.p1 = 1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
997 pmode.p2 = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
998 if (ioctl(priv->video_fd, VIDIOCSPLAYMODE, &pmode) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
999 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1000 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set play mode failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1001 // return 0; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1002 } |
2931 | 1003 } |
1004 #endif | |
2837 | 1005 |
1006 #if 0 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1007 // initialize video capture |
3815 | 1008 if (ioctl(priv->video_fd, VIDIOCCAPTURE, &one) == -1) |
2802 | 1009 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1010 mp_msg(MSGT_TV, MSGL_ERR, "FATAL: ioctl ccapture failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1011 return 0; |
2802 | 1012 } |
2837 | 1013 #endif |
1014 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1015 /* setup audio parameters */ |
23885 | 1016 if (!priv->tv_param->noaudio) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1017 setup_audio_buffer_sizes(priv); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1018 bytes_per_sample = priv->audio_in.bytes_per_sample; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1019 priv->audio_skew_buffer = calloc(priv->aud_skew_cnt, sizeof(long long)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1020 if (!priv->audio_skew_buffer) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1021 mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate skew buffer: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1022 return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1023 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1024 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1025 priv->audio_ringbuffer = calloc(priv->audio_in.blocksize, priv->audio_buffer_size); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1026 if (!priv->audio_ringbuffer) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1027 mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate audio buffer: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1028 return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1029 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1030 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1031 priv->audio_secs_per_block = (double)priv->audio_in.blocksize/(priv->audio_in.samplerate |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1032 *priv->audio_in.channels |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1033 *bytes_per_sample); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1034 priv->audio_head = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1035 priv->audio_tail = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1036 priv->audio_cnt = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1037 priv->audio_drop = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1038 priv->audio_skew = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1039 priv->audio_skew_total = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1040 priv->audio_recv_blocks_total = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1041 priv->audio_sent_blocks_total = 0; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1042 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1043 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1044 /* setup video parameters */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1045 if (priv->immediate_mode) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1046 priv->video_buffer_size_max = VID_BUF_SIZE_IMMEDIATE; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1047 } else { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1048 priv->video_buffer_size_max = get_capture_buffer_size(priv); |
6553
d000112bd06e
Paul Ortyl's patch - tv4l timestamps (not so precise :()
alex
parents:
6529
diff
changeset
|
1049 } |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1050 priv->video_buffer_size_current = 0; |
6553
d000112bd06e
Paul Ortyl's patch - tv4l timestamps (not so precise :()
alex
parents:
6529
diff
changeset
|
1051 |
23885 | 1052 if (!priv->tv_param->noaudio) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1053 if (priv->video_buffer_size_max < 3.0*priv->fps*priv->audio_secs_per_block) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1054 mp_msg(MSGT_TV, MSGL_ERR, "Video buffer shorter than 3 times audio frame duration.\n" |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1055 "You will probably experience heavy framedrops.\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1056 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1057 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1058 |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1059 mp_msg(MSGT_TV, MSGL_V, "Using a ring buffer for maximum %d frames, %d MB total size.\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1060 priv->video_buffer_size_max, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1061 priv->video_buffer_size_max*priv->height*priv->bytesperline/(1024*1024)); |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
1062 |
18885 | 1063 priv->video_ringbuffer = calloc(priv->video_buffer_size_max, sizeof(unsigned char*)); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1064 if (!priv->video_ringbuffer) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1065 mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate video buffer: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1066 return 0; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1067 } |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1068 for (i = 0; i < priv->video_buffer_size_max; i++) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1069 priv->video_ringbuffer[i] = NULL; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1070 |
18885 | 1071 priv->video_timebuffer = calloc(priv->video_buffer_size_max, sizeof(long long)); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1072 if (!priv->video_timebuffer) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1073 mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate time buffer: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1074 return 0; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1075 } |
18885 | 1076 priv->video_avg_buffer = malloc(sizeof(long long) * VIDEO_AVG_BUFFER_SIZE); |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1077 if (!priv->video_avg_buffer) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1078 mp_msg(MSGT_TV, MSGL_ERR, "cannot allocate period buffer: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1079 return 0; |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1080 } |
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1081 priv->video_interval_sum = (1e6/priv->fps)*VIDEO_AVG_BUFFER_SIZE; |
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1082 for (i = 0; i < VIDEO_AVG_BUFFER_SIZE; i++) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1083 priv->video_avg_buffer[i] = 1e6/priv->fps; |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1084 } |
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1085 |
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1086 priv->video_avg_ptr = 0; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1087 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1088 priv->video_head = 0; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1089 priv->video_tail = 0; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1090 priv->video_cnt = 0; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1091 priv->first = 1; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1092 |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
1093 if (priv->capability.audios) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1094 /* enable audio */ |
23885 | 1095 if (priv->tv_param->volume >= 0) |
1096 priv->audio[priv->audio_id].volume = priv->tv_param->volume; | |
1097 if (priv->tv_param->bass >= 0) | |
1098 priv->audio[priv->audio_id].bass = priv->tv_param->bass; | |
1099 if (priv->tv_param->treble >= 0) | |
1100 priv->audio[priv->audio_id].treble = priv->tv_param->treble; | |
1101 if (priv->tv_param->balance >= 0) | |
1102 priv->audio[priv->audio_id].balance = priv->tv_param->balance; | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1103 priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1104 mp_msg(MSGT_TV, MSGL_V, "Enabling tv audio. Requested setup is:\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1105 mp_msg(MSGT_TV, MSGL_V, "id=%d vol=%d bass=%d treble=%d balance=%d mode=%s", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1106 priv->audio_id, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1107 priv->audio[priv->audio_id].volume, priv->audio[priv->audio_id].bass, priv->audio[priv->audio_id].treble, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1108 priv->audio[priv->audio_id].balance, audio_mode2name(priv->audio[priv->audio_id].mode)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1109 mp_msg(MSGT_TV, MSGL_V, " chan=%d\n", priv->audio_channels[priv->audio_id]); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1110 ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]); |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
1111 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1112 |
23926 | 1113 /* start vbi thread */ |
1114 if(priv->priv_vbi){ | |
1115 priv->vbi_shutdown = 0; | |
1116 pthread_create(&priv->vbi_grabber_thread, NULL, vbi_grabber, priv); | |
1117 } | |
1118 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1119 /* launch capture threads */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1120 priv->shutdown = 0; |
23885 | 1121 if (!priv->tv_param->noaudio) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1122 pthread_mutex_init(&priv->audio_starter, NULL); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1123 pthread_mutex_init(&priv->skew_mutex, NULL); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1124 pthread_mutex_lock(&priv->audio_starter); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1125 pthread_create(&priv->audio_grabber_thread, NULL, audio_grabber, priv); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1126 } |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1127 pthread_mutex_init(&priv->video_buffer_mutex, NULL); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1128 /* we'll launch the video capture later, when a first request for a frame arrives */ |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1129 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1130 return 1; |
2790 | 1131 } |
1132 | |
9663 | 1133 |
2790 | 1134 static int control(priv_t *priv, int cmd, void *arg) |
1135 { | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1136 mp_msg(MSGT_TV, MSGL_DBG2, "\ndebug: control(priv=%p, cmd=%d, arg=%p)\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1137 priv, cmd, arg); |
2790 | 1138 switch(cmd) |
1139 { | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1140 /* ========== GENERIC controls =========== */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1141 case TVI_CONTROL_IS_VIDEO: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1142 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1143 if (priv->capability.type & VID_TYPE_CAPTURE) |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1144 return TVI_CONTROL_TRUE; |
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1145 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1146 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1147 case TVI_CONTROL_IS_AUDIO: |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1148 if (priv->tv_param->force_audio) return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1149 if (priv->channels[priv->act_channel].flags & VIDEO_VC_AUDIO) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1150 { |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1151 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1152 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1153 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1154 case TVI_CONTROL_IS_TUNER: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1155 { |
23149 | 1156 // if (priv->capability.type & VID_TYPE_TUNER) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1157 if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER) |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1158 return TVI_CONTROL_TRUE; |
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1159 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1160 } |
2802 | 1161 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1162 /* ========== VIDEO controls =========== */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1163 case TVI_CONTROL_VID_GET_FORMAT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1164 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1165 int output_fmt = -1; |
2802 | 1166 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1167 output_fmt = priv->format; |
23885 | 1168 if ( priv->tv_param->mjpeg ) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1169 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1170 mp_msg(MSGT_TV, MSGL_INFO, " MJP: setting sh_video->format to mjpg\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1171 output_fmt = 0x47504a4d; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1172 output_fmt = 0x67706a6d; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1173 *(int *)arg = output_fmt; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1174 mp_msg(MSGT_TV, MSGL_V, "Output format: %s\n", "mjpg"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1175 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1176 else |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1177 { |
23149 | 1178 *(int *)arg = output_fmt; |
1179 mp_msg(MSGT_TV, MSGL_V, "Output format: %s\n", vo_format_name(output_fmt)); | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1180 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1181 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1182 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1183 case TVI_CONTROL_VID_SET_FORMAT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1184 priv->format = *(int *)arg; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1185 // !HACK! v4l uses BGR format instead of RGB |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1186 // and we have to correct this. Fortunately, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1187 // tv.c reads later the format back so we |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1188 // can persuade it to use what we want. |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1189 if (IMGFMT_IS_RGB(priv->format)) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1190 priv->format &= ~IMGFMT_RGB_MASK; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1191 priv->format |= IMGFMT_BGR; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1192 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1193 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1194 case TVI_CONTROL_VID_GET_PLANES: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1195 *(int *)arg = 1; /* FIXME, also not needed at this time */ |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1196 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1197 case TVI_CONTROL_VID_GET_BITS: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1198 *(int *)arg = palette2depth(format2palette(priv->format)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1199 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1200 case TVI_CONTROL_VID_GET_WIDTH: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1201 *(int *)arg = priv->width; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1202 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1203 case TVI_CONTROL_VID_CHK_WIDTH: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1204 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1205 int req_width = *(int *)arg; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1206 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1207 mp_msg(MSGT_TV, MSGL_V, "Requested width: %d\n", req_width); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1208 if ((req_width >= priv->capability.minwidth) && |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1209 (req_width <= priv->capability.maxwidth)) |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1210 return TVI_CONTROL_TRUE; |
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1211 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1212 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1213 case TVI_CONTROL_VID_SET_WIDTH: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1214 priv->width = *(int *)arg; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1215 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1216 case TVI_CONTROL_VID_GET_HEIGHT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1217 *(int *)arg = priv->height; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1218 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1219 case TVI_CONTROL_VID_CHK_HEIGHT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1220 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1221 int req_height = *(int *)arg; |
2790 | 1222 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1223 mp_msg(MSGT_TV, MSGL_V, "Requested height: %d\n", req_height); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1224 if ((req_height >= priv->capability.minheight) && |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1225 (req_height <= priv->capability.maxheight)) |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1226 return TVI_CONTROL_TRUE; |
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1227 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1228 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1229 case TVI_CONTROL_VID_SET_HEIGHT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1230 priv->height = *(int *)arg; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1231 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1232 case TVI_CONTROL_VID_GET_PICTURE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1233 if (ioctl(priv->video_fd, VIDIOCGPICT, &priv->picture) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1234 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1235 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get picture failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1236 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1237 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1238 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1239 case TVI_CONTROL_VID_SET_PICTURE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1240 if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1241 { |
23150 | 1242 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1243 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1244 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1245 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1246 case TVI_CONTROL_VID_SET_BRIGHTNESS: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1247 priv->picture.brightness = (327*(*(int *)arg+100)) + 68; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1248 return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1249 case TVI_CONTROL_VID_SET_HUE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1250 priv->picture.hue = (327*(*(int *)arg+100)) + 68; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1251 return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1252 case TVI_CONTROL_VID_SET_SATURATION: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1253 priv->picture.colour = (327*(*(int *)arg+100)) + 68; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1254 return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1255 case TVI_CONTROL_VID_SET_CONTRAST: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1256 priv->picture.contrast = (327*(*(int *)arg+100)) + 68; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1257 return control(priv, TVI_CONTROL_VID_SET_PICTURE, 0); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1258 case TVI_CONTROL_VID_GET_BRIGHTNESS: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1259 if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1260 *(int*)arg = ((int)priv->picture.brightness-68)/327-100; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1261 return 1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1262 case TVI_CONTROL_VID_GET_HUE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1263 if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1264 *(int*)arg = ((int)priv->picture.hue-68)/327-100; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1265 return 1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1266 case TVI_CONTROL_VID_GET_SATURATION: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1267 if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1268 *(int*)arg = ((int)priv->picture.colour-68)/327-100; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1269 return 1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1270 case TVI_CONTROL_VID_GET_CONTRAST: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1271 if(!control(priv, TVI_CONTROL_VID_GET_PICTURE, 0)) return 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1272 *(int*)arg = ((int)priv->picture.contrast-68)/327-100; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1273 return 1; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1274 case TVI_CONTROL_VID_GET_FPS: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1275 *(float *)arg=priv->fps; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1276 return TVI_CONTROL_TRUE; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1277 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1278 /* ========== TUNER controls =========== */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1279 case TVI_CONTROL_TUN_GET_FREQ: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1280 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1281 unsigned long freq; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1282 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1283 if (ioctl(priv->video_fd, VIDIOCGFREQ, &freq) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1284 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1285 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get freq failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1286 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1287 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1288 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1289 /* tuner uses khz not mhz ! */ |
23149 | 1290 // if (priv->tuner.flags & VIDEO_TUNER_LOW) |
1291 // freq /= 1000; | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1292 *(unsigned long *)arg = freq; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1293 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1294 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1295 case TVI_CONTROL_TUN_SET_FREQ: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1296 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1297 /* argument is in MHz ! */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1298 unsigned long freq = *(unsigned long *)arg; |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
1299 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1300 if (priv->capability.audios) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1301 priv->audio[priv->audio_id].flags |= VIDEO_AUDIO_MUTE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1302 ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1303 } |
8485
4e32317f08be
don't give up when set_tuner fails; more zero div sanity checks
henry
parents:
8477
diff
changeset
|
1304 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1305 mp_msg(MSGT_TV, MSGL_V, "requested frequency: %.3f\n", (float)freq/16); |
7532
26cd91676fb6
complex patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7472
diff
changeset
|
1306 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1307 /* tuner uses khz not mhz ! */ |
23149 | 1308 // if (priv->tuner.flags & VIDEO_TUNER_LOW) |
1309 // freq *= 1000; | |
1310 // mp_msg(MSGT_TV, MSGL_V, " requesting from driver: freq=%.3f\n", (float)freq/16); | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1311 if (ioctl(priv->video_fd, VIDIOCSFREQ, &freq) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1312 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1313 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set freq failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1314 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1315 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1316 usleep(100000); // wait to suppress noise during switching |
2802 | 1317 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1318 if (priv->capability.audios) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1319 priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1320 ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id]); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1321 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1322 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1323 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1324 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1325 case TVI_CONTROL_TUN_GET_TUNER: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1326 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1327 if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1328 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1329 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1330 return TVI_CONTROL_FALSE; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1331 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1332 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1333 mp_msg(MSGT_TV, MSGL_V, "Tuner (%s) range: %lu -> %lu\n", priv->tuner.name, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1334 priv->tuner.rangelow, priv->tuner.rangehigh); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1335 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1336 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1337 case TVI_CONTROL_TUN_SET_TUNER: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1338 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1339 if (ioctl(priv->video_fd, VIDIOCSTUNER, &priv->tuner) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1340 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1341 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set tuner failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1342 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1343 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1344 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1345 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1346 case TVI_CONTROL_TUN_SET_NORM: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1347 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1348 int req_mode = *(int *)arg; |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1349 int norm_index; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1350 for(norm_index=0;supported_norms[norm_index].name; norm_index++) |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1351 if(req_mode==supported_norms[norm_index].normid) |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1352 break; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1353 |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1354 if(!supported_norms[norm_index].name) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1355 mp_msg(MSGT_TV, MSGL_ERR, "Unknown norm!\n"); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1356 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1357 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1358 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1359 if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1360 int prev_mode; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1361 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1362 control(priv, TVI_CONTROL_TUN_GET_TUNER, 0); |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1363 if(!(priv->tuner.flags & supported_norms[norm_index].tuner_flags)) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1364 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1365 mp_msg(MSGT_TV, MSGL_ERR, "Tuner isn't capable to set norm!\n"); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1366 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1367 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1368 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1369 prev_mode = priv->tuner.mode; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1370 |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1371 priv->tuner.mode = supported_norms[norm_index].tuner_mode; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1372 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1373 if (control(priv, TVI_CONTROL_TUN_SET_TUNER, &priv->tuner) != TVI_CONTROL_TRUE) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1374 // norm setting failed, but maybe it's only because it's fixed |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1375 if (priv->tuner.mode != prev_mode) return TVI_CONTROL_FALSE; // no it really failed |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1376 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1377 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1378 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1379 |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1380 priv->channels[priv->act_channel].norm = supported_norms[norm_index].input_norm; |
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1381 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1382 if (ioctl(priv->video_fd, VIDIOCSCHAN, &priv->channels[priv->act_channel]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1383 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1384 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1385 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1386 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1387 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1388 if (ioctl(priv->video_fd, VIDIOCGCAP, &priv->capability) == -1) { |
31834
64ba1daa147a
various spelling fixes, found by the Debian QA tool 'lintian'
siretart
parents:
31322
diff
changeset
|
1389 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get capabilities failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1390 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1391 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1392 |
24789
f6b881513502
Simplify handling SET_NORM for V4l1: replace several if-else-if and switch
voroshil
parents:
24763
diff
changeset
|
1393 priv->fps = supported_norms[norm_index].fps; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1394 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1395 if(priv->height > priv->capability.maxheight) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1396 priv->height = priv->capability.maxheight; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1397 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1398 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1399 if(priv->width > priv->capability.maxwidth) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1400 priv->width = priv->capability.maxwidth; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1401 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1402 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1403 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1404 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1405 case TVI_CONTROL_TUN_GET_NORM: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1406 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1407 *(int *)arg = priv->tuner.mode; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1408 |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1409 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1410 } |
24105
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1411 case TVI_CONTROL_TUN_GET_SIGNAL: |
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1412 { |
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1413 if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) == -1) |
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1414 { |
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1415 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get tuner failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1416 return TVI_CONTROL_FALSE; |
24105
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1417 } |
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1418 *(int*)arg=100*(priv->tuner.signal>>8)/255; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1419 return TVI_CONTROL_TRUE; |
24105
9e71e0345c35
Automatic TV channels scanning ability for MPlayer.
voroshil
parents:
23926
diff
changeset
|
1420 } |
2802 | 1421 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1422 /* ========== AUDIO controls =========== */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1423 case TVI_CONTROL_AUD_GET_FORMAT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1424 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1425 *(int *)arg = AF_FORMAT_S16_LE; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1426 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1427 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1428 case TVI_CONTROL_AUD_GET_CHANNELS: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1429 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1430 *(int *)arg = priv->audio_in.channels; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1431 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1432 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1433 case TVI_CONTROL_AUD_GET_SAMPLERATE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1434 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1435 *(int *)arg = priv->audio_in.samplerate; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1436 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1437 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1438 case TVI_CONTROL_AUD_GET_SAMPLESIZE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1439 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1440 *(int *)arg = priv->audio_in.bytes_per_sample; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1441 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1442 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1443 case TVI_CONTROL_AUD_SET_SAMPLERATE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1444 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1445 if (audio_in_set_samplerate(&priv->audio_in, *(int *)arg) < 0) return TVI_CONTROL_FALSE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1446 setup_audio_buffer_sizes(priv); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1447 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1448 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1449 /* ========== SPECIFIC controls =========== */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1450 case TVI_CONTROL_SPC_GET_INPUT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1451 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1452 int req_chan = *(int *)arg; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1453 int i; |
2802 | 1454 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1455 for (i = 0; i < priv->capability.channels; i++) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1456 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1457 if (priv->channels[i].channel == req_chan) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1458 break; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1459 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1460 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1461 priv->act_channel = i; |
2802 | 1462 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1463 if (ioctl(priv->video_fd, VIDIOCGCHAN, &priv->channels[i]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1464 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1465 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1466 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1467 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1468 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1469 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1470 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1471 case TVI_CONTROL_SPC_SET_INPUT: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1472 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1473 struct video_channel chan; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1474 int req_chan = *(int *)arg; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1475 int i; |
2802 | 1476 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1477 if (req_chan >= priv->capability.channels) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1478 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1479 mp_msg(MSGT_TV, MSGL_ERR, "Invalid input requested: %d, valid: 0-%d\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1480 req_chan, priv->capability.channels - 1); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1481 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1482 } |
2802 | 1483 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1484 for (i = 0; i < priv->capability.channels; i++) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1485 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1486 if (priv->channels[i].channel == req_chan) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1487 chan = priv->channels[i]; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1488 } |
2802 | 1489 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1490 if (ioctl(priv->video_fd, VIDIOCSCHAN, &chan) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1491 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1492 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno)); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1493 return TVI_CONTROL_FALSE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1494 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1495 mp_msg(MSGT_TV, MSGL_INFO, "Using input '%s'\n", chan.name); |
2802 | 1496 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1497 priv->act_channel = i; |
2841 | 1498 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1499 /* update tuner state */ |
23149 | 1500 // if (priv->capability.type & VID_TYPE_TUNER) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1501 if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1502 control(priv, TVI_CONTROL_TUN_GET_TUNER, 0); |
2802 | 1503 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1504 /* update local channel list */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1505 control(priv, TVI_CONTROL_SPC_GET_INPUT, &req_chan); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1506 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1507 case TVI_CONTROL_IMMEDIATE: |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1508 priv->immediate_mode = 1; |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1509 return TVI_CONTROL_TRUE; |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1510 } |
23926 | 1511 case TVI_CONTROL_VBI_INIT: |
1512 { | |
1513 void* ptr; | |
1514 tt_stream_props tsp; | |
1515 | |
1516 if (vbi_init(priv,*(char**)arg)!=TVI_CONTROL_TRUE) | |
1517 return TVI_CONTROL_FALSE; | |
1518 if(vbi_get_props(priv,&tsp)==TVI_CONTROL_TRUE) | |
1519 { | |
1520 ptr=&tsp; | |
29760
1cc8a20520e8
Add MSGT_TELETEXT, rename TVI_CONTROL as VBI_CONTROL and fix some paths
cehoyos
parents:
29759
diff
changeset
|
1521 if(teletext_control(NULL,TV_VBI_CONTROL_START,&ptr)==VBI_CONTROL_TRUE) |
23926 | 1522 priv->priv_vbi=ptr; |
1523 else | |
1524 priv->priv_vbi=NULL; | |
1525 } | |
1526 return TVI_CONTROL_TRUE; | |
1527 } | |
29806 | 1528 case TVI_CONTROL_GET_VBI_PTR: |
1529 *(void **)arg=priv->priv_vbi; | |
1530 return TVI_CONTROL_TRUE; | |
2790 | 1531 } |
1532 | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1533 return TVI_CONTROL_UNKNOWN; |
2790 | 1534 } |
1535 | |
23422 | 1536 static int set_mute(priv_t* priv,int value) |
1537 { | |
1538 if (!priv->capability.audios) { | |
1539 return 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27390
diff
changeset
|
1540 |
23422 | 1541 if(value) |
1542 priv->audio[priv->audio_id].flags |=VIDEO_AUDIO_MUTE; | |
1543 else | |
1544 priv->audio[priv->audio_id].flags &= ~VIDEO_AUDIO_MUTE; | |
1545 } | |
1546 if(ioctl(priv->video_fd, VIDIOCSAUDIO, &priv->audio[priv->audio_id])<0) | |
1547 return 0; | |
1548 return 1; | |
1549 } | |
1550 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1551 // copies a video frame |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1552 // for YV12 swaps the 2nd and 3rd plane |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1553 static inline void copy_frame(priv_t *priv, unsigned char *dest, unsigned char *source) |
2790 | 1554 { |
23885 | 1555 if(priv->tv_param->automute>0){ |
23422 | 1556 if (ioctl(priv->video_fd, VIDIOCGTUNER, &priv->tuner) >= 0) { |
23885 | 1557 if(priv->tv_param->automute<<8>priv->tuner.signal){ |
23422 | 1558 fill_blank_frame(dest,priv->bytesperline * priv->height,priv->format); |
1559 set_mute(priv,1); | |
1560 return; | |
1561 } | |
1562 } | |
1563 set_mute(priv,0); | |
1564 } | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1565 // YV12 uses VIDEO_PALETTE_YUV420P, but the planes are swapped |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1566 if (priv->format == IMGFMT_YV12) { |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23422
diff
changeset
|
1567 fast_memcpy(dest, source, priv->width * priv->height); |
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23422
diff
changeset
|
1568 fast_memcpy(dest+priv->width * priv->height*5/4, source+priv->width * priv->height, priv->width * priv->height/4); |
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23422
diff
changeset
|
1569 fast_memcpy(dest+priv->width * priv->height, source+priv->width * priv->height*5/4, priv->width * priv->height/4); |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1570 return; |
2790 | 1571 } |
3711 | 1572 |
23724 | 1573 fast_memcpy(dest, source, priv->bytesperline * priv->height); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1574 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1575 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1576 // maximum skew change, in frames |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1577 #define MAX_SKEW_DELTA 0.6 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1578 static void *video_grabber(void *data) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1579 { |
9608 | 1580 #define MAXTOL (priv->nbuf) |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1581 priv_t *priv = (priv_t*)data; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1582 struct timeval curtime; |
8131 | 1583 long long skew, prev_skew, xskew, interval, prev_interval; |
8650
cf1d4f48aecf
allow utilization of more v4l buffers, patch by Carsten Schulz <carsten@gnocchi.dialup.fu-berlin.de>
henry
parents:
8627
diff
changeset
|
1584 int frame; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1585 int i; |
7803
172ee2b4612f
Stop grabbing from v4l when paused by Jindrich Makovicka
alex
parents:
7585
diff
changeset
|
1586 int framecount; |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1587 int tolerance; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1588 unsigned long num; |
3711 | 1589 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1590 /* start the capture process */ |
8650
cf1d4f48aecf
allow utilization of more v4l buffers, patch by Carsten Schulz <carsten@gnocchi.dialup.fu-berlin.de>
henry
parents:
8627
diff
changeset
|
1591 |
23885 | 1592 if ( priv->tv_param->mjpeg ) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1593 { |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1594 mp_msg(MSGT_TV, MSGL_INFO, " MJP: gonna capture ! \n"); |
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1595 for (i=0; i < priv->nbuf; i++) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1596 num = i; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1597 if (ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1598 mp_msg(MSGT_TV, MSGL_ERR, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1599 "\n MJP: ioctl MJPIOC_QBUF_CAPT b failed: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1600 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1601 } |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1602 else |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1603 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1604 for (i=0; i < priv->nbuf; i++) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1605 if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[i]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1606 mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1607 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1608 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1609 |
9608 | 1610 gettimeofday(&curtime, NULL); |
1611 priv->starttime = (long long)1e6*curtime.tv_sec + curtime.tv_usec; | |
1612 priv->audio_skew_measure_time = 0; | |
1613 pthread_mutex_unlock(&priv->audio_starter); | |
1614 xskew = 0; | |
1615 skew = 0; | |
1616 interval = 0; | |
1617 | |
8131 | 1618 prev_interval = 0; |
1619 prev_skew = 0; | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1620 |
9608 | 1621 tolerance = MAXTOL; |
9607
e2eaeb3cb089
correct small framerate fluctuations directly in the capture thread
henry
parents:
9216
diff
changeset
|
1622 |
7803
172ee2b4612f
Stop grabbing from v4l when paused by Jindrich Makovicka
alex
parents:
7585
diff
changeset
|
1623 for (framecount = 0; !priv->shutdown;) |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1624 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1625 for (i = 0; i < priv->nbuf && !priv->shutdown; i++, framecount++) { |
7585
cfd6a99021ac
some cleanups for video_grabber() which fix a race condition by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
alex
parents:
7532
diff
changeset
|
1626 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1627 if (priv->immediate_mode) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1628 while (priv->video_cnt == priv->video_buffer_size_max) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1629 usleep(10000); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1630 if (priv->shutdown) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1631 return NULL; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1632 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1633 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1634 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1635 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1636 frame = i; |
2931 | 1637 |
23885 | 1638 if ( priv->tv_param->mjpeg ) |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1639 { |
23149 | 1640 while (ioctl(priv->video_fd, MJPIOC_SYNC, &priv->buf[frame].frame) < 0 && |
1641 (errno == EAGAIN || errno == EINTR)); | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1642 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1643 else |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1644 { |
23149 | 1645 while (ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[frame].frame) < 0 && |
1646 (errno == EAGAIN || errno == EINTR)); | |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1647 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1648 mp_dbg(MSGT_TV, MSGL_DBG3, "\npicture sync failed\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1649 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1650 gettimeofday(&curtime, NULL); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1651 if (!priv->immediate_mode) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1652 interval = (long long)1e6*curtime.tv_sec + curtime.tv_usec - priv->starttime; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1653 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1654 interval = (long long)1e6*framecount/priv->fps; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1655 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1656 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1657 if (!priv->immediate_mode) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1658 long long period, orig_interval; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1659 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1660 if (tolerance == 0) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1661 if (interval - prev_interval == 0) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1662 mp_msg(MSGT_TV, MSGL_V, "\nvideo capture thread: frame delta = 0\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1663 } else if ((interval - prev_interval < (long long)0.85e6/priv->fps) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1664 || (interval - prev_interval > (long long)1.15e6/priv->fps) ) { |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
32141
diff
changeset
|
1665 mp_msg(MSGT_TV, MSGL_V, "\nvideo capture thread: frame delta ~ %.1f fps\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1666 (double)1e6/(interval - prev_interval)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1667 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1668 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1669 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1670 // correct the rate fluctuations on a small scale |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1671 orig_interval = interval; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1672 period = priv->video_interval_sum/VIDEO_AVG_BUFFER_SIZE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1673 if (interval - prev_interval > 105*period/100) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1674 if (tolerance > 0) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1675 mp_msg(MSGT_TV, MSGL_DBG3, "correcting timestamp\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1676 interval = prev_interval + priv->video_interval_sum/VIDEO_AVG_BUFFER_SIZE; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1677 tolerance--; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1678 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1679 mp_msg(MSGT_TV, MSGL_DBG3, "bad - frames were dropped\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1680 tolerance = MAXTOL; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1681 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1682 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1683 if (tolerance < MAXTOL) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1684 mp_msg(MSGT_TV, MSGL_DBG3, "fluctuation overcome\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1685 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1686 tolerance = MAXTOL; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1687 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1688 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1689 priv->video_interval_sum -= priv->video_avg_buffer[priv->video_avg_ptr]; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1690 priv->video_avg_buffer[priv->video_avg_ptr++] = orig_interval-prev_interval; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1691 priv->video_interval_sum += orig_interval-prev_interval; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1692 if (priv->video_avg_ptr >= VIDEO_AVG_BUFFER_SIZE) priv->video_avg_ptr = 0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1693 |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
32141
diff
changeset
|
1694 // fprintf(stderr, "fps: %f\n", (double)1e6*VIDEO_AVG_BUFFER_SIZE/priv->video_interval_sum); |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1695 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1696 // interpolate the skew in time |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1697 pthread_mutex_lock(&priv->skew_mutex); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1698 xskew = priv->audio_skew + (interval - priv->audio_skew_measure_time)*priv->audio_skew_factor; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1699 pthread_mutex_unlock(&priv->skew_mutex); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1700 // correct extreme skew changes to avoid (especially) moving backwards in time |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1701 if (xskew - prev_skew > (interval - prev_interval)*MAX_SKEW_DELTA) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1702 skew = prev_skew + (interval - prev_interval)*MAX_SKEW_DELTA; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1703 } else if (xskew - prev_skew < -(interval - prev_interval)*MAX_SKEW_DELTA) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1704 skew = prev_skew - (interval - prev_interval)*MAX_SKEW_DELTA; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1705 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1706 skew = xskew; |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1707 } |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1708 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1709 |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
32141
diff
changeset
|
1710 mp_msg(MSGT_TV, MSGL_DBG3, "\nfps = %f, interval = %f, a_skew = %f, corr_skew = %f\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1711 (interval != prev_interval) ? (double)1e6/(interval - prev_interval) : -1, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1712 (double)1e-6*interval, (double)1e-6*xskew, (double)1e-6*skew); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1713 mp_msg(MSGT_TV, MSGL_DBG3, "vcnt = %d, acnt = %d\n", priv->video_cnt, priv->audio_cnt); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1714 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1715 prev_skew = skew; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1716 prev_interval = interval; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1717 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1718 /* allocate a new buffer, if needed */ |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1719 pthread_mutex_lock(&priv->video_buffer_mutex); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1720 if (priv->video_buffer_size_current < priv->video_buffer_size_max) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1721 if (priv->video_cnt == priv->video_buffer_size_current) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1722 unsigned char *newbuf = calloc(priv->bytesperline, priv->height); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1723 if (newbuf) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1724 memmove(priv->video_ringbuffer+priv->video_tail+1, priv->video_ringbuffer+priv->video_tail, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1725 (priv->video_buffer_size_current-priv->video_tail)*sizeof(unsigned char *)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1726 memmove(priv->video_timebuffer+priv->video_tail+1, priv->video_timebuffer+priv->video_tail, |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1727 (priv->video_buffer_size_current-priv->video_tail)*sizeof(long long)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1728 priv->video_ringbuffer[priv->video_tail] = newbuf; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1729 if ((priv->video_head >= priv->video_tail) && (priv->video_cnt > 0)) priv->video_head++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1730 priv->video_buffer_size_current++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1731 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1732 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1733 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1734 pthread_mutex_unlock(&priv->video_buffer_mutex); |
8650
cf1d4f48aecf
allow utilization of more v4l buffers, patch by Carsten Schulz <carsten@gnocchi.dialup.fu-berlin.de>
henry
parents:
8627
diff
changeset
|
1735 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1736 if (priv->video_cnt == priv->video_buffer_size_current) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1737 if (!priv->immediate_mode) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1738 mp_msg(MSGT_TV, MSGL_ERR, "\nvideo buffer full - dropping frame\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1739 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1740 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1741 if (priv->immediate_mode) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1742 priv->video_timebuffer[priv->video_tail] = interval; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1743 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1744 // compensate for audio skew |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1745 // negative skew => there are more audio samples, increase interval |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1746 // positive skew => less samples, shorten the interval |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1747 priv->video_timebuffer[priv->video_tail] = interval - skew; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1748 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1749 |
23885 | 1750 if ( priv->tv_param->mjpeg ) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1751 copy_frame(priv, priv->video_ringbuffer[priv->video_tail], |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1752 priv->mmap+(priv->mjpeg_bufsize)*i); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1753 else |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1754 copy_frame(priv, priv->video_ringbuffer[priv->video_tail], |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1755 priv->mmap+priv->mbuf.offsets[frame]); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1756 priv->video_tail = (priv->video_tail+1)%priv->video_buffer_size_current; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1757 priv->video_cnt++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1758 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1759 |
23885 | 1760 if ( priv->tv_param->mjpeg ) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1761 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1762 num = frame; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1763 if (ioctl(priv->video_fd, MJPIOC_QBUF_CAPT, &num) < 0) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1764 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1765 mp_msg(MSGT_TV, MSGL_ERR, "\n MJP: ioctl MJPIOC_QBUF_CAPT end failed: %s\n", |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1766 strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1767 continue; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1768 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1769 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1770 else |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1771 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1772 if (ioctl(priv->video_fd, VIDIOCMCAPTURE, &priv->buf[frame]) == -1) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1773 { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1774 mp_msg(MSGT_TV, MSGL_ERR, "\nioctl mcapture failed: %s\n", strerror(errno)); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1775 continue; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1776 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1777 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1778 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1779 } |
9620
ce4cd85498f3
hardware mjpeg encoding using v4l by Iv«¡n Sz«¡nt«Ñ <szivan@freemail.hu>
henry
parents:
9609
diff
changeset
|
1780 mp_msg(MSGT_TV, MSGL_INFO, " MJP: returning! \n"); |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7318
diff
changeset
|
1781 return NULL; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1782 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1783 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1784 static double grab_video_frame(priv_t *priv, char *buffer, int len) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1785 { |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1786 double interval; |
2802 | 1787 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1788 if (priv->first) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1789 pthread_create(&priv->video_grabber_thread, NULL, video_grabber, priv); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1790 priv->first = 0; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1791 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1792 |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1793 while (priv->video_cnt == 0) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1794 usleep(10000); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1795 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1796 |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1797 pthread_mutex_lock(&priv->video_buffer_mutex); |
8131 | 1798 interval = (double)priv->video_timebuffer[priv->video_head]*1e-6; |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23422
diff
changeset
|
1799 fast_memcpy(buffer, priv->video_ringbuffer[priv->video_head], len); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1800 priv->video_cnt--; |
8671
e1337452fe62
Obvious patch to avoid undefined behaviour of multiple side effects in
arpi
parents:
8650
diff
changeset
|
1801 priv->video_head = (priv->video_head+1)%priv->video_buffer_size_current; |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1802 pthread_mutex_unlock(&priv->video_buffer_mutex); |
9608 | 1803 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1804 return interval; |
2790 | 1805 } |
1806 | |
1807 static int get_video_framesize(priv_t *priv) | |
1808 { | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1809 return priv->bytesperline * priv->height; |
2790 | 1810 } |
1811 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1812 static void *audio_grabber(void *data) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1813 { |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1814 priv_t *priv = (priv_t*)data; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1815 struct timeval tv; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1816 int i, audio_skew_ptr = 0; |
8417
15e3d9c2c0ac
allocate the video buffer on the fly, instead of one big chunk at startup
henry
parents:
8335
diff
changeset
|
1817 long long current_time, prev_skew = 0; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1818 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1819 pthread_mutex_lock(&priv->audio_starter); |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1820 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1821 audio_in_start_capture(&priv->audio_in); |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1822 for (i = 0; i < priv->aud_skew_cnt; i++) |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1823 priv->audio_skew_buffer[i] = 0; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1824 |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1825 for (; !priv->shutdown;) |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1826 { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1827 if (audio_in_read_chunk(&priv->audio_in, priv->audio_ringbuffer+priv->audio_tail*priv->audio_in.blocksize) < 0) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1828 continue; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1829 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1830 gettimeofday(&tv, NULL); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1831 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1832 priv->audio_recv_blocks_total++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1833 current_time = (long long)1e6*tv.tv_sec + tv.tv_usec - priv->starttime; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1834 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1835 priv->audio_skew_total -= priv->audio_skew_buffer[audio_skew_ptr]; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1836 priv->audio_skew_buffer[audio_skew_ptr] = current_time |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1837 - 1e6*priv->audio_secs_per_block*priv->audio_recv_blocks_total; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1838 priv->audio_skew_total += priv->audio_skew_buffer[audio_skew_ptr]; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1839 audio_skew_ptr = (audio_skew_ptr+1) % priv->aud_skew_cnt; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1840 |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1841 pthread_mutex_lock(&priv->skew_mutex); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1842 // linear interpolation - here we interpolate current skew value |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1843 // from the moving average, which we expect to be in the middle |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1844 // of the interval |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1845 if (priv->audio_recv_blocks_total > priv->aud_skew_cnt) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1846 priv->audio_skew = priv->audio_skew_total/priv->aud_skew_cnt; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1847 priv->audio_skew += (priv->audio_skew*priv->aud_skew_cnt)/(2*priv->audio_recv_blocks_total-priv->aud_skew_cnt); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1848 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1849 // this smoothes the evolution of audio_skew at startup a bit |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1850 priv->audio_skew = ((priv->aud_skew_cnt+priv->audio_recv_blocks_total)*priv->audio_skew_total)/(priv->aud_skew_cnt*priv->audio_recv_blocks_total); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1851 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1852 // current skew factor (assuming linearity) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1853 // used for further interpolation in video_grabber |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1854 // probably overkill but seems to be necessary for |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1855 // stress testing by dropping half of the audio frames ;) |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1856 // especially when using ALSA with large block sizes |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1857 // where audio_skew remains a long while behind |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1858 if ((priv->audio_skew_measure_time != 0) && (current_time - priv->audio_skew_measure_time != 0)) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1859 priv->audio_skew_factor = (double)(priv->audio_skew-prev_skew)/(current_time - priv->audio_skew_measure_time); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1860 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1861 priv->audio_skew_factor = 0.0; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1862 } |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1863 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1864 priv->audio_skew_measure_time = current_time; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1865 prev_skew = priv->audio_skew; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1866 pthread_mutex_unlock(&priv->skew_mutex); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1867 |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1868 if ((priv->audio_tail+1) % priv->audio_buffer_size == priv->audio_head) { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1869 mp_msg(MSGT_TV, MSGL_ERR, "\ntoo bad - dropping audio frame !\n"); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1870 priv->audio_drop++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1871 } else { |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1872 priv->audio_tail = (priv->audio_tail+1) % priv->audio_buffer_size; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1873 priv->audio_cnt++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1874 } |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1875 } |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7318
diff
changeset
|
1876 return NULL; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1877 } |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1878 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5088
diff
changeset
|
1879 static double grab_audio_frame(priv_t *priv, char *buffer, int len) |
2790 | 1880 { |
5088 | 1881 mp_dbg(MSGT_TV, MSGL_DBG2, "grab_audio_frame(priv=%p, buffer=%p, len=%d)\n", |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1882 priv, buffer, len); |
3815 | 1883 |
10776
80402283a017
Fix immediatemode with mplayer (ie playing both sound and video)
albeu
parents:
10621
diff
changeset
|
1884 if (priv->first) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1885 pthread_create(&priv->video_grabber_thread, NULL, video_grabber, priv); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1886 priv->first = 0; |
10776
80402283a017
Fix immediatemode with mplayer (ie playing both sound and video)
albeu
parents:
10621
diff
changeset
|
1887 } |
80402283a017
Fix immediatemode with mplayer (ie playing both sound and video)
albeu
parents:
10621
diff
changeset
|
1888 |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1889 // compensate for dropped audio frames |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1890 if (priv->audio_drop && (priv->audio_head == priv->audio_tail)) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1891 priv->audio_drop--; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1892 priv->audio_sent_blocks_total++; |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1893 memset(buffer, 0, len); |
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1894 return (double)priv->audio_sent_blocks_total*priv->audio_secs_per_block; |
3815 | 1895 } |
1896 | |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1897 while (priv->audio_head == priv->audio_tail) { |
23141
69232417ffde
cosmetics: Remove all trailing whitespace and tabs, indentation fixes.
diego
parents:
22507
diff
changeset
|
1898 usleep(10000); |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1899 } |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23422
diff
changeset
|
1900 fast_memcpy(buffer, priv->audio_ringbuffer+priv->audio_head*priv->audio_in.blocksize, len); |
8671
e1337452fe62
Obvious patch to avoid undefined behaviour of multiple side effects in
arpi
parents:
8650
diff
changeset
|
1901 priv->audio_head = (priv->audio_head+1) % priv->audio_buffer_size; |
7058
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1902 priv->audio_cnt--; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1903 priv->audio_sent_blocks_total++; |
2e5c07262861
new v4l capture patch by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>:
arpi
parents:
6553
diff
changeset
|
1904 return (double)priv->audio_sent_blocks_total*priv->audio_secs_per_block; |
2790 | 1905 } |
1906 | |
1907 static int get_audio_framesize(priv_t *priv) | |
1908 { | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25689
diff
changeset
|
1909 return priv->audio_in.blocksize; |
2790 | 1910 } |