Mercurial > mplayer.hg
annotate libmpcodecs/ad_roqaudio.c @ 7358:bb40478265df
I experienced several segfaults when trying to play (unencrypted) DVDs
from harddisk using xine/ogle/mplayer with the respective libdvdnav
support feature.
I found that while libdvdnav itself may do something wrong by trying
to read beyond the end of the files, it was actually the fault of libdvdread
that a segfault resulted. The following tiny patch fixes the problem
and it seems that libdvdnav can very well live with the "short read"
result it gets then - navigation worked fine after applying the patch:
patch by Peter Niemayer <niemayer@isg.de> & H}kan Hjort <d95hjort@dtek.chalmers.se>
author | arpi |
---|---|
date | Tue, 10 Sep 2002 20:33:31 +0000 |
parents | 1eadce15446c |
children | a117511790c0 |
rev | line source |
---|---|
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
1 #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
|
2 #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
|
3 #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
|
4 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
5 #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
|
6 #include "ad_internal.h" |
5603 | 7 #include "roqav.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
|
8 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
9 static ad_info_t info = |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
10 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
11 "Id RoQ File Audio Decoder", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
12 "roqaudio", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
13 "Nick Kurshev", |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
14 "Mike Melanson", |
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
15 "" //"RoQA is an internal MPlayer FOURCC" |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
16 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
17 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
18 LIBAD_EXTERN(roqaudio) |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
19 |
5349
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
20 static int preinit(sh_audio_t *sh_audio) |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
21 { |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
22 // minsize was stored in wf->nBlockAlign by the RoQ demuxer |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
23 sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign; |
5458 | 24 sh_audio->audio_in_minsize=sh_audio->audio_out_minsize / 2; // FIXME? |
5349
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
25 sh_audio->context = roq_decode_audio_init(); |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
26 return 1; |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
27 } |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
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 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
|
30 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
31 sh_audio->channels=sh_audio->wf->nChannels; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
32 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; |
5422 | 33 sh_audio->i_bps = 44100; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
34 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
|
35 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
36 |
5349
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
37 static void uninit(sh_audio_t *sh_audio) |
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 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
41 static int control(sh_audio_t *sh,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
|
42 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
43 // TODO!!! |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
44 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
|
45 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
46 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
47 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
|
48 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
49 unsigned char header_data[6]; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
50 int read_len; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
51 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
52 /* figure out how much data to read */ |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
53 if (demux_read_data(sh_audio->ds, header_data, 6) != 6) return -1; /* EOF */ |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
54 read_len = (header_data[5] << 24) | (header_data[4] << 16) | |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
55 (header_data[3] << 8) | header_data[2]; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
56 read_len += 2; /* 16-bit arguments */ |
5349
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
57 if (demux_read_data(sh_audio->ds, sh_audio->a_in_buffer, read_len) != |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
58 read_len) return -1; |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
59 return 2 * roq_decode_audio((unsigned short *)buf, sh_audio->a_in_buffer, |
80d11d6a5fca
fixed to work nicely with the new system (and yes, I did originate the RoQ
melanson
parents:
5340
diff
changeset
|
60 read_len, sh_audio->channels, sh_audio->context); |
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 } |