Mercurial > mplayer.hg
annotate libmpcodecs/ad_qtaudio.c @ 29391:e69a1d754130
Bandaid compilation fix: Disable ivtv VIDIX driver until a proper test exists.
author | diego |
---|---|
date | Sun, 19 Jul 2009 21:24:45 +0000 |
parents | 0f1b5b68af32 |
children | bbb6ebec87a0 |
rev | line source |
---|---|
8008 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 #include <inttypes.h> | |
5 | |
21260
cc732ceece60
Shouldn't move "#ifdef MACOSX" before #include config.h of course...
uau
parents:
21258
diff
changeset
|
6 #include "config.h" |
28197
45ca1763a540
Reorder #includes and #ifdefs to avoid excessive #ifdeffery.
diego
parents:
27388
diff
changeset
|
7 #include "mp_msg.h" |
45ca1763a540
Reorder #includes and #ifdefs to avoid excessive #ifdeffery.
diego
parents:
27388
diff
changeset
|
8 #include "mpbswap.h" |
45ca1763a540
Reorder #includes and #ifdefs to avoid excessive #ifdeffery.
diego
parents:
27388
diff
changeset
|
9 #include "ad_internal.h" |
21260
cc732ceece60
Shouldn't move "#ifdef MACOSX" before #include config.h of course...
uau
parents:
21258
diff
changeset
|
10 |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26542
diff
changeset
|
11 #ifdef CONFIG_QUICKTIME |
21258
ed01090d1192
Move #include <QuickTime/QuickTimeComponents.h> before internal headers.
uau
parents:
18771
diff
changeset
|
12 #include <QuickTime/QuickTimeComponents.h> |
28197
45ca1763a540
Reorder #includes and #ifdefs to avoid excessive #ifdeffery.
diego
parents:
27388
diff
changeset
|
13 #else |
45ca1763a540
Reorder #includes and #ifdefs to avoid excessive #ifdeffery.
diego
parents:
27388
diff
changeset
|
14 #include "loader/ldt_keeper.h" |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
21260
diff
changeset
|
15 #include "loader/wine/windef.h" |
8451 | 16 #endif |
17 | |
8008 | 18 static ad_info_t info = { |
19 "QuickTime Audio Decoder", | |
20 "qtaudio", | |
21 "A'rpi", | |
22 "Sascha Sommer", | |
23 "uses win32 quicktime DLLs" | |
24 }; | |
25 | |
26 LIBAD_EXTERN(qtaudio) | |
27 | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26542
diff
changeset
|
28 #ifndef CONFIG_QUICKTIME |
8008 | 29 typedef struct OpaqueSoundConverter* SoundConverter; |
30 typedef unsigned long OSType; | |
31 typedef unsigned long UnsignedFixed; | |
32 typedef uint8_t Byte; | |
33 typedef struct SoundComponentData { | |
34 long flags; | |
35 OSType format; | |
36 short numChannels; | |
37 short sampleSize; | |
38 UnsignedFixed sampleRate; | |
39 long sampleCount; | |
40 Byte * buffer; | |
41 long reserved; | |
42 }SoundComponentData; | |
43 | |
44 typedef int (__cdecl* LPFUNC1)(long flag); | |
45 typedef int (__cdecl* LPFUNC2)(const SoundComponentData *, const SoundComponentData *,SoundConverter *); | |
46 typedef int (__cdecl* LPFUNC3)(SoundConverter sc); | |
47 typedef int (__cdecl* LPFUNC4)(void); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
48 typedef int (__cdecl* LPFUNC5)(SoundConverter sc, OSType selector,void * infoPtr); |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
49 typedef int (__cdecl* LPFUNC6)(SoundConverter sc, |
8008 | 50 unsigned long inputBytesTarget, |
51 unsigned long *inputFrames, | |
52 unsigned long *inputBytes, | |
53 unsigned long *outputBytes ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
54 typedef int (__cdecl* LPFUNC7)(SoundConverter sc, |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
55 const void *inputPtr, |
8008 | 56 unsigned long inputFrames, |
57 void *outputPtr, | |
58 unsigned long *outputFrames, | |
59 unsigned long *outputBytes ); | |
60 typedef int (__cdecl* LPFUNC8)(SoundConverter sc, | |
61 void *outputPtr, | |
62 unsigned long *outputFrames, | |
63 unsigned long *outputBytes); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
64 typedef int (__cdecl* LPFUNC9)(SoundConverter sc) ; |
8008 | 65 |
14528
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
66 static HINSTANCE qtime_qts; // handle to the preloaded quicktime.qts |
8008 | 67 static HINSTANCE qtml_dll; |
68 static LPFUNC1 InitializeQTML; | |
69 static LPFUNC2 SoundConverterOpen; | |
70 static LPFUNC3 SoundConverterClose; | |
71 static LPFUNC4 TerminateQTML; | |
72 static LPFUNC5 SoundConverterSetInfo; | |
73 static LPFUNC6 SoundConverterGetBufferSizes; | |
74 static LPFUNC7 SoundConverterConvertBuffer; | |
75 static LPFUNC8 SoundConverterEndConversion; | |
76 static LPFUNC9 SoundConverterBeginConversion; | |
77 | |
78 #define siDecompressionParams 2002876005 // siDecompressionParams = FOUR_CHAR_CODE('wave') | |
79 | |
80 HMODULE WINAPI LoadLibraryA(LPCSTR); | |
81 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); | |
82 int WINAPI FreeLibrary(HMODULE); | |
83 | |
29212
eda346733b8c
Add missing 'void' to parameterless function declarations.
diego
parents:
28197
diff
changeset
|
84 static int loader_init(void) |
8008 | 85 { |
86 | |
9405
a4444e7ee56a
real cygwin support by Sascha Sommer <saschasommer@freenet.de>
alex
parents:
8632
diff
changeset
|
87 #ifdef WIN32_LOADER |
8270 | 88 Setup_LDT_Keeper(); |
89 #endif | |
14528
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
90 //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
91 qtime_qts = LoadLibraryA("QuickTime.qts"); |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
92 if( qtime_qts == (HMODULE)NULL ) |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
93 { |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
94 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed loading QuickTime.qts\n" ); |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
95 return 1; |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
96 } |
8008 | 97 qtml_dll = LoadLibraryA("qtmlClient.dll"); |
13188 | 98 if( qtml_dll == (HMODULE)NULL ) |
8008 | 99 { |
14528
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
100 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed loading qtmlClient.dll\n" ); |
8008 | 101 return 1; |
102 } | |
103 #if 1 | |
104 InitializeQTML = (LPFUNC1)GetProcAddress(qtml_dll,"InitializeQTML"); | |
105 if ( InitializeQTML == NULL ) | |
106 { | |
12193 | 107 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed geting proc address InitializeQTML\n"); |
8008 | 108 return 1; |
109 } | |
110 SoundConverterOpen = (LPFUNC2)GetProcAddress(qtml_dll,"SoundConverterOpen"); | |
111 if ( SoundConverterOpen == NULL ) | |
112 { | |
12193 | 113 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterOpen\n"); |
8008 | 114 return 1; |
115 } | |
116 SoundConverterClose = (LPFUNC3)GetProcAddress(qtml_dll,"SoundConverterClose"); | |
117 if ( SoundConverterClose == NULL ) | |
118 { | |
12193 | 119 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterClose\n"); |
8008 | 120 return 1; |
121 } | |
122 TerminateQTML = (LPFUNC4)GetProcAddress(qtml_dll,"TerminateQTML"); | |
123 if ( TerminateQTML == NULL ) | |
124 { | |
12193 | 125 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address TerminateQTML\n"); |
8008 | 126 return 1; |
127 } | |
128 SoundConverterSetInfo = (LPFUNC5)GetProcAddress(qtml_dll,"SoundConverterSetInfo"); | |
129 if ( SoundConverterSetInfo == NULL ) | |
130 { | |
12193 | 131 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterSetInfo\n"); |
8008 | 132 return 1; |
133 } | |
134 SoundConverterGetBufferSizes = (LPFUNC6)GetProcAddress(qtml_dll,"SoundConverterGetBufferSizes"); | |
135 if ( SoundConverterGetBufferSizes == NULL ) | |
136 { | |
12193 | 137 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterGetBufferSizes\n"); |
8008 | 138 return 1; |
139 } | |
140 SoundConverterConvertBuffer = (LPFUNC7)GetProcAddress(qtml_dll,"SoundConverterConvertBuffer"); | |
141 if ( SoundConverterConvertBuffer == NULL ) | |
142 { | |
12193 | 143 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterConvertBuffer1\n"); |
8008 | 144 return 1; |
145 } | |
146 SoundConverterEndConversion = (LPFUNC8)GetProcAddress(qtml_dll,"SoundConverterEndConversion"); | |
147 if ( SoundConverterEndConversion == NULL ) | |
148 { | |
12193 | 149 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterEndConversion\n"); |
8008 | 150 return 1; |
151 } | |
152 SoundConverterBeginConversion = (LPFUNC9)GetProcAddress(qtml_dll,"SoundConverterBeginConversion"); | |
153 if ( SoundConverterBeginConversion == NULL ) | |
154 { | |
12193 | 155 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterBeginConversion\n"); |
8008 | 156 return 1; |
157 } | |
158 #endif | |
12193 | 159 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"loader_init DONE???\n"); |
8008 | 160 return 0; |
161 } | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26542
diff
changeset
|
162 #endif /* #ifndef CONFIG_QUICKTIME */ |
8008 | 163 |
164 static SoundConverter myConverter = NULL; | |
165 static SoundComponentData InputFormatInfo,OutputFormatInfo; | |
166 | |
167 static int InFrameSize; | |
168 static int OutFrameSize; | |
169 | |
170 static int preinit(sh_audio_t *sh){ | |
171 int error; | |
172 unsigned long FramesToGet=0; //how many frames the demuxer has to get | |
173 unsigned long InputBufferSize=0; //size of the input buffer | |
174 unsigned long OutputBufferSize=0; //size of the output buffer | |
175 unsigned long WantedBufferSize=0; //the size you want your buffers to be | |
176 | |
177 | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26542
diff
changeset
|
178 #ifdef CONFIG_QUICKTIME |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
179 EnterMovies(); |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
180 #else |
8008 | 181 if(loader_init()) return 0; // failed to load DLL |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
182 |
12193 | 183 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"loader_init DONE!\n"); |
8008 | 184 |
8159 | 185 error = InitializeQTML(6+16); |
13008 | 186 if(error){ |
187 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"InitializeQTML:%i\n",error); | |
188 return 0; | |
189 } | |
9694 | 190 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
191 |
9694 | 192 #if 1 |
8008 | 193 OutputFormatInfo.flags = InputFormatInfo.flags = 0; |
194 OutputFormatInfo.sampleCount = InputFormatInfo.sampleCount = 0; | |
195 OutputFormatInfo.buffer = InputFormatInfo.buffer = NULL; | |
196 OutputFormatInfo.reserved = InputFormatInfo.reserved = 0; | |
197 OutputFormatInfo.numChannels = InputFormatInfo.numChannels = sh->wf->nChannels; | |
8159 | 198 InputFormatInfo.sampleSize = sh->wf->wBitsPerSample; |
199 OutputFormatInfo.sampleSize = 16; | |
8008 | 200 OutputFormatInfo.sampleRate = InputFormatInfo.sampleRate = sh->wf->nSamplesPerSec; |
201 InputFormatInfo.format = bswap_32(sh->format); //1363430706;///*1768775988;//*/1902406962;//qdm2//1768775988;//FOUR_CHAR_CODE('ima4'); | |
202 OutputFormatInfo.format = 1313820229;// FOUR_CHAR_CODE('NONE'); | |
203 | |
204 error = SoundConverterOpen(&InputFormatInfo, &OutputFormatInfo, &myConverter); | |
12193 | 205 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterOpen:%i\n",error); |
8008 | 206 if(error) return 0; |
207 | |
208 if(sh->codecdata){ | |
209 error = SoundConverterSetInfo(myConverter,siDecompressionParams,sh->codecdata); | |
12193 | 210 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterSetInfo:%i\n",error); |
8632
9cecfb883d85
don't abort if setparams failed - fixes some Qclp files
arpi
parents:
8451
diff
changeset
|
211 // if(error) return 0; |
8008 | 212 } |
213 | |
214 WantedBufferSize=OutputFormatInfo.numChannels*OutputFormatInfo.sampleRate*2; | |
215 error = SoundConverterGetBufferSizes(myConverter, | |
216 WantedBufferSize,&FramesToGet,&InputBufferSize,&OutputBufferSize); | |
12193 | 217 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterGetBufferSizes:%i\n",error); |
218 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"WantedBufferSize = %li\n",WantedBufferSize); | |
219 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"InputBufferSize = %li\n",InputBufferSize); | |
220 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OutputBufferSize = %li\n",OutputBufferSize); | |
221 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FramesToGet = %li\n",FramesToGet); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
222 |
8389
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
223 InFrameSize=(InputBufferSize+FramesToGet-1)/FramesToGet; |
8008 | 224 OutFrameSize=OutputBufferSize/FramesToGet; |
225 | |
12193 | 226 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FrameSize: %i -> %i\n",InFrameSize,OutFrameSize); |
8008 | 227 |
228 error = SoundConverterBeginConversion(myConverter); | |
12193 | 229 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterBeginConversion:%i\n",error); |
8008 | 230 if(error) return 0; |
231 | |
232 sh->audio_out_minsize=OutputBufferSize; | |
233 sh->audio_in_minsize=InputBufferSize; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
234 |
8008 | 235 sh->channels=sh->wf->nChannels; |
236 sh->samplerate=sh->wf->nSamplesPerSec; | |
8159 | 237 sh->samplesize=2; //(sh->wf->wBitsPerSample+7)/8; |
8008 | 238 |
239 sh->i_bps=sh->wf->nAvgBytesPerSec; | |
240 //InputBufferSize*WantedBufferSize/OutputBufferSize; | |
241 | |
242 #endif | |
8159 | 243 |
244 if(sh->format==0x3343414D){ | |
245 // MACE 3:1 | |
246 sh->ds->ss_div = 2*3; // 1 samples/packet | |
247 sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet | |
248 } else | |
249 if(sh->format==0x3643414D){ | |
250 // MACE 6:1 | |
251 sh->ds->ss_div = 2*6; // 1 samples/packet | |
252 sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet | |
253 } | |
254 | |
8008 | 255 return 1; // return values: 1=OK 0=ERROR |
256 } | |
257 | |
258 static int init(sh_audio_t *sh_audio){ | |
259 | |
260 return 1; // return values: 1=OK 0=ERROR | |
261 } | |
262 | |
263 static void uninit(sh_audio_t *sh){ | |
264 int error; | |
265 unsigned long ConvertedFrames=0; | |
266 unsigned long ConvertedBytes=0; | |
267 error=SoundConverterEndConversion(myConverter,NULL,&ConvertedFrames,&ConvertedBytes); | |
12193 | 268 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterEndConversion:%i\n",error); |
8008 | 269 error = SoundConverterClose(myConverter); |
12193 | 270 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterClose:%i\n",error); |
8389
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
271 // error = TerminateQTML(); |
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
272 // printf("TerminateQTML:%i\n",error); |
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
273 // FreeLibrary( qtml_dll ); |
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
274 // qtml_dll = NULL; |
14528
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
275 // FreeLibrary( qtime_qts ); |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
276 // qtime_qts = NULL; |
8389
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
277 // printf("qt dll loader uninit done\n"); |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26542
diff
changeset
|
278 #ifdef CONFIG_QUICKTIME |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
279 ExitMovies(); |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
280 #endif |
8008 | 281 } |
282 | |
283 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ | |
284 int error; | |
285 unsigned long FramesToGet=0; //how many frames the demuxer has to get | |
286 unsigned long InputBufferSize=0; //size of the input buffer | |
287 unsigned long ConvertedFrames=0; | |
288 unsigned long ConvertedBytes=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
289 |
8008 | 290 FramesToGet=minlen/OutFrameSize; |
291 if(FramesToGet*OutFrameSize<minlen && | |
292 (FramesToGet+1)*OutFrameSize<=maxlen) ++FramesToGet; | |
293 if(FramesToGet*InFrameSize>sh->a_in_buffer_size) | |
294 FramesToGet=sh->a_in_buffer_size/InFrameSize; | |
295 | |
296 InputBufferSize=FramesToGet*InFrameSize; | |
297 | |
8159 | 298 // printf("FramesToGet = %li (%li -> %li bytes)\n",FramesToGet, |
299 // InputBufferSize, FramesToGet*OutFrameSize); | |
8008 | 300 |
301 if(InputBufferSize>sh->a_in_buffer_len){ | |
302 int x=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], | |
303 InputBufferSize-sh->a_in_buffer_len); | |
304 if(x>0) sh->a_in_buffer_len+=x; | |
305 if(InputBufferSize>sh->a_in_buffer_len) | |
306 FramesToGet=sh->a_in_buffer_len/InFrameSize; // not enough data! | |
307 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
308 |
8159 | 309 // printf("\nSoundConverterConvertBuffer(myConv=%p,inbuf=%p,frames=%d,outbuf=%p,&convframes=%p,&convbytes=%p)\n", |
310 // myConverter,sh->a_in_buffer,FramesToGet,buf,&ConvertedFrames,&ConvertedBytes); | |
8008 | 311 error = SoundConverterConvertBuffer(myConverter,sh->a_in_buffer, |
312 FramesToGet,buf,&ConvertedFrames,&ConvertedBytes); | |
8159 | 313 // printf("SoundConverterConvertBuffer:%i\n",error); |
314 // printf("ConvertedFrames = %li\n",ConvertedFrames); | |
315 // printf("ConvertedBytes = %li\n",ConvertedBytes); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29212
diff
changeset
|
316 |
8389
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
317 // InputBufferSize=(ConvertedBytes/OutFrameSize)*InFrameSize; // FIXME!! |
e8c51ec86340
fixed in/out framesize rounding bug (causing low-rate QCLP hangup/looping)
arpi
parents:
8270
diff
changeset
|
318 InputBufferSize=FramesToGet*InFrameSize; |
8008 | 319 sh->a_in_buffer_len-=InputBufferSize; |
320 if(sh->a_in_buffer_len<0) sh->a_in_buffer_len=0; // should not happen... | |
321 else if(sh->a_in_buffer_len>0){ | |
322 memcpy(sh->a_in_buffer,&sh->a_in_buffer[InputBufferSize],sh->a_in_buffer_len); | |
323 } | |
324 | |
325 return ConvertedBytes; | |
326 } | |
327 | |
328 static int control(sh_audio_t *sh,int cmd,void* arg, ...){ | |
329 // various optional functions you MAY implement: | |
330 return CONTROL_UNKNOWN; | |
331 } |