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