Mercurial > mplayer.hg
annotate libmpcodecs/ad_libmad.c @ 36802:621b61818a0f
configure: add -Zhigh-mem linker flag for OS/2
x264 encoder crashes due to memory allocation failure. This fixes the problem.
author | komh |
---|---|
date | Thu, 20 Feb 2014 13:59:34 +0000 |
parents | 6198c908db85 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
18 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
19 #include <stdio.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
20 #include <stdlib.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
21 #include <unistd.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
22 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
23 #include "config.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
31160
diff
changeset
|
24 #include "mp_msg.h" |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
25 #include "ad_internal.h" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
26 |
31160 | 27 static const ad_info_t info = { |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
28 "libmad mpeg audio decoder", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
29 "libmad", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
30 "A'rpi", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
31 "libmad...", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
32 "based on Xine's libmad/xine_decoder.c" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
33 }; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
34 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
35 LIBAD_EXTERN(libmad) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
36 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
37 #include <mad.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
38 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
39 typedef struct mad_decoder_s { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
40 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
41 struct mad_synth synth; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
42 struct mad_stream stream; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
43 struct mad_frame frame; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
44 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
45 int have_frame; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
46 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
47 int output_sampling_rate; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
48 int output_open; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
49 int output_mode; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
50 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
51 } mad_decoder_t; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
52 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
53 static int preinit(sh_audio_t *sh){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
54 |
34740 | 55 mad_decoder_t *this = calloc(1, sizeof(mad_decoder_t)); |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
56 sh->context = this; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
57 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
58 mad_synth_init (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
59 mad_stream_init (&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
60 mad_frame_init (&this->frame); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
61 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
62 sh->audio_out_minsize=2*4608; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
63 sh->audio_in_minsize=4096; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
64 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
65 return 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
66 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
67 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
68 static int read_frame(sh_audio_t *sh){ |
34739 | 69 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
70 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
71 while(1){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
72 int ret; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
73 mad_stream_buffer (&this->stream, sh->a_in_buffer, sh->a_in_buffer_len); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
74 ret=mad_frame_decode (&this->frame, &this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
75 if (this->stream.next_frame) { |
36339 | 76 unsigned processed = this->stream.next_frame - (uint8_t *)sh->a_in_buffer; |
77 sh->a_in_buffer_len -= processed; | |
78 memmove(sh->a_in_buffer, this->stream.next_frame, sh->a_in_buffer_len); | |
79 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"libmad: %d bytes processed\n",processed); | |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
80 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
81 if (ret == 0) return 1; // OK!!! |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
82 // error! try to resync! |
36340 | 83 if(this->stream.error==MAD_ERROR_BUFLEN) { |
84 int len=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], | |
85 sh->a_in_buffer_size-sh->a_in_buffer_len); | |
86 if (len <= 0) break; | |
87 sh->a_in_buffer_len+=len; | |
88 } | |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
89 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
90 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Cannot sync MAD frame\n"); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
91 return 0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
92 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
93 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
94 static int init(sh_audio_t *sh){ |
34739 | 95 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
96 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
97 this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
98 if(!this->have_frame) return 0; // failed to sync... |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
99 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
100 sh->channels=(this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? 1 : 2; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
101 sh->samplerate=this->frame.header.samplerate; |
34741 | 102 if (sh->i_bps < 1) |
103 sh->i_bps=this->frame.header.bitrate/8; | |
13430 | 104 sh->samplesize=2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
105 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
106 return 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
107 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
108 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
109 static void uninit(sh_audio_t *sh){ |
34739 | 110 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
111 mad_synth_finish (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
112 mad_frame_finish (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
113 mad_stream_finish(&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
114 free(sh->context); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
115 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
116 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
117 /* utility to scale and round samples to 16 bits */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
118 static inline signed int scale(mad_fixed_t sample) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
119 /* round */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
120 sample += (1L << (MAD_F_FRACBITS - 16)); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
121 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
122 /* clip */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
123 if (sample >= MAD_F_ONE) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
124 sample = MAD_F_ONE - 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
125 else if (sample < -MAD_F_ONE) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
126 sample = -MAD_F_ONE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
127 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
128 /* quantize */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
129 return sample >> (MAD_F_FRACBITS + 1 - 16); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
130 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
131 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
132 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ |
34739 | 133 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
134 int len=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
135 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
136 while(len<minlen && len+4608<=maxlen){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
137 if(!this->have_frame) this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
138 if(!this->have_frame) break; // failed to sync... or EOF |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
139 this->have_frame=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
140 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
141 mad_synth_frame (&this->synth, &this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
142 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
143 { unsigned int nchannels, nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
144 mad_fixed_t const *left_ch, *right_ch; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
145 struct mad_pcm *pcm = &this->synth.pcm; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
146 uint16_t *output = (uint16_t*) buf; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
147 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
148 nchannels = pcm->channels; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
149 nsamples = pcm->length; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
150 left_ch = pcm->samples[0]; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
151 right_ch = pcm->samples[1]; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
152 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
153 len+=2*nchannels*nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
154 buf+=2*nchannels*nsamples; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
155 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
156 while (nsamples--) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
157 /* output sample(s) in 16-bit signed little-endian PCM */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
158 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
159 *output++ = scale(*left_ch++); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
160 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
161 if (nchannels == 2) |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
162 *output++ = scale(*right_ch++); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
163 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
164 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
165 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
166 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
167 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
168 return len?len:-1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
169 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
170 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
171 static int control(sh_audio_t *sh,int cmd,void* arg, ...){ |
34739 | 172 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
173 // various optional functions you MAY implement: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
174 switch(cmd){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
175 case ADCTRL_RESYNC_STREAM: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
176 this->have_frame=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
177 mad_synth_init (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
178 mad_stream_init (&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
179 mad_frame_init (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
180 return CONTROL_TRUE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
181 case ADCTRL_SKIP_FRAME: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
182 this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
183 return CONTROL_TRUE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
184 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
185 return CONTROL_UNKNOWN; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
186 } |