Mercurial > mplayer.hg
annotate libmpcodecs/ad_acm.c @ 17009:48a041427dbb
libavformat seems to use "Vo" as Vorbis tag, so add that.
author | reimar |
---|---|
date | Thu, 17 Nov 2005 22:31:28 +0000 |
parents | b313a38c69cb |
children | c0068de90f44 |
rev | line source |
---|---|
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
1 #include <stdio.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
2 #include <stdlib.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
3 #include <unistd.h> |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
4 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
5 #include "config.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
6 #include "mp_msg.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
7 #include "help_mp.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
8 |
5343 | 9 #ifdef USE_WIN32DLL |
10 | |
7471 | 11 #include "wineacm.h" |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
12 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
13 #include "ad_internal.h" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
14 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
15 static ad_info_t info = |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
16 { |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
17 "Win32/ACM decoders", |
5343 | 18 "acm", |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
19 "A'rpi", |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
20 "A'rpi & Alex", |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
21 "" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
22 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
23 |
5343 | 24 LIBAD_EXTERN(acm) |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
25 |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
26 typedef struct { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
27 WAVEFORMATEX *o_wf; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
28 HACMSTREAM handle; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
29 } acm_context_t; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
30 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
31 static int init(sh_audio_t *sh_audio) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
32 { |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
33 int ret=decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size); |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
34 if(ret<0){ |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
35 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"ACM decoding error: %d\n",ret); |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
36 return 0; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
37 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
38 sh_audio->a_buffer_len=ret; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
39 return 1; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
40 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
41 |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
42 extern void print_wave_header(WAVEFORMATEX *h); |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
43 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
44 static int preinit(sh_audio_t *sh_audio) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
45 { |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
46 HRESULT ret; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
47 WAVEFORMATEX *in_fmt = sh_audio->wf; |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
8027
diff
changeset
|
48 DWORD srcsize = 0; |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
49 acm_context_t *priv; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
50 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
51 priv = malloc(sizeof(acm_context_t)); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
52 if (!priv) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
53 return 0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
54 sh_audio->context = priv; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
55 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
56 mp_msg(MSGT_WIN32, MSGL_V, "======= Win32 (ACM) AUDIO Codec init =======\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
57 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
58 // priv->handle = NULL; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
59 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
60 priv->o_wf = malloc(sizeof(WAVEFORMATEX)); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
61 if (!priv->o_wf) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
62 { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
63 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
64 return 0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
65 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
66 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
67 priv->o_wf->nChannels = in_fmt->nChannels; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
68 priv->o_wf->nSamplesPerSec = in_fmt->nSamplesPerSec; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
69 priv->o_wf->nAvgBytesPerSec = 2*in_fmt->nSamplesPerSec*in_fmt->nChannels; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
70 priv->o_wf->wFormatTag = WAVE_FORMAT_PCM; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
71 priv->o_wf->nBlockAlign = 2*in_fmt->nChannels; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
72 priv->o_wf->wBitsPerSample = 16; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
73 // priv->o_wf->wBitsPerSample = inf_fmt->wBitsPerSample; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
74 priv->o_wf->cbSize = 0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
75 |
8027 | 76 if (verbose>0) |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
77 { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
78 mp_msg(MSGT_DECAUDIO, MSGL_V, "Input format:\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
79 print_wave_header(in_fmt); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
80 mp_msg(MSGT_DECAUDIO, MSGL_V, "Output format:\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
81 print_wave_header(priv->o_wf); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
82 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
83 |
7390 | 84 MSACM_RegisterDriver((const char *)sh_audio->codec->dll, in_fmt->wFormatTag, 0); |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
85 ret = acmStreamOpen(&priv->handle, (HACMDRIVER)NULL, in_fmt, |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
86 priv->o_wf, NULL, 0, 0, 0); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
87 if (ret) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
88 { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
89 if (ret == ACMERR_NOTPOSSIBLE) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
90 mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: Unappropriate audio format\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
91 else |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
92 mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: acmStreamOpen error: %d\n", |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
93 (int)ret); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
94 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_ACMiniterror); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
95 return 0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
96 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
97 mp_msg(MSGT_WIN32, MSGL_V, "Audio codec opened OK! ;-)\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
98 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
99 acmStreamSize(priv->handle, in_fmt->nBlockAlign, &srcsize, ACM_STREAMSIZEF_SOURCE); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
100 //if (verbose) printf("Audio ACM output buffer min. size: %ld (reported by codec)\n", srcsize); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
101 srcsize *= 2; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
102 //if (srcsize < MAX_OUTBURST) srcsize = MAX_OUTBURST; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
103 if (!srcsize) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
104 { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
105 mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
106 srcsize = 16384; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
107 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
108 // limit srcsize to 4-16kb |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
109 //while(srcsize && srcsize<4096) srcsize*=2; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
110 //while(srcsize>16384) srcsize/=2; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
111 sh_audio->audio_out_minsize=srcsize; // audio output min. size |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
112 mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM output buffer min. size: %ld\n",srcsize); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
113 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
114 acmStreamSize(priv->handle, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
115 // if(srcsize<in_fmt->nBlockAlign) srcsize=in_fmt->nBlockAlign; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
116 |
11683 | 117 if (!srcsize) |
118 { | |
119 mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n"); | |
120 srcsize = 2*in_fmt->nBlockAlign; | |
121 } | |
122 | |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
123 mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM input buffer min. size: %ld\n",srcsize); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
124 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
125 sh_audio->audio_in_minsize=2*srcsize; // audio input min. size |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
126 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
127 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
128 sh_audio->channels=priv->o_wf->nChannels; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
129 sh_audio->samplerate=priv->o_wf->nSamplesPerSec; |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
11683
diff
changeset
|
130 sh_audio->samplesize=2; |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
131 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
132 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/ACM audio codec init OK!\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
133 return 1; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
134 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
135 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
136 static void uninit(sh_audio_t *sh) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
137 { |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
138 HRESULT ret; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
139 acm_context_t *priv = sh->context; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
140 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
141 ret = acmStreamClose(priv->handle, 0); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
142 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
143 if (ret) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
144 switch(ret) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
145 { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
146 case ACMERR_BUSY: |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
147 case ACMERR_CANCELED: |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
148 mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: stream busy, waiting..\n"); |
16372
b313a38c69cb
replace sleep with usec_sleep, required for recent mingw versions, patch by Robert Swain <robert.swain at gmail.com>
faust3
parents:
13427
diff
changeset
|
149 usec_sleep(100000000); |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
150 return(uninit(sh)); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
151 case ACMERR_UNPREPARED: |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
152 case ACMERR_NOTPOSSIBLE: |
7471 | 153 return; |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
154 default: |
11678
972d1998bde9
occured --> occurred typo patch by Clinton Roy <croy@dstc.edu.au>
diego
parents:
8123
diff
changeset
|
155 mp_msg(MSGT_WIN32, MSGL_WARN, "ACM_Decoder: unknown error occurred: %d\n", ret); |
7471 | 156 return; |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
157 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
158 |
7390 | 159 MSACM_UnregisterAllDrivers(); |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
160 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
161 free(priv->o_wf); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
162 free(priv); |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
163 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
164 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
165 static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
166 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
167 int skip; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
168 switch(cmd) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
169 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
170 case ADCTRL_SKIP_FRAME: |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
171 skip=sh_audio->wf->nBlockAlign; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
172 if(skip<16){ |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
173 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7); |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
174 if(skip<16) skip=16; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
175 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
176 demux_read_data(sh_audio->ds,NULL,skip); |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
177 return CONTROL_TRUE; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
178 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
179 return CONTROL_UNKNOWN; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
180 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
181 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
182 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
183 { |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
184 ACMSTREAMHEADER ash; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
185 HRESULT hr; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
186 DWORD srcsize=0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
187 DWORD len=minlen; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
188 acm_context_t *priv = sh_audio->context; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
189 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
190 acmStreamSize(priv->handle, len, &srcsize, ACM_STREAMSIZEF_DESTINATION); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
191 mp_msg(MSGT_WIN32,MSGL_DBG3,"acm says: srcsize=%ld (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,len); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
192 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
193 if(srcsize<sh_audio->wf->nBlockAlign){ |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
194 srcsize=sh_audio->wf->nBlockAlign; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
195 acmStreamSize(priv->handle, srcsize, &len, ACM_STREAMSIZEF_SOURCE); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
196 if(len>maxlen) len=maxlen; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
197 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
198 |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
199 // if(srcsize==0) srcsize=((WAVEFORMATEX *)&sh_audio->o_wf_ext)->nBlockAlign; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
200 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
201 if(sh_audio->a_in_buffer_len<srcsize){ |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
202 sh_audio->a_in_buffer_len+= |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
203 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
204 srcsize-sh_audio->a_in_buffer_len); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
205 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
206 mp_msg(MSGT_WIN32,MSGL_DBG3,"acm convert %d -> %d bytes\n",sh_audio->a_in_buffer_len,len); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
207 memset(&ash, 0, sizeof(ash)); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
208 ash.cbStruct=sizeof(ash); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
209 ash.fdwStatus=0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
210 ash.dwUser=0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
211 ash.pbSrc=sh_audio->a_in_buffer; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
212 ash.cbSrcLength=sh_audio->a_in_buffer_len; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
213 ash.pbDst=buf; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
214 ash.cbDstLength=len; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
215 hr=acmStreamPrepareHeader(priv->handle,&ash,0); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
216 if(hr){ |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
217 mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamPrepareHeader error %d\n",(int)hr); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
218 return -1; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
219 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
220 hr=acmStreamConvert(priv->handle,&ash,0); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
221 if(hr){ |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
222 mp_msg(MSGT_WIN32,MSGL_DBG2,"ACM_Decoder: acmStreamConvert error %d\n",(int)hr); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
223 switch(hr) |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
224 { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
225 case ACMERR_NOTPOSSIBLE: |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
226 case ACMERR_UNPREPARED: |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
227 mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: acmStreamConvert error: probarly not initialized!\n"); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
228 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
229 // return -1; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
230 } |
8027 | 231 mp_msg(MSGT_WIN32,MSGL_DBG2,"acm converted %d -> %d\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed); |
7228
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
232 if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){ |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
233 sh_audio->a_in_buffer_len=0; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
234 } else { |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
235 sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
236 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[ash.cbSrcLengthUsed],sh_audio->a_in_buffer_len); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
237 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
238 len=ash.cbDstLengthUsed; |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
239 hr=acmStreamUnprepareHeader(priv->handle,&ash,0); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
240 if(hr){ |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
241 mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamUnprepareHeader error %d\n",(int)hr); |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
242 } |
0a21be7df603
merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents:
7191
diff
changeset
|
243 return len; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
244 } |
5343 | 245 #endif |