annotate stream/stream_dvd_common.c @ 36003:8fea01665c83

Remove HidePreferences(), HideAudioConfig() and HideDXR3Config(). Simply destroy the windows. (It's pointless to check whether the window is existing, because it cannot be called without an existing window.) In order to do so, relocate definition of AudioConfig. Additionally, remove unnecessary declarations.
author ib
date Fri, 29 Mar 2013 17:28:44 +0000
parents edd8273dc025
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30426
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
1 /*
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
2 * This file is part of MPlayer.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
3 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
5 * it under the terms of the GNU General Public License as published by
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
7 * (at your option) any later version.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
8 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
12 * GNU General Public License for more details.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
13 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
14 * You should have received a copy of the GNU General Public License along
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
17 */
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29852
diff changeset
18
26907
f0d0b666ee35 Fix compilation with internal dvdnav
rtogni
parents: 26906
diff changeset
19 #include "config.h"
29852
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
20 #include <fcntl.h>
24047
de28f9e8cb00 Sync libdvdread with version 0.9.5 (functional changes).
diego
parents: 23993
diff changeset
21 #include <inttypes.h>
29852
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
22 #include <unistd.h>
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
23 #include <stdio.h>
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
24 #include <string.h>
27466
ea01824701a5 Rename internal libdvdread fork from dvdread to libdvdread
rathann
parents: 27341
diff changeset
25 #include <dvdread/ifo_types.h>
29852
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
26 #ifdef __FreeBSD__
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
27 #include <sys/cdrio.h>
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
28 #endif
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
29
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
30 #ifdef __linux__
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
31 #include <linux/cdrom.h>
35884
edd8273dc025 Hacks to fix compilation on/for Android.
reimar
parents: 30426
diff changeset
32 #ifndef __ANDROID__
29852
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
33 #include <scsi/sg.h>
35884
edd8273dc025 Hacks to fix compilation on/for Android.
reimar
parents: 30426
diff changeset
34 #endif
29852
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
35 #include <sys/types.h>
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
36 #include <sys/stat.h>
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
37 #include <sys/ioctl.h>
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
38 #endif
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
39
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
40 #include "mp_msg.h"
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
41 #include "help_mp.h"
23993
2107f38b6ca1 Moved dvdtimetomsec to stream_dvd_common.c.
cehoyos
parents: 23691
diff changeset
42 #include "stream_dvd_common.h"
29852
32d288088a0f Move headers related to setting dvd speed to dvd_common.
reimar
parents: 29848
diff changeset
43 #include "libavutil/intreadwrite.h"
15518
9391bf60ccdf ported dvd:// to the new stream api
nicodvb
parents:
diff changeset
44
29847
e37311e178e1 Move arrays used by both dvd and dvdnav to dvd_common.
reimar
parents: 29263
diff changeset
45 const char * const dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" };
e37311e178e1 Move arrays used by both dvd and dvdnav to dvd_common.
reimar
parents: 29263
diff changeset
46 const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" };
e37311e178e1 Move arrays used by both dvd and dvdnav to dvd_common.
reimar
parents: 29263
diff changeset
47
29848
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
48 int dvd_speed=0; /* 0 => don't touch speed */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
49
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
50 void dvd_set_speed(char *device, unsigned speed)
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
51 {
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
52 #if defined(__linux__) && defined(SG_IO) && defined(GPCMD_SET_STREAMING)
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
53 int fd;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
54 unsigned char buffer[28];
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
55 unsigned char cmd[12];
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
56 struct sg_io_hdr sghdr;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
57 struct stat st;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
58
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
59 memset(&st, 0, sizeof(st));
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
60
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
61 if (stat(device, &st) == -1) return;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
62
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
63 if (!S_ISBLK(st.st_mode)) return; /* not a block device */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
64
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
65 switch (speed) {
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
66 case 0: /* don't touch speed setting */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
67 return;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
68 case -1: /* restore default value */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
69 if (dvd_speed == 0) return; /* we haven't touched the speed setting */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
70 mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDrestoreSpeed);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
71 break;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
72 default: /* limit to <speed> KB/s */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
73 // speed < 100 is multiple of DVD single speed (1350KB/s)
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
74 if (speed < 100)
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
75 speed *= 1350;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
76 mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitSpeed, speed);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
77 break;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
78 }
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
79
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
80 memset(&sghdr, 0, sizeof(sghdr));
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
81 sghdr.interface_id = 'S';
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
82 sghdr.timeout = 5000;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
83 sghdr.dxfer_direction = SG_DXFER_TO_DEV;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
84 sghdr.dxfer_len = sizeof(buffer);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
85 sghdr.dxferp = buffer;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
86 sghdr.cmd_len = sizeof(cmd);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
87 sghdr.cmdp = cmd;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
88
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
89 memset(cmd, 0, sizeof(cmd));
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
90 cmd[0] = GPCMD_SET_STREAMING;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
91 cmd[10] = sizeof(buffer);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
92
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
93 memset(buffer, 0, sizeof(buffer));
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
94 /* first sector 0, last sector 0xffffffff */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
95 AV_WB32(buffer + 8, 0xffffffff);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
96 if (speed == -1)
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
97 buffer[0] = 4; /* restore default */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
98 else {
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
99 /* <speed> kilobyte */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
100 AV_WB32(buffer + 12, speed);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
101 AV_WB32(buffer + 20, speed);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
102 }
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
103 /* 1 second */
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
104 AV_WB16(buffer + 18, 1000);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
105 AV_WB16(buffer + 26, 1000);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
106
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
107 fd = open(device, O_RDWR | O_NONBLOCK);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
108 if (fd == -1) {
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
109 mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDspeedCantOpen);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
110 return;
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
111 }
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
112
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
113 if (ioctl(fd, SG_IO, &sghdr) < 0)
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
114 mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitFail);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
115 else
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
116 mp_msg(MSGT_OPEN, MSGL_INFO, MSGTR_DVDlimitOk);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
117
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
118 close(fd);
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
119 #endif
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
120 }
c20a30ebbe56 Move dvd_speed and dvd_set_speed to dvd_common and implement -dvd-speed
reimar
parents: 29847
diff changeset
121
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28245
diff changeset
122 /**
16544
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
123 \brief Converts DVD time structure to milliseconds.
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
124 \param *dev the DVD time structure to convert
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
125 \return returns the time in milliseconds
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
126 */
23993
2107f38b6ca1 Moved dvdtimetomsec to stream_dvd_common.c.
cehoyos
parents: 23691
diff changeset
127 int mp_dvdtimetomsec(dvd_time_t *dt)
16544
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
128 {
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
129 static int framerates[4] = {0, 2500, 0, 2997};
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
130 int framerate = framerates[(dt->frame_u & 0xc0) >> 6];
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
131 int msec = (((dt->hour & 0xf0) >> 3) * 5 + (dt->hour & 0x0f)) * 3600000;
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
132 msec += (((dt->minute & 0xf0) >> 3) * 5 + (dt->minute & 0x0f)) * 60000;
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
133 msec += (((dt->second & 0xf0) >> 3) * 5 + (dt->second & 0x0f)) * 1000;
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
134 if(framerate > 0)
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
135 msec += (((dt->frame_u & 0x30) >> 3) * 5 + (dt->frame_u & 0x0f)) * 100000 / framerate;
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
136 return msec;
a10adcba312f Prints the number of titles, DVD disk ID, the numbers of chapters and
gpoirier
parents: 15551
diff changeset
137 }