annotate libmpcodecs/ad_acm.c @ 30521:828219ec9742

Remove useless casts.
author reimar
date Sun, 14 Feb 2010 11:09:24 +0000
parents cc27da5d7286
children df6c41f16b40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
19 #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
20 #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
21 #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
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 #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
24 #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
25 #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
26
22577
a033e5519802 Include loader/ prefix in #include path everywhere.
diego
parents: 18771
diff changeset
27 #include "loader/wineacm.h"
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
28
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
29 #include "ad_internal.h"
17092
rathann
parents: 16372
diff changeset
30 #include "osdep/timer.h"
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
31
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
32 static const ad_info_t info =
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
33 {
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
34 "Win32/ACM decoders",
5343
3dd532400d44 argh... Nick messed up driver names too
arpi
parents: 5340
diff changeset
35 "acm",
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
36 "A'rpi",
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
37 "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
38 ""
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
39 };
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
40
5343
3dd532400d44 argh... Nick messed up driver names too
arpi
parents: 5340
diff changeset
41 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
42
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
43 typedef struct {
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
44 WAVEFORMATEX *o_wf;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
45 HACMSTREAM handle;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
46 } 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
47
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
48 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
49 {
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
50 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
51 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
52 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
53 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
54 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
55 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
56 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
57 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 23912
diff changeset
59 void print_wave_header(WAVEFORMATEX *h, int verbose_level);
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8027
diff changeset
60
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
61 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
62 {
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
63 HRESULT ret;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
64 WAVEFORMATEX *in_fmt = sh_audio->wf;
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 8027
diff changeset
65 DWORD srcsize = 0;
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
66 acm_context_t *priv;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
67
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
68 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
69 if (!priv)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
70 return 0;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
71 sh_audio->context = priv;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
72
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
73 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
74
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
75 // priv->handle = NULL;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
76
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
77 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
78 if (!priv->o_wf)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
79 {
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_ERR,MSGTR_ACMiniterror);
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
81 return 0;
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
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
84 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
85 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
86 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
87 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
88 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
89 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
90 // 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
91 priv->o_wf->cbSize = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
92
17932
3fe3b2b3a6ce Convert all if(verbose>X) to mp_msg_test calls.
diego
parents: 17366
diff changeset
93 if ( mp_msg_test(MSGT_DECAUDIO,MSGL_V) )
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
94 {
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
95 mp_msg(MSGT_DECAUDIO, MSGL_V, "Input format:\n");
17977
f70772d02eaa Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents: 17932
diff changeset
96 print_wave_header(in_fmt, MSGL_V);
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
97 mp_msg(MSGT_DECAUDIO, MSGL_V, "Output format:\n");
17977
f70772d02eaa Convert printfs in aviprint.c to mp_msg and give the information printing
diego
parents: 17932
diff changeset
98 print_wave_header(priv->o_wf, MSGL_V);
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
99 }
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
100
7390
2357ee501582 fixed to comply with new loader
alex
parents: 7228
diff changeset
101 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
102 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
103 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
104 if (ret)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
105 {
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
106 if (ret == ACMERR_NOTPOSSIBLE)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
107 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
108 else
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
109 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
110 (int)ret);
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
111 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
112 return 0;
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 mp_msg(MSGT_WIN32, MSGL_V, "Audio codec opened OK! ;-)\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
115
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
116 acmStreamSize(priv->handle, in_fmt->nBlockAlign, &srcsize, ACM_STREAMSIZEF_SOURCE);
17932
3fe3b2b3a6ce Convert all if(verbose>X) to mp_msg_test calls.
diego
parents: 17366
diff changeset
117 //if ( mp_msg_test(MSGT_DECAUDIO,MSGL_V) ) printf("Audio ACM output buffer min. size: %ld (reported by codec)\n", srcsize);
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
118 srcsize *= 2;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
119 //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
120 if (!srcsize)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
121 {
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
122 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
123 srcsize = 16384;
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 // 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
126 //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
127 //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
128 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
129 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
130
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
131 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
132 // 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
133
11683
edd57e928b94 workaround for min_srcsize==0 (scg726.acm)
arpi
parents: 11678
diff changeset
134 if (!srcsize)
edd57e928b94 workaround for min_srcsize==0 (scg726.acm)
arpi
parents: 11678
diff changeset
135 {
edd57e928b94 workaround for min_srcsize==0 (scg726.acm)
arpi
parents: 11678
diff changeset
136 mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n");
edd57e928b94 workaround for min_srcsize==0 (scg726.acm)
arpi
parents: 11678
diff changeset
137 srcsize = 2*in_fmt->nBlockAlign;
edd57e928b94 workaround for min_srcsize==0 (scg726.acm)
arpi
parents: 11678
diff changeset
138 }
edd57e928b94 workaround for min_srcsize==0 (scg726.acm)
arpi
parents: 11678
diff changeset
139
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
140 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
141
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
142 sh_audio->audio_in_minsize=2*srcsize; // audio input min. size
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
143
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
144 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
145 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
146 sh_audio->samplerate=priv->o_wf->nSamplesPerSec;
13427
9d0b052c4f74 setting samplesize to 2 in decoders where neccessary.
reimar
parents: 11683
diff changeset
147 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
148
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
149 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
150 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
151 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
152
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
153 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
154 {
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
155 HRESULT ret;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
156 acm_context_t *priv = sh->context;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
157
23912
de63d6fc46dd Use goto instead of useless recursion that might fill up the stack
reimar
parents: 23911
diff changeset
158 retry:
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
159 ret = acmStreamClose(priv->handle, 0);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
160
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
161 if (ret)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
162 switch(ret)
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
163 {
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
164 case ACMERR_BUSY:
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
165 case ACMERR_CANCELED:
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
166 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
167 usec_sleep(100000000);
23912
de63d6fc46dd Use goto instead of useless recursion that might fill up the stack
reimar
parents: 23911
diff changeset
168 goto retry;
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
169 case ACMERR_UNPREPARED:
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
170 case ACMERR_NOTPOSSIBLE:
7471
5e56ce70b551 wine headers cleanup
arpi
parents: 7390
diff changeset
171 return;
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
172 default:
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17092
diff changeset
173 mp_msg(MSGT_WIN32, MSGL_WARN, "ACM_Decoder: unknown error occurred: %ld\n", ret);
7471
5e56ce70b551 wine headers cleanup
arpi
parents: 7390
diff changeset
174 return;
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
175 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
176
7390
2357ee501582 fixed to comply with new loader
alex
parents: 7228
diff changeset
177 MSACM_UnregisterAllDrivers();
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
178
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
179 free(priv->o_wf);
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
180 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
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
183 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
184 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
185 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
186 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
187 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
188 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
189 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
190 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
191 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
192 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
193 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
194 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
195 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
196 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
197 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
198 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
199
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
200 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
201 {
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
202 ACMSTREAMHEADER ash;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
203 HRESULT hr;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
204 DWORD srcsize=0;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
205 DWORD len=minlen;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
206 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
207
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
208 acmStreamSize(priv->handle, len, &srcsize, ACM_STREAMSIZEF_DESTINATION);
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17092
diff changeset
209 mp_msg(MSGT_WIN32,MSGL_DBG3,"acm says: srcsize=%ld (buffsize=%d) out_size=%ld\n",srcsize,sh_audio->a_in_buffer_size,len);
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
210
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
211 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
212 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
213 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
214 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
215 }
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
216
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
217 // 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
218 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
219 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
220 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
221 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
222 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
223 }
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17092
diff changeset
224 mp_msg(MSGT_WIN32,MSGL_DBG3,"acm convert %d -> %ld bytes\n",sh_audio->a_in_buffer_len,len);
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
225 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
226 ash.cbStruct=sizeof(ash);
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
227 ash.fdwStatus=0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
228 ash.dwUser=0;
7228
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
229 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
230 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
231 ash.pbDst=buf;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
232 ash.cbDstLength=len;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
233 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
234 if(hr){
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
235 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
236 return -1;
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 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
239 if(hr){
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
240 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
241 switch(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 case ACMERR_NOTPOSSIBLE:
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
244 case ACMERR_UNPREPARED:
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
245 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
246 }
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
247 // return -1;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
248 }
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 17092
diff changeset
249 mp_msg(MSGT_WIN32,MSGL_DBG2,"acm converted %ld -> %ld\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
250 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
251 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
252 } else {
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
253 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
254 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
255 }
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
256 len=ash.cbDstLengthUsed;
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
257 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
258 if(hr){
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
259 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
260 }
0a21be7df603 merged with dll_init.c, moved some variables from sh_audio to private struct
alex
parents: 7191
diff changeset
261 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
262 }