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