Mercurial > mplayer.hg
annotate mixer.c @ 27518:e54c9b7eb0d8
Revert bad changes to SSA/ASS subtitle packet format
The following commits are reverted partially or completely:
"a valid ASS line contains 9 ',' before actual text"
"demux_mkv: output correctly formated ASS packets"
"libass: add a new ass_process_data() to process demuxed subtitle packets"
These commits converted the internal representation of SSA/ASS
subtitle packets from the format used by Matroska to a custom format
where each packet has contents exactly matching one line in complete
SSA script files. AFAIK no files natively use such a format for muxed
subtitles. The stated reason for this change was to use a format that
could in principle be muxed into a maximal number of containers. SSA
subtitles do not have an implicit duration so both start time and
duration or end time need to be specified explicitly; the new format
moved timing information inside the codec packet data so it could be
muxed without modification into containers that can represent only
start time at the container level. However such a change is wrong from
the viewpoint of program architecture. Timing information belongs to
the demuxer level, but these commits moved not only the duration but
also the authoritative value of the start time to inside the codec
data. Additionally the new format lost the value of the Matroska
ReadOrder field which is used by MPlayer.
This commit changes the internal packet format back to that used by
Matroska and makes the internal Matroska demuxer output that format
again. Libavformat still outputs the "new" format; it could be
converted back to the Matroska format in demux_lavf.c, but I'm not
adding that code at least yet. The current lavf code has similar
problems as the reverted code in MPlayer, and it also currently fails
to provide any way to access the value of the ReadOrder field. I hope
that the lavf side will be improved; if it isn't conversion can be
added later. For now I'll make MPlayer default to the internal Matroska
demuxer instead of the lavf one in a separate commit.
author | uau |
---|---|
date | Mon, 08 Sep 2008 21:26:22 +0000 |
parents | 519e42b716aa |
children | 0f1b5b68af32 |
rev | line source |
---|---|
441 | 1 #include <string.h> |
9772 | 2 #ifndef __MINGW32__ |
441 | 3 #include <sys/ioctl.h> |
9772 | 4 #endif |
441 | 5 #include <fcntl.h> |
6 #include <stdio.h> | |
605 | 7 #include <unistd.h> |
441 | 8 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
9 #include "config.h" |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
10 #include "libao2/audio_out.h" |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
11 #include "libaf/af.h" |
441 | 12 #include "mixer.h" |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
13 |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
14 #include "help_mp.h" |
1061 | 15 |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
16 char * mixer_device=NULL; |
11837 | 17 char * mixer_channel=NULL; |
13933
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
18 int soft_vol = 0; |
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
19 float soft_vol_max = 110.0; |
441 | 20 |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
21 void mixer_getvolume(mixer_t *mixer, float *l, float *r) |
441 | 22 { |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
23 ao_control_vol_t vol; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
24 *l=0; *r=0; |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
25 if(mixer->audio_out){ |
13933
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
26 if(soft_vol || |
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
27 CONTROL_OK != mixer->audio_out->control(AOCONTROL_GET_VOLUME,&vol)) { |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
28 if (!mixer->afilter) |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
29 return; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
30 else { |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
31 float db_vals[AF_NCH]; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
32 if (!af_control_any_rev(mixer->afilter, |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
33 AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, db_vals)) |
12908
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
34 db_vals[0] = db_vals[1] = 1.0; |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
35 else |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
36 af_from_dB (2, db_vals, db_vals, 20.0, -200.0, 60.0); |
13933
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
37 vol.left = (db_vals[0] / (soft_vol_max / 100.0)) * 100.0; |
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
38 vol.right = (db_vals[1] / (soft_vol_max / 100.0)) * 100.0; |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
39 } |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
40 } |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
41 *r=vol.right; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
42 *l=vol.left; |
441 | 43 } |
44 } | |
45 | |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
46 void mixer_setvolume(mixer_t *mixer, float l, float r) |
441 | 47 { |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
48 ao_control_vol_t vol; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
49 vol.right=r; vol.left=l; |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
50 if(mixer->audio_out){ |
13933
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
51 if(soft_vol || |
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
52 CONTROL_OK != mixer->audio_out->control(AOCONTROL_SET_VOLUME,&vol)) { |
12688 | 53 if (!mixer->afilter) |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
54 return; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
55 else { |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
56 // af_volume uses values in dB |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
57 float db_vals[AF_NCH]; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
58 int i; |
13933
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
59 db_vals[0] = (l / 100.0) * (soft_vol_max / 100.0); |
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
60 db_vals[1] = (r / 100.0) * (soft_vol_max / 100.0); |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
61 for (i = 2; i < AF_NCH; i++) { |
13933
75b84965d137
allow forcing of software volume control and setting maximum amplification.
reimar
parents:
12908
diff
changeset
|
62 db_vals[i] = ((l + r) / 100.0) * (soft_vol_max / 100.0) / 2.0; |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
63 } |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
64 af_to_dB (AF_NCH, db_vals, db_vals, 20.0); |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
65 if (!af_control_any_rev(mixer->afilter, |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
66 AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) { |
12908
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
67 mp_msg(MSGT_GLOBAL, MSGL_INFO, MSGTR_InsertingAfVolume); |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
68 if (af_add(mixer->afilter, "volume")) { |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
69 if (!af_control_any_rev(mixer->afilter, |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
70 AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) { |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
71 mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoVolume); |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
72 return; |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
73 } |
7b9b4f07d2c4
automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents:
12688
diff
changeset
|
74 } |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
75 } |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
76 } |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
77 } |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
78 } |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
79 mixer->muted=0; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
80 } |
1061 | 81 |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
82 void mixer_incvolume(mixer_t *mixer) |
441 | 83 { |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
84 float mixer_l, mixer_r; |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
85 mixer_getvolume(mixer, &mixer_l, &mixer_r); |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
86 mixer_l += mixer->volstep; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
87 if ( mixer_l > 100 ) mixer_l = 100; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
88 mixer_r += mixer->volstep; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
89 if ( mixer_r > 100 ) mixer_r = 100; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
90 mixer_setvolume(mixer, mixer_l, mixer_r); |
441 | 91 } |
92 | |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
93 void mixer_decvolume(mixer_t *mixer) |
441 | 94 { |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
95 float mixer_l, mixer_r; |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
96 mixer_getvolume(mixer, &mixer_l, &mixer_r); |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
97 mixer_l -= mixer->volstep; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
98 if ( mixer_l < 0 ) mixer_l = 0; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
99 mixer_r -= mixer->volstep; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
100 if ( mixer_r < 0 ) mixer_r = 0; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
101 mixer_setvolume(mixer, mixer_l, mixer_r); |
441 | 102 } |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
103 |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
104 void mixer_getbothvolume(mixer_t *mixer, float *b) |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
105 { |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
106 float mixer_l, mixer_r; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
107 mixer_getvolume(mixer, &mixer_l, &mixer_r); |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
108 *b = ( mixer_l + mixer_r ) / 2; |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
109 } |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
110 |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
111 void mixer_mute(mixer_t *mixer) |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
112 { |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
113 if (mixer->muted) mixer_setvolume(mixer, mixer->last_l, mixer->last_r); |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
114 else |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
115 { |
12672
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
116 mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r); |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
117 mixer_setvolume(mixer, 0, 0); |
9709ce101949
New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents:
11837
diff
changeset
|
118 mixer->muted=1; |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
119 } |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
120 } |
23568 | 121 |
122 void mixer_getbalance(mixer_t *mixer, float *val) | |
123 { | |
124 *val = 0.f; | |
125 if(!mixer->afilter) | |
126 return; | |
127 af_control_any_rev(mixer->afilter, | |
128 AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET, val); | |
129 } | |
130 | |
131 void mixer_setbalance(mixer_t *mixer, float val) | |
132 { | |
133 float level[AF_NCH]; | |
134 int i; | |
135 af_control_ext_t arg_ext = { .arg = level }; | |
136 af_instance_t* af_pan_balance; | |
137 | |
138 if(!mixer->afilter) | |
139 return; | |
140 if (af_control_any_rev(mixer->afilter, | |
141 AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val)) | |
142 return; | |
143 | |
144 if (!(af_pan_balance = af_add(mixer->afilter, "pan"))) { | |
145 mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoBalance); | |
146 return; | |
147 } | |
148 | |
149 af_init(mixer->afilter); | |
150 /* make all other channels pass thru since by default pan blocks all */ | |
151 memset(level, 0, sizeof(level)); | |
152 for (i = 2; i < AF_NCH; i++) { | |
153 arg_ext.ch = i; | |
154 level[i] = 1.f; | |
155 af_pan_balance->control(af_pan_balance, | |
156 AF_CONTROL_PAN_LEVEL | AF_CONTROL_SET, &arg_ext); | |
157 level[i] = 0.f; | |
158 } | |
159 | |
160 af_pan_balance->control(af_pan_balance, | |
161 AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val); | |
162 } | |
163 |