Use proper length specifiers in mp_msg calls, fixes the warnings:
[mplayer/greg.git] / libmpcodecs / ad_dshow.c
blob24c34966bc562536b0293f81a99f309c6be90664
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
5 #include "config.h"
6 #include "mp_msg.h"
7 #include "help_mp.h"
9 #include "ad_internal.h"
11 static ad_info_t info =
13 "Win32/DirectShow decoders",
14 "dshow",
15 "Nick Kurshev",
16 "avifile.sf.net",
20 LIBAD_EXTERN(dshow)
22 #include "loader/dshow/DS_AudioDecoder.h"
24 static int init(sh_audio_t *sh)
26 return 1;
29 static int preinit(sh_audio_t *sh_audio)
31 DS_AudioDecoder* ds_adec;
32 if(!(ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf)))
34 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll);
35 return 0;
37 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
38 sh_audio->channels=sh_audio->wf->nChannels;
39 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
40 sh_audio->samplesize=2;
41 sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign;
42 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
43 sh_audio->audio_out_minsize=16384;
44 sh_audio->context = ds_adec;
45 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow audio codec init OK!\n");
46 return 1;
49 static void uninit(sh_audio_t *sh)
51 DS_AudioDecoder* ds_adec = sh->context;
52 DS_AudioDecoder_Destroy(ds_adec);
55 static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
57 int skip;
58 switch(cmd)
60 case ADCTRL_SKIP_FRAME:
61 skip=sh_audio->wf->nBlockAlign;
62 if(skip<16){
63 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7);
64 if(skip<16) skip=16;
66 demux_read_data(sh_audio->ds,NULL,skip);
67 return CONTROL_TRUE;
69 return CONTROL_UNKNOWN;
72 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
74 DS_AudioDecoder* ds_adec = sh_audio->context;
75 // int len=-1;
76 int size_in=0;
77 int size_out=0;
78 int srcsize=DS_AudioDecoder_GetSrcSize(ds_adec, maxlen);
79 mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
80 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
81 if(sh_audio->a_in_buffer_len<srcsize){
82 sh_audio->a_in_buffer_len+=
83 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
84 srcsize-sh_audio->a_in_buffer_len);
86 DS_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
87 buf,maxlen, &size_in,&size_out);
88 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DShow: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds));
89 if(size_in>=sh_audio->a_in_buffer_len){
90 sh_audio->a_in_buffer_len=0;
91 } else {
92 sh_audio->a_in_buffer_len-=size_in;
93 memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
95 // len=size_out;
96 return size_out;