5345
|
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 "native MSGSM audio decoder",
|
|
11 "msgsm",
|
|
12 "A'rpi",
|
|
13 "XAnim",
|
|
14 ""
|
|
15 };
|
|
16
|
|
17 LIBAD_EXTERN(msgsm)
|
|
18
|
5603
|
19 #include "xa_gsm.h"
|
5345
|
20
|
|
21 static int init(sh_audio_t *sh_audio)
|
|
22 {
|
|
23 if(!sh_audio->wf) return 0;
|
|
24 // MS-GSM audio codec:
|
|
25 GSM_Init();
|
|
26 sh_audio->channels=sh_audio->wf->nChannels;
|
|
27 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
|
|
28 // decodes 65 byte -> 320 short
|
|
29 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
|
|
30 // 1 frame: 320 samples
|
|
31 sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320; // 1:10
|
|
32 return 1;
|
|
33 }
|
|
34
|
|
35 static int preinit(sh_audio_t *sh_audio)
|
|
36 {
|
|
37 sh_audio->audio_out_minsize=4*320;
|
|
38 return 1;
|
|
39 }
|
|
40
|
|
41 static void uninit(sh_audio_t *sh)
|
|
42 {
|
|
43 }
|
|
44
|
|
45 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
|
|
46 {
|
|
47 return CONTROL_UNKNOWN;
|
|
48 }
|
|
49
|
|
50 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
|
|
51 {
|
|
52 unsigned char ibuf[65]; // 65 bytes / frame
|
|
53 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
|
|
54 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
|
|
55 return 2*320;
|
|
56 }
|