comparison libmpcodecs/ad_pcm.c @ 5340:0f12fb7c1c5d

imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
author arpi
date Mon, 25 Mar 2002 21:06:01 +0000
parents
children 0e63c2f19ba6
comparison
equal deleted inserted replaced
5339:e72d8e3955ea 5340:0f12fb7c1c5d
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4
5 #include "config.h"
6 #include "ad_internal.h"
7
8 static ad_info_t info =
9 {
10 "Uncompressed PCM audio decoder",
11 "pcm",
12 AFM_PCM,
13 "Nick Kurshev",
14 "A'rpi",
15 ""
16 };
17
18 LIBAD_EXTERN(pcm)
19
20 static int init(sh_audio_t *sh_audio)
21 {
22 WAVEFORMATEX *h=sh_audio->wf;
23 sh_audio->i_bps=h->nAvgBytesPerSec;
24 sh_audio->channels=h->nChannels;
25 sh_audio->samplerate=h->nSamplesPerSec;
26 sh_audio->samplesize=(h->wBitsPerSample+7)/8;
27 switch(sh_audio->format){ /* hardware formats: */
28 case 0x6: sh_audio->sample_format=AFMT_A_LAW;break;
29 case 0x7: sh_audio->sample_format=AFMT_MU_LAW;break;
30 case 0x11: sh_audio->sample_format=AFMT_IMA_ADPCM;break;
31 case 0x50: sh_audio->sample_format=AFMT_MPEG;break;
32 case 0x736F7774: sh_audio->sample_format=AFMT_S16_LE;sh_audio->codec->driver=AFM_DVDPCM;break;
33 /* case 0x2000: sh_audio->sample_format=AFMT_AC3; */
34 default: sh_audio->sample_format=(sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8;
35 }
36 return 1;
37 }
38
39 static int preinit(sh_audio_t *sh)
40 {
41 sh->audio_out_minsize=2048;
42 return 1;
43 }
44
45 static void uninit(sh_audio_t *sh)
46 {
47 }
48
49 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
50 {
51 int skip;
52 switch(cmd)
53 {
54 case ADCTRL_SKIP_FRAME:
55 skip=sh->i_bps/16;
56 skip=skip&(~3);
57 demux_read_data(sh->ds,NULL,skip);
58 return CONTROL_TRUE;
59 }
60 return CONTROL_UNKNOWN;
61 }
62
63 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
64 {
65 return demux_read_data(sh_audio->ds,buf,minlen);
66 }