annotate libmpcodecs/ad_qtaudio.c @ 24147:2f9f0e7fe015

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