summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio_dec/ff_dvaudio_decoder.c8
-rw-r--r--src/audio_dec/fooaudio.c4
-rw-r--r--src/audio_dec/gsm610.c6
-rw-r--r--src/audio_dec/xine_a52_decoder.c4
-rw-r--r--src/audio_dec/xine_dts_decoder.c4
-rw-r--r--src/audio_dec/xine_faad_decoder.c8
-rw-r--r--src/audio_dec/xine_lpcm_decoder.c4
-rw-r--r--src/audio_dec/xine_mad_decoder.c4
-rw-r--r--src/audio_dec/xine_musepack_decoder.c6
-rw-r--r--src/audio_out/audio_alsa_out.c48
-rw-r--r--src/audio_out/audio_coreaudio_out.c4
-rw-r--r--src/audio_out/audio_directx2_out.c4
-rw-r--r--src/audio_out/audio_directx_out.c4
-rw-r--r--src/audio_out/audio_esd_out.c4
-rw-r--r--src/audio_out/audio_file_out.c4
-rw-r--r--src/audio_out/audio_fusionsound_out.c6
-rw-r--r--src/audio_out/audio_jack_out.c1094
-rw-r--r--src/audio_out/audio_none_out.c4
-rw-r--r--src/audio_out/audio_oss_out.c43
-rw-r--r--src/audio_out/audio_pulse_out.c28
-rw-r--r--src/audio_out/audio_sun_out.c4
-rw-r--r--src/combined/ffmpeg/ff_audio_decoder.c18
-rw-r--r--src/combined/ffmpeg/ff_mpeg_parser.c2
-rw-r--r--src/combined/ffmpeg/ff_video_decoder.c35
-rw-r--r--src/combined/flac_decoder.c6
-rw-r--r--src/combined/flac_demuxer.c4
-rw-r--r--src/combined/nsf_decoder.c6
-rw-r--r--src/combined/nsf_demuxer.c4
-rw-r--r--src/combined/wavpack_combined.h1
-rw-r--r--src/combined/wavpack_decoder.c4
-rw-r--r--src/combined/wavpack_demuxer.c4
-rw-r--r--src/combined/xine_ogg_demuxer.c75
-rw-r--r--src/combined/xine_speex_decoder.c20
-rw-r--r--src/combined/xine_theora_decoder.c4
-rw-r--r--src/combined/xine_vorbis_decoder.c6
-rw-r--r--src/demuxers/asfheader.c13
-rw-r--r--src/demuxers/asfheader.h2
-rw-r--r--src/demuxers/demux_4xm.c6
-rw-r--r--src/demuxers/demux_aac.c4
-rw-r--r--src/demuxers/demux_ac3.c4
-rw-r--r--src/demuxers/demux_aiff.c6
-rw-r--r--src/demuxers/demux_asf.c4
-rw-r--r--src/demuxers/demux_aud.c4
-rw-r--r--src/demuxers/demux_avi.c20
-rw-r--r--src/demuxers/demux_cdda.c4
-rw-r--r--src/demuxers/demux_dts.c4
-rw-r--r--src/demuxers/demux_eawve.c4
-rw-r--r--src/demuxers/demux_elem.c4
-rw-r--r--src/demuxers/demux_film.c9
-rw-r--r--src/demuxers/demux_flac.c4
-rw-r--r--src/demuxers/demux_fli.c4
-rw-r--r--src/demuxers/demux_flv.c6
-rw-r--r--src/demuxers/demux_idcin.c4
-rw-r--r--src/demuxers/demux_iff.c28
-rw-r--r--src/demuxers/demux_image.c4
-rw-r--r--src/demuxers/demux_ipmovie.c4
-rw-r--r--src/demuxers/demux_matroska.c17
-rw-r--r--src/demuxers/demux_mng.c4
-rw-r--r--src/demuxers/demux_mod.c4
-rw-r--r--src/demuxers/demux_mpc.c10
-rw-r--r--src/demuxers/demux_mpeg.c4
-rw-r--r--src/demuxers/demux_mpeg_block.c4
-rw-r--r--src/demuxers/demux_mpeg_pes.c9
-rw-r--r--src/demuxers/demux_mpgaudio.c16
-rw-r--r--src/demuxers/demux_nsv.c4
-rw-r--r--src/demuxers/demux_pva.c4
-rw-r--r--src/demuxers/demux_qt.c19
-rw-r--r--src/demuxers/demux_rawdv.c4
-rw-r--r--src/demuxers/demux_real.c12
-rw-r--r--src/demuxers/demux_realaudio.c8
-rw-r--r--src/demuxers/demux_roq.c4
-rw-r--r--src/demuxers/demux_shn.c4
-rw-r--r--src/demuxers/demux_slave.c10
-rw-r--r--src/demuxers/demux_smjpeg.c4
-rw-r--r--src/demuxers/demux_snd.c4
-rw-r--r--src/demuxers/demux_str.c8
-rw-r--r--src/demuxers/demux_ts.c53
-rw-r--r--src/demuxers/demux_tta.c4
-rw-r--r--src/demuxers/demux_vmd.c4
-rw-r--r--src/demuxers/demux_voc.c4
-rw-r--r--src/demuxers/demux_vox.c4
-rw-r--r--src/demuxers/demux_vqa.c4
-rw-r--r--src/demuxers/demux_wav.c9
-rw-r--r--src/demuxers/demux_wc3movie.c4
-rw-r--r--src/demuxers/demux_yuv4mpeg2.c4
-rw-r--r--src/demuxers/demux_yuv_frames.c4
-rw-r--r--src/demuxers/ebml.h2
-rw-r--r--src/demuxers/id3.c20
-rw-r--r--src/demuxers/id3.h23
-rw-r--r--src/dxr3/dxr3_decode_spu.c6
-rw-r--r--src/dxr3/dxr3_decode_video.c4
-rw-r--r--src/dxr3/dxr3_mpeg_encoders.c4
-rw-r--r--src/dxr3/dxr3_scr.c2
-rw-r--r--src/dxr3/ffmpeg_encoder.c8
-rw-r--r--src/dxr3/video_out_dxr3.c16
-rw-r--r--src/input/input_cdda.c58
-rw-r--r--src/input/input_dvb.c82
-rw-r--r--src/input/input_dvd.c63
-rw-r--r--src/input/input_file.c48
-rw-r--r--src/input/input_http.c47
-rw-r--r--src/input/input_mms.c4
-rw-r--r--src/input/input_net.c4
-rw-r--r--src/input/input_pnm.c4
-rw-r--r--src/input/input_pvr.c14
-rw-r--r--src/input/input_rtp.c4
-rw-r--r--src/input/input_rtsp.c7
-rw-r--r--src/input/input_smb.c42
-rw-r--r--src/input/input_stdin_fifo.c4
-rw-r--r--src/input/input_v4l.c168
-rw-r--r--src/input/input_vcd.c67
-rw-r--r--src/input/libreal/asmrp.c2
-rw-r--r--src/input/libreal/real.c11
-rw-r--r--src/input/libreal/rmff.h6
-rw-r--r--src/input/libreal/sdpplin.c8
-rw-r--r--src/input/libreal/sdpplin.h2
-rw-r--r--src/input/librtsp/rtsp.c42
-rw-r--r--src/input/librtsp/rtsp.h2
-rw-r--r--src/input/librtsp/rtsp_session.c2
-rw-r--r--src/input/librtsp/rtsp_session.h2
-rw-r--r--src/input/mms.c14
-rw-r--r--src/input/mmsh.c6
-rw-r--r--src/input/net_buf_ctrl.c2
-rw-r--r--src/input/net_buf_ctrl.h2
-rw-r--r--src/input/pnm.c15
-rw-r--r--src/input/vcd/xine-extra.c10
-rw-r--r--src/input/vcd/xineplug_inp_vcd.c2
-rw-r--r--src/libmpeg2new/xine_mpeg2new_decoder.c4
-rw-r--r--src/libreal/xine_real_audio_decoder.c10
-rw-r--r--src/libreal/xine_real_video_decoder.c6
-rw-r--r--src/libw32dll/qt_decoder.c8
-rw-r--r--src/libw32dll/w32codec.c8
-rw-r--r--src/libw32dll/wine/win32.c4
-rw-r--r--src/post/audio/stretch.c6
-rw-r--r--src/post/audio/upmix.c4
-rw-r--r--src/post/audio/upmix_mono.c34
-rw-r--r--src/post/audio/volnorm.c7
-rw-r--r--src/post/deinterlace/xine_plugin.c4
-rw-r--r--src/post/goom/goom_core.c4
-rw-r--r--src/post/goom/xine_goom.c4
-rw-r--r--src/post/mosaico/mosaico.c13
-rw-r--r--src/post/mosaico/switch.c4
-rw-r--r--src/post/planar/boxblur.c2
-rw-r--r--src/post/planar/denoise3d.c2
-rw-r--r--src/post/planar/eq.c2
-rw-r--r--src/post/planar/eq2.c29
-rw-r--r--src/post/planar/expand.c2
-rw-r--r--src/post/planar/fill.c2
-rw-r--r--src/post/planar/invert.c2
-rw-r--r--src/post/planar/noise.c2
-rw-r--r--src/post/planar/pp.c6
-rw-r--r--src/post/planar/unsharp.c9
-rw-r--r--src/post/visualizations/fftgraph.c2
-rw-r--r--src/post/visualizations/fftscope.c2
-rw-r--r--src/post/visualizations/fooviz.c2
-rw-r--r--src/post/visualizations/oscope.c2
-rw-r--r--src/spu_dec/cc_decoder.c6
-rw-r--r--src/spu_dec/cmml_decoder.c54
-rw-r--r--src/spu_dec/spu_decoder.c10
-rw-r--r--src/spu_dec/spudec.c2
-rw-r--r--src/spu_dec/spudvb_decoder.c10
-rw-r--r--src/spu_dec/sputext_decoder.c6
-rw-r--r--src/spu_dec/sputext_demuxer.c47
-rw-r--r--src/spu_dec/xine_cc_decoder.c4
-rw-r--r--src/vdr/input_vdr.c53
-rw-r--r--src/video_dec/bitplane.c32
-rw-r--r--src/video_dec/foovideo.c4
-rw-r--r--src/video_dec/gdkpixbuf.c4
-rw-r--r--src/video_dec/image.c4
-rw-r--r--src/video_dec/libmpeg2/xine_mpeg2_decoder.c4
-rw-r--r--src/video_dec/rgb.c6
-rw-r--r--src/video_dec/yuv.c4
-rw-r--r--src/video_out/Makefile.am7
-rw-r--r--src/video_out/video_out_aa.c6
-rw-r--r--src/video_out/video_out_caca.c6
-rw-r--r--src/video_out/video_out_directfb.c14
-rw-r--r--src/video_out/video_out_directx.c6
-rw-r--r--src/video_out/video_out_fb.c8
-rw-r--r--src/video_out/video_out_macosx.m6
-rw-r--r--src/video_out/video_out_none.c6
-rw-r--r--src/video_out/video_out_opengl.c18
-rw-r--r--src/video_out/video_out_pgx32.c6
-rw-r--r--src/video_out/video_out_pgx64.c6
-rw-r--r--src/video_out/video_out_raw.c586
-rw-r--r--src/video_out/video_out_sdl.c6
-rw-r--r--src/video_out/video_out_stk.c6
-rw-r--r--src/video_out/video_out_vidix.c6
-rw-r--r--src/video_out/video_out_xcbshm.c6
-rw-r--r--src/video_out/video_out_xcbxv.c6
-rw-r--r--src/video_out/video_out_xshm.c8
-rw-r--r--src/video_out/video_out_xv.c10
-rw-r--r--src/video_out/video_out_xvmc.c9
-rw-r--r--src/video_out/video_out_xxmc.c6
-rw-r--r--src/video_out/x11osd.c2
-rw-r--r--src/video_out/xcbosd.c2
-rw-r--r--src/video_out/yuv2rgb.c2
-rw-r--r--src/video_out/yuv2rgb_mlib.c2
-rw-r--r--src/xine-engine/Makefile.am2
-rw-r--r--src/xine-engine/alphablend.c8
-rw-r--r--src/xine-engine/audio_out.c16
-rw-r--r--src/xine-engine/broadcaster.c2
-rw-r--r--src/xine-engine/buffer.c4
-rw-r--r--src/xine-engine/configfile.c11
-rw-r--r--src/xine-engine/demux.c9
-rw-r--r--src/xine-engine/info_helper.c13
-rw-r--r--src/xine-engine/input_cache.c7
-rw-r--r--src/xine-engine/input_rip.c10
-rw-r--r--src/xine-engine/load_plugins.c308
-rw-r--r--src/xine-engine/load_plugins.h50
-rw-r--r--src/xine-engine/lrb.c2
-rw-r--r--src/xine-engine/metronom.c8
-rw-r--r--src/xine-engine/osd.c30
-rw-r--r--src/xine-engine/post.c14
-rw-r--r--src/xine-engine/refcounter.c2
-rw-r--r--src/xine-engine/scratch.c11
-rw-r--r--src/xine-engine/video_decoder.c1
-rw-r--r--src/xine-engine/video_out.c6
-rw-r--r--src/xine-engine/video_overlay.c6
-rw-r--r--src/xine-engine/xine.c194
-rw-r--r--src/xine-engine/xine_interface.c4
-rw-r--r--src/xine-engine/xine_private.h97
-rw-r--r--src/xine-utils/Makefile.am2
-rw-r--r--src/xine-utils/list.c4
-rw-r--r--src/xine-utils/pool.c2
-rw-r--r--src/xine-utils/utils.c52
-rw-r--r--src/xine-utils/xine_buffer.c4
-rw-r--r--src/xine-utils/xine_check.c79
-rw-r--r--src/xine-utils/xine_check.h35
-rw-r--r--src/xine-utils/xmllexer.c3
-rw-r--r--src/xine-utils/xmlparser.c16
229 files changed, 3018 insertions, 1878 deletions
diff --git a/src/audio_dec/ff_dvaudio_decoder.c b/src/audio_dec/ff_dvaudio_decoder.c
index 237ec5b6d..eba6dee4a 100644
--- a/src/audio_dec/ff_dvaudio_decoder.c
+++ b/src/audio_dec/ff_dvaudio_decoder.c
@@ -224,10 +224,10 @@ static void dvaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
return;
if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
+ this->buf = calloc(1, AUDIOBUFSIZE);
this->bufsize = AUDIOBUFSIZE;
this->size = 0;
- this->decode_buffer = xine_xmalloc(MAXFRAMESIZE);
+ this->decode_buffer = calloc(1, MAXFRAMESIZE);
this->audio_sample_rate = buf->decoder_info[1];
this->audio_bits = buf->decoder_info[2];
@@ -341,7 +341,7 @@ static audio_decoder_t *dvaudio_open_plugin (audio_decoder_class_t *class_gen, x
dvaudio_decoder_t *this ;
- this = (dvaudio_decoder_t *) xine_xmalloc (sizeof (dvaudio_decoder_t));
+ this = calloc(1, sizeof (dvaudio_decoder_t));
this->audio_decoder.decode_data = dvaudio_decode_data;
this->audio_decoder.reset = dvaudio_reset;
@@ -362,7 +362,7 @@ static void *init_dvaudio_plugin (xine_t *xine, void *data) {
dvaudio_class_t *this ;
- this = (dvaudio_class_t *) xine_xmalloc (sizeof (dvaudio_class_t));
+ this = calloc(1, sizeof (dvaudio_class_t));
this->decoder_class.open_plugin = dvaudio_open_plugin;
this->decoder_class.identifier = "dv audio";
diff --git a/src/audio_dec/fooaudio.c b/src/audio_dec/fooaudio.c
index 34a3f2d48..756b9019a 100644
--- a/src/audio_dec/fooaudio.c
+++ b/src/audio_dec/fooaudio.c
@@ -91,7 +91,7 @@ static void fooaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->channels = buf->decoder_info[3];
/* initialize the data accumulation buffer */
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
+ this->buf = calloc(1, AUDIOBUFSIZE);
this->bufsize = AUDIOBUFSIZE;
this->size = 0;
@@ -255,7 +255,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
fooaudio_decoder_t *this ;
- this = (fooaudio_decoder_t *) xine_xmalloc (sizeof (fooaudio_decoder_t));
+ this = (fooaudio_decoder_t *) calloc(1, sizeof(fooaudio_decoder_t));
/* connect the member functions */
this->audio_decoder.decode_data = fooaudio_decode_data;
diff --git a/src/audio_dec/gsm610.c b/src/audio_dec/gsm610.c
index a0226638a..25f54d310 100644
--- a/src/audio_dec/gsm610.c
+++ b/src/audio_dec/gsm610.c
@@ -100,7 +100,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if (buf->decoder_flags & BUF_FLAG_STDHEADER) {
this->sample_rate = buf->decoder_info[1];
- this->buf = xine_xmalloc(AUDIOBUFSIZE);
+ this->buf = calloc(1, AUDIOBUFSIZE);
this->bufsize = AUDIOBUFSIZE;
this->size = 0;
@@ -233,7 +233,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
gsm610_decoder_t *this ;
- this = (gsm610_decoder_t *) xine_xmalloc (sizeof (gsm610_decoder_t));
+ this = (gsm610_decoder_t *) calloc(1, sizeof(gsm610_decoder_t));
this->audio_decoder.decode_data = gsm610_decode_data;
this->audio_decoder.reset = gsm610_reset;
@@ -253,7 +253,7 @@ static void *init_plugin (xine_t *xine, void *data) {
gsm610_class_t *this ;
- this = (gsm610_class_t *) xine_xmalloc (sizeof (gsm610_class_t));
+ this = (gsm610_class_t *) calloc(1, sizeof(gsm610_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "GSM 6.10";
diff --git a/src/audio_dec/xine_a52_decoder.c b/src/audio_dec/xine_a52_decoder.c
index 8d0c35f91..053980d17 100644
--- a/src/audio_dec/xine_a52_decoder.c
+++ b/src/audio_dec/xine_a52_decoder.c
@@ -652,7 +652,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
lprintf ("open_plugin called\n");
- this = (a52dec_decoder_t *) xine_xmalloc (sizeof (a52dec_decoder_t));
+ this = calloc(1, sizeof (a52dec_decoder_t));
this->audio_decoder.decode_data = a52dec_decode_data;
this->audio_decoder.reset = a52dec_reset;
@@ -789,7 +789,7 @@ static void *init_plugin (xine_t *xine, void *data) {
a52dec_class_t *this;
config_values_t *cfg;
- this = (a52dec_class_t *) xine_xmalloc (sizeof (a52dec_class_t));
+ this = calloc(1, sizeof (a52dec_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "a/52dec";
diff --git a/src/audio_dec/xine_dts_decoder.c b/src/audio_dec/xine_dts_decoder.c
index 4f9171d6e..9699b5d0d 100644
--- a/src/audio_dec/xine_dts_decoder.c
+++ b/src/audio_dec/xine_dts_decoder.c
@@ -466,7 +466,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
lprintf("open_plugin\n");
- this = (dts_decoder_t *) xine_xmalloc (sizeof (dts_decoder_t));
+ this = calloc(1, sizeof (dts_decoder_t));
this->audio_decoder.decode_data = dts_decode_data;
this->audio_decoder.reset = dts_reset;
@@ -560,7 +560,7 @@ static void *init_plugin (xine_t *xine, void *data) {
lprintf("init_plugin\n");
- this = (dts_class_t *) xine_xmalloc (sizeof (dts_class_t));
+ this = calloc(1, sizeof (dts_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "DTS";
diff --git a/src/audio_dec/xine_faad_decoder.c b/src/audio_dec/xine_faad_decoder.c
index 0c7c6dd01..30850c903 100644
--- a/src/audio_dec/xine_faad_decoder.c
+++ b/src/audio_dec/xine_faad_decoder.c
@@ -325,7 +325,7 @@ static void faad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if( !this->faac_dec && (buf->decoder_flags & BUF_FLAG_SPECIAL) &&
buf->decoder_info[1] == BUF_SPECIAL_DECODER_CONFIG ) {
- this->dec_config = xine_xmalloc(buf->decoder_info[2]);
+ this->dec_config = malloc(buf->decoder_info[2]);
this->dec_config_size = buf->decoder_info[2];
memcpy(this->dec_config, buf->decoder_info_ptr[2], buf->decoder_info[2]);
@@ -346,7 +346,7 @@ static void faad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
xine_waveformatex *wavex = (xine_waveformatex *) buf->content;
if( wavex->cbSize > 0 ) {
- this->dec_config = xine_xmalloc(wavex->cbSize);
+ this->dec_config = malloc(wavex->cbSize);
this->dec_config_size = wavex->cbSize;
memcpy(this->dec_config, buf->content + sizeof(xine_waveformatex),
wavex->cbSize);
@@ -422,7 +422,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
faad_decoder_t *this ;
- this = (faad_decoder_t *) xine_xmalloc (sizeof (faad_decoder_t));
+ this = calloc(1, sizeof (faad_decoder_t));
this->audio_decoder.decode_data = faad_decode_data;
this->audio_decoder.reset = faad_reset;
@@ -451,7 +451,7 @@ static void *init_plugin (xine_t *xine, void *data) {
faad_class_t *this ;
- this = (faad_class_t *) xine_xmalloc (sizeof (faad_class_t));
+ this = calloc(1, sizeof (faad_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "FAAD";
diff --git a/src/audio_dec/xine_lpcm_decoder.c b/src/audio_dec/xine_lpcm_decoder.c
index 83043cec9..b2761d35f 100644
--- a/src/audio_dec/xine_lpcm_decoder.c
+++ b/src/audio_dec/xine_lpcm_decoder.c
@@ -245,7 +245,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
lpcm_decoder_t *this ;
- this = (lpcm_decoder_t *) xine_xmalloc (sizeof (lpcm_decoder_t));
+ this = (lpcm_decoder_t *) calloc(1, sizeof(lpcm_decoder_t));
this->audio_decoder.decode_data = lpcm_decode_data;
this->audio_decoder.reset = lpcm_reset;
@@ -268,7 +268,7 @@ static void *init_plugin (xine_t *xine, void *data) {
lpcm_class_t *this ;
- this = (lpcm_class_t *) xine_xmalloc (sizeof (lpcm_class_t));
+ this = (lpcm_class_t *) calloc(1, sizeof(lpcm_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "Linear PCM";
diff --git a/src/audio_dec/xine_mad_decoder.c b/src/audio_dec/xine_mad_decoder.c
index abad70f4f..992c78fea 100644
--- a/src/audio_dec/xine_mad_decoder.c
+++ b/src/audio_dec/xine_mad_decoder.c
@@ -346,7 +346,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
mad_decoder_t *this ;
- this = (mad_decoder_t *) xine_xmalloc (sizeof (mad_decoder_t));
+ this = (mad_decoder_t *) calloc(1, sizeof(mad_decoder_t));
this->audio_decoder.decode_data = mad_decode_data;
this->audio_decoder.reset = mad_reset;
@@ -377,7 +377,7 @@ static void *init_plugin (xine_t *xine, void *data) {
mad_class_t *this;
- this = (mad_class_t *) xine_xmalloc (sizeof (mad_class_t));
+ this = (mad_class_t *) calloc(1, sizeof(mad_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "mad";
diff --git a/src/audio_dec/xine_musepack_decoder.c b/src/audio_dec/xine_musepack_decoder.c
index c556c5b9a..fcc16836d 100644
--- a/src/audio_dec/xine_musepack_decoder.c
+++ b/src/audio_dec/xine_musepack_decoder.c
@@ -224,7 +224,7 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
this->file_size = buf->decoder_info[0];
/* Initialise the data accumulation buffer */
- this->buf = xine_xmalloc(INIT_BUFSIZE);
+ this->buf = calloc(1, INIT_BUFSIZE);
this->buf_max = INIT_BUFSIZE;
this->read = 0;
this->size = 0;
@@ -404,7 +404,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
mpc_decoder_t *this ;
- this = (mpc_decoder_t *) xine_xmalloc (sizeof (mpc_decoder_t));
+ this = (mpc_decoder_t *) calloc(1, sizeof(mpc_decoder_t));
/* connect the member functions */
this->audio_decoder.decode_data = mpc_decode_data;
@@ -434,7 +434,7 @@ static void *init_plugin (xine_t *xine, void *data) {
mpc_class_t *this ;
- this = (mpc_class_t *) xine_xmalloc (sizeof (mpc_class_t));
+ this = (mpc_class_t *) calloc(1, sizeof(mpc_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "mpc";
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c
index a6f81cb35..cd6254281 100644
--- a/src/audio_out/audio_alsa_out.c
+++ b/src/audio_out/audio_alsa_out.c
@@ -1350,7 +1350,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
#define A52_PASSTHRU 12
int speakers;
- this = (alsa_driver_t *) xine_xmalloc (sizeof (alsa_driver_t));
+ this = calloc(1, sizeof (alsa_driver_t));
if (!this)
return NULL;
@@ -1497,70 +1497,73 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
"formats you want to play to your sound card's digital output."),
0, alsa_speaker_arrangement_cb, this);
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("audio_alsa_out : supported modes are "));
+ char *logmsg = strdup (_("audio_alsa_out : supported modes are"));
+
if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_U8))) {
this->capabilities |= AO_CAP_8BITS;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("8bit "));
+ xine_strcat_realloc (&logmsg, _(" 8bit"));
}
/* ALSA automatically appends _LE or _BE depending on the CPU */
if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_S16))) {
this->capabilities |= AO_CAP_16BITS;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("16bit "));
+ xine_strcat_realloc (&logmsg, _(" 16bit"));
}
if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_S24))) {
this->capabilities |= AO_CAP_24BITS;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("24bit "));
+ xine_strcat_realloc (&logmsg, _(" 24bit"));
}
if (!(snd_pcm_hw_params_test_format(this->audio_fd, params, SND_PCM_FORMAT_FLOAT))) {
this->capabilities |= AO_CAP_FLOAT32;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("32bit "));
+ xine_strcat_realloc (&logmsg, _(" 32bit"));
}
if (0 == (this->capabilities & (AO_CAP_FLOAT32 | AO_CAP_24BITS | AO_CAP_16BITS | AO_CAP_8BITS))) {
- xprintf (this->class->xine, XINE_VERBOSITY_DEBUG,
- "\naudio_alsa_out: no supported PCM format found\n");
+ xprintf(class->xine, XINE_VERBOSITY_LOG, "%s\n", logmsg);
+ free (logmsg);
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG,
+ "audio_alsa_out: no supported PCM format found\n");
snd_pcm_close(this->audio_fd);
free(this);
return NULL;
}
if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 1))) {
this->capabilities |= AO_CAP_MODE_MONO;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("mono "));
+ xine_strcat_realloc (&logmsg, _(" mono"));
}
if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 2))) {
this->capabilities |= AO_CAP_MODE_STEREO;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("stereo "));
+ xine_strcat_realloc (&logmsg, _(" stereo"));
}
if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 4)) &&
( speakers == SURROUND4 )) {
this->capabilities |= AO_CAP_MODE_4CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("4-channel "));
+ xine_strcat_realloc (&logmsg, _(" 4-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("(4-channel not enabled in xine config) "));
+ xine_strcat_realloc (&logmsg, _(" (4-channel not enabled in xine config)"));
if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 6)) &&
( speakers == SURROUND41 )) {
this->capabilities |= AO_CAP_MODE_4_1CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("4.1-channel "));
+ xine_strcat_realloc (&logmsg, _(" 4.1-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("(4.1-channel not enabled in xine config) "));
+ xine_strcat_realloc (&logmsg, _(" (4.1-channel not enabled in xine config)"));
if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 6)) &&
( speakers == SURROUND5 )) {
this->capabilities |= AO_CAP_MODE_5CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("5-channel "));
+ xine_strcat_realloc (&logmsg, _(" 5-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("(5-channel not enabled in xine config) "));
+ xine_strcat_realloc (&logmsg, _(" (5-channel not enabled in xine config)"));
if (!(snd_pcm_hw_params_test_channels(this->audio_fd, params, 6)) &&
( speakers >= SURROUND51 )) {
this->capabilities |= AO_CAP_MODE_5_1CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("5.1-channel "));
+ xine_strcat_realloc (&logmsg, _(" 5.1-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("(5.1-channel not enabled in xine config) "));
+ xine_strcat_realloc (&logmsg, _(" (5.1-channel not enabled in xine config)"));
this->has_pause_resume = 0; /* This is checked at open time instead */
this->is_paused = 0;
@@ -1583,10 +1586,13 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
if ( speakers == A52_PASSTHRU ) {
this->capabilities |= AO_CAP_MODE_A52;
this->capabilities |= AO_CAP_MODE_AC5;
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("a/52 and DTS pass-through\n"));
+ xine_strcat_realloc (&logmsg, _(" a/52 and DTS pass-through"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_LOG, _("(a/52 and DTS pass-through not enabled in xine config)\n"));
+ xine_strcat_realloc (&logmsg, _(" (a/52 and DTS pass-through not enabled in xine config)"));
+
+ xprintf(class->xine, XINE_VERBOSITY_LOG, "%s\n", logmsg);
+ free (logmsg);
/* printf("audio_alsa_out: capabilities 0x%X\n",this->capabilities); */
@@ -1666,7 +1672,7 @@ static void *init_class (xine_t *xine, void *data) {
alsa_class_t *this;
- this = (alsa_class_t *) xine_xmalloc (sizeof (alsa_class_t));
+ this = calloc(1, sizeof (alsa_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_coreaudio_out.c b/src/audio_out/audio_coreaudio_out.c
index 001d873fa..93275ac04 100644
--- a/src/audio_out/audio_coreaudio_out.c
+++ b/src/audio_out/audio_coreaudio_out.c
@@ -530,7 +530,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen,
lprintf ("open_plugin called\n");
- this = (coreaudio_driver_t *) xine_xmalloc (sizeof (coreaudio_driver_t));
+ this = calloc(1, sizeof (coreaudio_driver_t));
if (!this)
return NULL;
@@ -566,7 +566,7 @@ static void *init_class (xine_t *xine, void *data) {
lprintf ("init class\n");
- this = (coreaudio_class_t *) xine_xmalloc (sizeof (coreaudio_class_t));
+ this = calloc(1, sizeof (coreaudio_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_directx2_out.c b/src/audio_out/audio_directx2_out.c
index 309edf961..301a23226 100644
--- a/src/audio_out/audio_directx2_out.c
+++ b/src/audio_out/audio_directx2_out.c
@@ -955,7 +955,7 @@ static ao_driver_t *open_plugin(audio_driver_class_t *class_gen, const void *dat
lprintf("open plugin called\n");
- this = (dx2_driver_t *)xine_xmalloc(sizeof(dx2_driver_t));
+ this = calloc(1, sizeof(dx2_driver_t));
if (!this)
return NULL;
@@ -993,7 +993,7 @@ static void *init_class(xine_t *xine, void *data) {
lprintf("init class\n");
- this = (dx2_class_t *)xine_xmalloc(sizeof(dx2_class_t));
+ this = calloc(1, sizeof(dx2_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_directx_out.c b/src/audio_out/audio_directx_out.c
index 5d16698b2..60d61780b 100644
--- a/src/audio_out/audio_directx_out.c
+++ b/src/audio_out/audio_directx_out.c
@@ -790,7 +790,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
audiox_class_t *class = (audiox_class_t *) class_gen;
ao_directx_t *ao_directx;
- ao_directx = ( ao_directx_t * ) xine_xmalloc( sizeof( ao_directx_t ) );
+ ao_directx = calloc(1, sizeof(ao_directx_t));
if (!ao_directx)
return NULL;
@@ -827,7 +827,7 @@ static void *init_class (xine_t *xine, void *data) {
/*
* from this point on, nothing should go wrong anymore
*/
- audiox = (audiox_class_t *) xine_xmalloc (sizeof (audiox_class_t));
+ audiox = calloc(1, sizeof (audiox_class_t));
if (!audiox)
return NULL;
diff --git a/src/audio_out/audio_esd_out.c b/src/audio_out/audio_esd_out.c
index 81017f1ca..eab8dd0ff 100644
--- a/src/audio_out/audio_esd_out.c
+++ b/src/audio_out/audio_esd_out.c
@@ -521,7 +521,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen,
esd_close(audio_fd);
- this = (esd_driver_t *) xine_xmalloc (sizeof (esd_driver_t));
+ this = calloc(1, sizeof (esd_driver_t));
if (!this)
return NULL;
this->xine = class->xine;
@@ -567,7 +567,7 @@ static void *init_class (xine_t *xine, void *data) {
esd_class_t *this;
- this = (esd_class_t *) xine_xmalloc (sizeof (esd_class_t));
+ this = calloc(1, sizeof (esd_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_file_out.c b/src/audio_out/audio_file_out.c
index 666c9deeb..a3672092f 100644
--- a/src/audio_out/audio_file_out.c
+++ b/src/audio_out/audio_file_out.c
@@ -323,7 +323,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen,
lprintf ("open_plugin called\n");
- this = (file_driver_t *) xine_xmalloc (sizeof (file_driver_t));
+ this = calloc(1, sizeof (file_driver_t));
if (!this)
return NULL;
@@ -359,7 +359,7 @@ static void *init_class (xine_t *xine, void *data) {
lprintf ("init class\n");
- this = (file_class_t *) xine_xmalloc (sizeof (file_class_t));
+ this = calloc(1, sizeof (file_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_fusionsound_out.c b/src/audio_out/audio_fusionsound_out.c
index b33850c5e..7db9e1ad2 100644
--- a/src/audio_out/audio_fusionsound_out.c
+++ b/src/audio_out/audio_fusionsound_out.c
@@ -422,11 +422,11 @@ static ao_driver_t* open_plugin(audio_driver_class_t *ao_class,
fusionsound_class_t *class = (fusionsound_class_t *) ao_class;
fusionsound_driver_t *this;
const char *args[] = { "xine", "--dfb:no-sighandler", "--fs:no-banner" };
- int argn = sizeof(args) / sizeof(args[0]);
+ const size_t argn = sizeof(args) / sizeof(args[0]);
char **argp = (char **) args;
DFBResult ret;
- this = (fusionsound_driver_t *) xine_xmalloc (sizeof(fusionsound_driver_t));
+ this = calloc(1, sizeof(fusionsound_driver_t));
if (!this) {
xprintf (class->xine, XINE_VERBOSITY_LOG,
"audio_fusionsound_out: driver interface allocation failed!\n");
@@ -481,7 +481,7 @@ static void* init_class(xine_t *xine, void *data) {
return NULL;
}
- class = (fusionsound_class_t *) xine_xmalloc (sizeof( fusionsound_class_t));
+ class = calloc(1, sizeof( fusionsound_class_t));
if (!class) {
xprintf (xine, XINE_VERBOSITY_LOG,
"audio_fusionsound_out: class interface allocation failed!\n");
diff --git a/src/audio_out/audio_jack_out.c b/src/audio_out/audio_jack_out.c
index 7b8bb3eb3..f1a011a6c 100644
--- a/src/audio_out/audio_jack_out.c
+++ b/src/audio_out/audio_jack_out.c
@@ -17,381 +17,894 @@
#define AO_OUT_JACK_IFACE_VERSION 9
#define GAP_TOLERANCE AO_MAX_GAP
-#define BUFSIZE 81920
+/* maximum number of channels supported, avoids lots of mallocs */
+#define MAX_CHANS 6
-typedef struct jack_driver_s {
+typedef struct jack_driver_s
+{
+ ao_driver_t ao_driver;
+ xine_t *xine;
+
+ int capabilities;
+ int mode;
+ int paused;
+ int underrun;
+
+ int32_t output_sample_rate, input_sample_rate;
+ uint32_t num_channels;
+ uint32_t bits_per_sample;
+ uint32_t bytes_per_frame;
+ uint32_t bytes_in_buffer; /* number of bytes writen to audio hardware */
+ uint32_t fragment_size;
+
+ jack_client_t *client;
+ jack_port_t *ports[MAX_CHANS];
+
+ /*! buffer for audio data */
+ unsigned char *buffer;
+
+ /*! buffer read position, may only be modified by playback thread or while it is stopped */
+ uint32_t read_pos;
+ /*! buffer write position, may only be modified by MPlayer's thread */
+ uint32_t write_pos;
+
+ struct
+ {
+ int volume;
+ int mute;
+ } mixer;
- ao_driver_t ao_driver;
- xine_t *xine;
+} jack_driver_t;
- int capabilities;
+typedef struct
+{
+ audio_driver_class_t driver_class;
+ config_values_t *config;
+ xine_t *xine;
+} jack_class_t;
- int32_t sample_rate;
- uint32_t num_channels;
- uint32_t bits_per_sample;
- uint32_t bytes_per_frame;
- jack_client_t *client;
- jack_port_t *port_1;
- jack_port_t *port_2;
- float buf_1[BUFSIZE];
- float buf_2[BUFSIZE];
- uint32_t buf_read;
- uint32_t buf_write;
+/**************************************************************
+ *
+ * Simple ringbuffer implementation
+ * Lifted from mplayer ao_jack.c
+ *
+**************************************************************/
+
+
+/*! size of one chunk, if this is too small Xine will start to "stutter" */
+/*! after a short time of playback */
+#define CHUNK_SIZE (16 * 1024)
+/*! number of "virtual" chunks the buffer consists of */
+#define NUM_CHUNKS 8
+/* This type of ring buffer may never fill up completely, at least */
+/* one byte must always be unused. */
+/* For performance reasons (alignment etc.) one whole chunk always stays */
+/* empty, not only one byte. */
+#define BUFFSIZE ((NUM_CHUNKS + 1) * CHUNK_SIZE)
+
+/**
+ * \brief get the number of free bytes in the buffer
+ * \return number of free bytes in buffer
+ *
+ * may only be called by Xine's thread
+ * return value may change between immediately following two calls,
+ * and the real number of free bytes might be larger!
+ */
+static int buf_free (jack_driver_t *this)
+{
+ int free = this->read_pos - this->write_pos - CHUNK_SIZE;
+ if (free < 0)
+ free += BUFFSIZE;
+ return free;
+}
- uint32_t volume;
- uint32_t mute;
+/**
+ * \brief get amount of data available in the buffer
+ * \return number of bytes available in buffer
+ *
+ * may only be called by the playback thread
+ * return value may change between immediately following two calls,
+ * and the real number of buffered bytes might be larger!
+ */
+static int buf_used (jack_driver_t *this)
+{
+ int used = this->write_pos - this->read_pos;
+ if (used < 0)
+ used += BUFFSIZE;
+ return used;
+}
-} jack_driver_t;
+/**
+ * \brief insert len bytes into buffer
+ * \param data data to insert
+ * \param len length of data
+ * \return number of bytes inserted into buffer
+ *
+ * If there is not enough room, the buffer is filled up
+ *
+ * TODO: Xine should really pass data as float, perhaps in V1.2?
+ */
+static int write_buffer_32 (jack_driver_t *this, unsigned char *data, int len)
+{
+ int first_len = BUFFSIZE - this->write_pos;
+ int free = buf_free (this);
+ if (len > free)
+ len = free;
+ if (first_len > len)
+ first_len = len;
+
+ /* copy from current write_pos to end of buffer */
+ memcpy (&(this->buffer[this->write_pos]), data, first_len);
+ if (len > first_len) { /* we have to wrap around */
+ /* remaining part from beginning of buffer */
+ memcpy (this->buffer, &data[first_len], len - first_len);
+ }
+ this->write_pos = (this->write_pos + len) % BUFFSIZE;
+
+ return len;
+}
+
+static int write_buffer_16 (jack_driver_t *this, unsigned char *data, int len)
+{
+ int samples_free = buf_free (this) / (sizeof (float));
+ int samples = len / 2;
+ if (samples > samples_free)
+ samples = samples_free;
+
+ /* Rename some pointers so that the next bit of gymnastics is easier to read */
+ uint32_t write_pos = this->write_pos;
+ float *p_write;
+ int16_t *p_read = (int16_t *) data;
+ int i;
+ for (i = 0; i < samples; i++) {
+ /* Read in 16bits, write out floats */
+ p_write = (float *) (&(this->buffer[write_pos]));
+ *p_write = ((float) (p_read[i])) / 32767.0f;
+ write_pos = (write_pos + sizeof (float)) % BUFFSIZE;
+ }
+ this->write_pos = write_pos;
+
+ return samples * 2;
+}
-typedef struct {
- audio_driver_class_t driver_class;
- config_values_t *config;
- xine_t *xine;
-} jack_class_t;
-static int jack_process(jack_nframes_t nframes, void *arg)
+/**
+ * \brief read data from buffer and splitting it into channels
+ * \param bufs num_bufs float buffers, each will contain the data of one channel
+ * \param cnt number of samples to read per channel
+ * \param num_bufs number of channels to split the data into
+ * \return number of samples read per channel, equals cnt unless there was too
+ * little data in the buffer
+ *
+ * Assumes the data in the buffer is of type float, the number of bytes
+ * read is res * num_bufs * sizeof(float), where res is the return value.
+ * If there is not enough data in the buffer remaining parts will be filled
+ * with silence.
+ */
+static int read_buffer (jack_driver_t *this, float **bufs, int cnt,
+ int num_bufs, float gain)
{
- jack_driver_t *this = (jack_driver_t *)arg;
- uint32_t local_buf_read = this->buf_read;
- uint32_t local_buf_write = this->buf_write;
- uint32_t src_channel, target_channel;
- uint32_t frame;
- float *buf, *out;
- float gain = 0;
-
- if (!this->client) return 0;
-
- if (!this->mute) {
- gain = (float)this->volume / 100.0;
+ int buffered = buf_used (this);
+ int i, j;
+ int orig_cnt = cnt;
+ if (cnt * sizeof (float) * num_bufs > buffered)
+ cnt = buffered / (sizeof (float) * num_bufs);
+
+ uint32_t read_pos = this->read_pos;
+ unsigned char *buffer = this->buffer;
+ for (i = 0; i < cnt; i++) {
+ for (j = 0; j < num_bufs; j++) {
+ bufs[j][i] = *((float *) (&(buffer[read_pos]))) * gain;
+ read_pos = (read_pos + sizeof (float)) % BUFFSIZE;
}
+ }
+ this->read_pos = read_pos;
+ for (i = cnt; i < orig_cnt; i++)
+ for (j = 0; j < num_bufs; j++)
+ bufs[j][i] = 0;
- for (target_channel = 0; target_channel < 2; ++target_channel) {
-
- if (target_channel < this->num_channels) src_channel = target_channel;
- else src_channel = 0;
+ return cnt;
+}
- jack_port_t *port = (target_channel ? this->port_2 : this->port_1);
- if (!port) continue;
+/**
+ * \brief fill the buffers with silence
+ * \param bufs num_bufs float buffers, each will contain the data of one channel
+ * \param cnt number of samples in each buffer
+ * \param num_bufs number of buffers
+ */
+static void silence (float **bufs, int cnt, int num_bufs)
+{
+ int i, j;
+ for (i = 0; i < cnt; i++)
+ for (j = 0; j < num_bufs; j++)
+ bufs[j][i] = 0;
+}
- buf = (src_channel ? this->buf_2 : this->buf_1);
- out = (float *)jack_port_get_buffer(port, nframes);
- local_buf_read = this->buf_read;
- frame = 0;
+/**************************************************************
+ *
+ * Jack interface functions
+ *
+**************************************************************/
- while (frame < nframes && local_buf_read != local_buf_write) {
- // local_buf_write doesn't change during this process,
- // so we can safely defer updating buf_read until after
+/**
+ * \brief stop playing and empty buffers (for seeking/pause)
+ */
+static void jack_reset (jack_driver_t *this)
+{
+ this->paused = 1;
+ this->read_pos = this->write_pos = 0;
+ this->paused = 0;
+}
- out[frame++] = buf[local_buf_read] * gain;
- if (++local_buf_read == BUFSIZE) local_buf_read = 0;
- }
+static int jack_callback (jack_nframes_t nframes, void *arg)
+{
+ jack_driver_t *this = (jack_driver_t *) arg;
- if (frame < nframes) {
-// printf("jack_process: underrun: %u required, %u available\n",
-// nframes, frame);
- while (frame < nframes) {
- out[frame++] = 0.0f;
- }
- }
+ if (!this->client) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_callback: called without a client parameter? silently trying to continue...\n");
+ return 0;
+ }
+
+ float gain = 0;
+ if (!this->mixer.mute) {
+ gain = (float) this->mixer.volume / 100.0;
+ gain *= gain; /* experiment with increasing volume range */
+ }
+
+ float *bufs[MAX_CHANS];
+ int i;
+ for (i = 0; i < this->num_channels; i++)
+ bufs[i] = jack_port_get_buffer (this->ports[i], nframes);
+
+ if (this->paused || this->underrun) {
+ silence (bufs, nframes, this->num_channels);
+ } else {
+ int frames_read = read_buffer (this, bufs, nframes, this->num_channels, gain);
+ if (frames_read < nframes) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_callback: underrun - frames read: %d\n", frames_read);
+ this->underrun = 1;
}
+ }
- this->buf_read = local_buf_read;
+ return 0;
+}
-// printf("jack_process: buf_read %u, buf_write %u\n", this->buf_read, this->buf_write);
+static void jack_shutdown (void *arg)
+{
+ jack_driver_t *this = (jack_driver_t *) arg;
+ this->client = NULL;
+}
- return 0;
+/*
+ * Open the Jack audio device
+ * Return 1 on success, 0 on failure
+ * All error handling rests with the caller, we just try to open the device here
+ */
+static int jack_open_device (ao_driver_t *this_gen, char *jack_device,
+ int32_t *poutput_sample_rate, int num_channels)
+{
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ const char **matching_ports = NULL;
+ char *port_name = NULL;
+ jack_client_t *client = this->client;
+
+ int port_flags = JackPortIsInput;
+ int i;
+ int num_ports;
+
+ if (num_channels > MAX_CHANS) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: Invalid number of channels: %i\n",
+ num_channels);
+ goto err_out;
+ }
+ /* Try to create a client called "xine" */
+ if ((client = jack_client_new ("xine")) == 0) {
+ /* If that doesn't work it could be because running two copies of xine - try using a unique name */
+ char client_name[20];
+ sprintf (client_name, "xine (%d)", (int) getpid ());
+
+ if ((client = jack_client_new (client_name)) == 0) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "\njack_open_device: Error: Failed to connect to JACK server\n");
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: (did you start 'jackd' server?)\n");
+ goto err_out;
+ }
+ }
+
+ /* Save the new client */
+ this->client = client;
+
+ jack_reset (this);
+ jack_set_process_callback (client, jack_callback, this);
+
+ /* list matching ports */
+ if (!jack_device)
+ port_flags |= JackPortIsPhysical;
+ matching_ports = jack_get_ports (client, jack_device, NULL, port_flags);
+ for (num_ports = 0; matching_ports && matching_ports[num_ports];
+ num_ports++);
+ if (!num_ports) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: no physical ports available\n");
+ goto err_out;
+ }
+ if (num_ports < num_channels) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: not enough physical ports available\n");
+ goto err_out;
+ }
+
+ /* create output ports */
+ for (i = 0; i < num_channels; i++) {
+ char pname[50];
+ snprintf (pname, 50, "out_%d", i);
+ this->ports[i] =
+ jack_port_register (client, pname, JACK_DEFAULT_AUDIO_TYPE,
+ JackPortIsOutput, 0);
+ if (!this->ports[i]) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: could not create output ports? Why not?\n");
+ goto err_out;
+ }
+ }
+ if (jack_activate (client)) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: jack_activate() failed\n");
+ goto err_out;
+ }
+ for (i = 0; i < num_channels; i++) {
+ if (jack_connect
+ (client, jack_port_name (this->ports[i]), matching_ports[i])) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "jack_open_device: jack_connect() failed\n");
+ goto err_out;
+ }
+ }
+ *poutput_sample_rate = jack_get_sample_rate (client);
+
+ free (matching_ports);
+ return 1;
+
+err_out:
+ free (matching_ports);
+ if (client) {
+ jack_client_close (client);
+ this->client = NULL;
+ }
+ return 0;
}
-
-static void jack_shutdown(void *arg)
+
+/**************************************************************
+ *
+ * Xine interface functions
+ *
+**************************************************************/
+
+
+/**
+ * close the device and reset the play position
+ */
+static void ao_jack_close (ao_driver_t *this_gen)
{
- jack_driver_t *this = (jack_driver_t *)arg;
- this->client = 0;
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG, "ao_jack_close: closing\n");
+
+ jack_reset (this);
+ if (this->client) {
+ jack_client_close (this->client);
+ this->client = NULL;
+ }
}
/*
* open the audio device for writing to
*/
-static int ao_jack_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int mode)
+static int ao_jack_open (ao_driver_t *this_gen, uint32_t bits, uint32_t rate,
+ int mode)
{
- jack_driver_t *this = (jack_driver_t *) this_gen;
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ config_values_t *config = this->xine->config;
+ char *jack_device;
- if (bits != 16) {
- fprintf(stderr, "ao_jack_open: bits=%u expected %u\n", bits, 16);
- return 0;
- }
+ jack_device =
+ config->lookup_entry (config, "audio.device.jack_device_name")->str_value;
- rate = jack_get_sample_rate(this->client);
- fprintf(stderr, "ao_jack_open: JACK sample rate is %u\n", rate);
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "ao_jack_open: ao_open rate=%d, mode=%d, bits=%d dev=%s\n", rate,
+ mode, bits, jack_device);
+
+ if ((bits != 16) && (bits != 32)) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "ao_jack_open: bits=%u expected 16 or 32bit only\n", bits);
+ return 0;
+ }
- switch (mode) {
- case AO_CAP_MODE_MONO:
- this->num_channels = 1;
- break;
- case AO_CAP_MODE_STEREO:
- this->num_channels = 2;
- break;
+ if ((mode & this->capabilities) == 0) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "ao_jack_open: unsupported mode %08x\n", mode);
+ return 0;
+ }
+
+ /* If device open already then either re-use it or close it */
+ if (this->client) {
+ if ((mode == this->mode) && (rate == this->input_sample_rate)) {
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "ao_jack_open: device already open, reusing it\n");
+ return this->output_sample_rate;
}
- this->buf_read = this->buf_write = 0;
- this->sample_rate = rate;
- this->bits_per_sample = bits;
- this->capabilities = AO_CAP_16BITS | AO_CAP_MODE_MONO | \
- AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | AO_CAP_MUTE_VOL;
- this->bytes_per_frame = this->num_channels * (bits / 8);
+ ao_jack_close (this_gen);
+ }
+
+
+ this->mode = mode;
+ this->input_sample_rate = rate;
+ this->bits_per_sample = bits;
+ this->bytes_in_buffer = 0;
+ this->read_pos = this->write_pos = 0;
+ this->paused = 0;
+ this->underrun = 0;
+
+ /*
+ * set number of channels / a52 passthrough
+ */
+ switch (mode) {
+ case AO_CAP_MODE_MONO:
+ this->num_channels = 1;
+ break;
+ case AO_CAP_MODE_STEREO:
+ this->num_channels = 2;
+ break;
+ case AO_CAP_MODE_4CHANNEL:
+ this->num_channels = 4;
+ break;
+ case AO_CAP_MODE_4_1CHANNEL:
+ case AO_CAP_MODE_5CHANNEL:
+ case AO_CAP_MODE_5_1CHANNEL:
+ this->num_channels = 6;
+ break;
+ case AO_CAP_MODE_A52:
+ case AO_CAP_MODE_AC5:
+ /* FIXME: Is this correct...? */
+ this->num_channels = 2;
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "ao_jack_open: AO_CAP_MODE_A52\n");
+ break;
+ default:
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "ao_jack_open: JACK Driver does not support the requested mode: 0x%X\n",
+ mode);
+ return 0;
+ }
+
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "ao_jack_open: %d channels output\n", this->num_channels);
+ this->bytes_per_frame = (this->bits_per_sample * this->num_channels) / 8;
- fprintf(stderr, "ao_jack_open: bits=%d rate=%d, mode=%d OK\n", bits, rate, mode);
+ /*
+ * open audio device
+ */
+ if (!jack_open_device (this_gen, jack_device, &(this->output_sample_rate),
+ this->num_channels))
+ return 0;
+
+ if (this->input_sample_rate != this->output_sample_rate) {
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "ao_jack_open: audio rate : %d requested, %d provided by device\n",
+ this->input_sample_rate, this->output_sample_rate);
+ }
- return rate;
+ return this->output_sample_rate;
}
-static int ao_jack_num_channels(ao_driver_t *this_gen)
+static int ao_jack_num_channels (ao_driver_t *this_gen)
{
- jack_driver_t *this = (jack_driver_t *) this_gen;
- return this->num_channels;
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ return this->num_channels;
}
-static int ao_jack_bytes_per_frame(ao_driver_t *this_gen)
+static int ao_jack_bytes_per_frame (ao_driver_t *this_gen)
{
- jack_driver_t *this = (jack_driver_t *) this_gen;
- return this->bytes_per_frame;
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ return this->bytes_per_frame;
}
static int ao_jack_get_gap_tolerance (ao_driver_t *this_gen)
{
- return GAP_TOLERANCE;
+ return GAP_TOLERANCE;
}
-static int last_write_space = 0;
-
-static int ao_jack_write(ao_driver_t *this_gen, int16_t *data,
- uint32_t num_frames)
+/*
+ * Return the number of outstanding frames in all output buffers
+ * need to account for ring buffer plus Jack, plus soundcard
+ */
+static int ao_jack_delay (ao_driver_t *this_gen)
{
- jack_driver_t *this = (jack_driver_t *) this_gen;
- uint32_t frame, channel;
-
- uint32_t local_buf_read = this->buf_read;
- uint32_t local_buf_write = this->buf_write;
- uint32_t space = (local_buf_read + BUFSIZE - local_buf_write - 1) % BUFSIZE;
- uint32_t first_frame = 0;
-
- int c = 0;
- while (space < num_frames) {
- if (++c == 10) return 0;
- usleep(10000);
- local_buf_read = this->buf_read;
- space = (local_buf_read + BUFSIZE - local_buf_write - 1) % BUFSIZE;
- }
-
-// if (space < num_frames) return 0;
-
-// printf("ao_jack_write: %u frames on %u channels, space is %u\n", num_frames, this->num_channels, space);
- last_write_space = space;
-
- for (frame = first_frame; frame < num_frames; ++frame) {
- for (channel = 0; channel < this->num_channels; ++channel) {
- float *buf = (channel ? this->buf_2 : this->buf_1);
- int16_t sample = data[frame * this->num_channels + channel];
- buf[local_buf_write] = ((float)sample) / 32767.0f;
-// printf("%6f ", buf[local_buf_write]);
-// if (++c == 8) { printf("\n"); c = 0; }
- }
- if (++local_buf_write == BUFSIZE) local_buf_write = 0;
- }
-
- this->buf_write = local_buf_write;
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ int frames_played = jack_frames_since_cycle_start (this->client);
-// printf("ao_jack_write: buf_read %u, buf_write %u\n", this->buf_read, this->buf_write);
+ int delay = 0;
+ /* Ring Buffer always stores floats */
+ /* TODO: Unsure if the delay should be fragment_size*2 or *3? */
+ delay = buf_used (this) / (sizeof (float) * this->num_channels) +
+ this->fragment_size * 3 - frames_played;
- return 1;
+ return delay;
}
-static int ao_jack_delay (ao_driver_t *this_gen)
+ /* Write audio samples
+ * num_frames is the number of audio frames present
+ * audio frames are equivalent one sample on each channel.
+ * I.E. Stereo 16 bits audio frames are 4 bytes.
+ * MUST SIMULATE BLOCKING WRITES
+ */
+static int ao_jack_write (ao_driver_t *this_gen, int16_t *frame_buffer,
+ uint32_t num_frames)
{
- jack_driver_t *this = (jack_driver_t *) this_gen;
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ int written = 0;
+ int num_bytes = num_frames * this->bytes_per_frame;
+
+ /* First try and write all the bytes in one go */
+ this->underrun = 0;
+ /* TODO: In the future Xine should pass only floats to us, so no conversion needed */
+ if (this->bits_per_sample == 16)
+ written = write_buffer_16 (this, (char *) frame_buffer, num_bytes);
+ else if (this->bits_per_sample == 32)
+ written = write_buffer_32 (this, (char *) frame_buffer, num_bytes);
+
+ /* If this fails then need to spin and keep trying until everything written */
+ int spin_count = 0;
+ while ((written < num_bytes) && (spin_count < 40)) {
+ num_bytes -= written;
+ frame_buffer += written / 2;
+
+ /* Sleep to save CPU */
+ int until_callback =
+ this->fragment_size - jack_frames_since_cycle_start (this->client);
+ if ((until_callback < 0) || (until_callback > this->fragment_size)) {
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "ao_jack_write: Invalid until_callback %d\n", until_callback);
+ until_callback = this->fragment_size;
+ }
+ xine_usec_sleep (((until_callback +
+ 100) * 1000.0 * 1000.0) / this->output_sample_rate);
- uint32_t local_buf_read = this->buf_read;
- uint32_t local_buf_write = this->buf_write;
+ if (this->bits_per_sample == 16)
+ written = write_buffer_16 (this, (char *) frame_buffer, num_bytes);
+ else if (this->bits_per_sample == 32)
+ written = write_buffer_32 (this, (char *) frame_buffer, num_bytes);
- int delay = 0;
+ if (written == 0)
+ spin_count++;
+ else
+ spin_count = 0;
- if (local_buf_write > local_buf_read) {
- delay = local_buf_write - local_buf_read;
- } else {
- delay = ((local_buf_write + BUFSIZE - local_buf_read) % BUFSIZE);
- }
+ if (written == 0)
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "ao_jack_write: unusual, couldn't write anything\n");
+ };
- return delay;// - jack_get_buffer_size(this->client);
-}
+ if (spin_count)
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "Nonzero spin_count...%d\n", spin_count);
-static void ao_jack_close(ao_driver_t *this_gen)
-{
- // nothing
+ return spin_count ? 0 : 1; /* return 1 on success, 0 if we got stuck for some reason */
}
-static uint32_t ao_jack_get_capabilities (ao_driver_t *this_gen) {
- jack_driver_t *this = (jack_driver_t *) this_gen;
- return this->capabilities;
-}
-
-static void ao_jack_exit(ao_driver_t *this_gen)
+static uint32_t ao_jack_get_capabilities (ao_driver_t *this_gen)
{
- jack_driver_t *this = (jack_driver_t *) this_gen;
- jack_client_t *client = this->client;
- ao_jack_close(this_gen);
- this->client = 0;
- if (client) jack_client_close(client);
- free (this);
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+ return this->capabilities;
}
-static int ao_jack_get_property (ao_driver_t *this_gen, int property) {
- jack_driver_t *this = (jack_driver_t *) this_gen;
-
- switch(property) {
- case AO_PROP_PCM_VOL:
- case AO_PROP_MIXER_VOL:
-// printf("ao_jack_get_property(AO_PROP_MIXER_VOL): %u\n", this->volume);
- return this->volume;
- break;
- case AO_PROP_MUTE_VOL:
-// printf("ao_jack_get_property(AO_PROP_MUTE_VOL): %u\n", this->mute);
- return this->mute;
- break;
- }
+static void ao_jack_exit (ao_driver_t *this_gen)
+{
+ jack_driver_t *this = (jack_driver_t *) this_gen;
- return 0;
+ ao_jack_close (this_gen);
+ if (this->buffer)
+ free (this->buffer);
+ free (this);
}
-static int ao_jack_set_property (ao_driver_t *this_gen, int property, int value) {
- jack_driver_t *this = (jack_driver_t *) this_gen;
-
- switch(property) {
- case AO_PROP_PCM_VOL:
- case AO_PROP_MIXER_VOL:
-// printf("ao_jack_set_property(AO_PROP_MIXER_VOL): %u\n", value);
- this->volume = value;
- break;
- case AO_PROP_MUTE_VOL:
-// printf("ao_jack_get_property(AO_PROP_MUTE_VOL): %u\n", value);
- this->mute = value;
- break;
- }
+static int ao_jack_get_property (ao_driver_t *this_gen, int property)
+{
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+
+ switch (property) {
+ case AO_PROP_PCM_VOL:
+ case AO_PROP_MIXER_VOL:
+ return this->mixer.volume;
+ break;
+ case AO_PROP_MUTE_VOL:
+ return this->mixer.mute;
+ break;
+ }
+
+ return 0;
+}
- return ~value;
+static int ao_jack_set_property (ao_driver_t *this_gen, int property, int value)
+{
+ jack_driver_t *this = (jack_driver_t *) this_gen;
+
+ switch (property) {
+ case AO_PROP_PCM_VOL:
+ case AO_PROP_MIXER_VOL:
+ this->mixer.volume = value;
+ return value;
+ break;
+ case AO_PROP_MUTE_VOL:
+ this->mixer.mute = value;
+ return value;
+ break;
+ }
+
+ return -1;
}
-static int ao_jack_ctrl(ao_driver_t *this_gen, int cmd, ...) {
- jack_driver_t *this = (jack_driver_t *) this_gen;
+static int ao_jack_ctrl (ao_driver_t *this_gen, int cmd, ...)
+{
+ jack_driver_t *this = (jack_driver_t *) this_gen;
- switch (cmd) {
+ switch (cmd) {
- case AO_CTRL_PLAY_PAUSE:
- break;
+ case AO_CTRL_PLAY_PAUSE:
+ this->paused = 1;
+ break;
- case AO_CTRL_PLAY_RESUME:
- break;
+ case AO_CTRL_PLAY_RESUME:
+ this->paused = 0;
+ break;
- case AO_CTRL_FLUSH_BUFFERS:
-// fprintf(stderr, "ao_jack_ctrl(AO_CTRL_FLUSH_BUFFERS)\n");
- this->buf_write = this->buf_read = 0;
- break;
- }
+ case AO_CTRL_FLUSH_BUFFERS:
+ jack_reset (this);
+ break;
+ }
- return 0;
+ return 0;
}
+static void jack_speaker_arrangement_cb (void *user_data,
+ xine_cfg_entry_t *entry);
+
static ao_driver_t *open_jack_plugin (audio_driver_class_t *class_gen,
const void *data)
{
- jack_class_t *class = (jack_class_t *) class_gen;
- jack_driver_t *this;
- jack_client_t *client;
- uint32_t rate;
- const char **port_names;
- int i;
-
- if ((client = jack_client_new("xine")) == 0) {
-
- char name[20];
- sprintf(name, "xine (%d)", (int)getpid());
-
- if ((client = jack_client_new(name)) == 0) {
- fprintf(stderr, "\nopen_jack_plugin: Error: Failed to connect to JACK server\n");
- fprintf(stderr, "open_jack_plugin: (did you start 'jackd' server?)\n");
- return 0;
- }
- }
-
- this = (jack_driver_t *) xine_xmalloc (sizeof (jack_driver_t));
-
- this->client = client;
-
- jack_set_process_callback(client, jack_process, this);
- jack_on_shutdown(client, jack_shutdown, this);
-
- rate = jack_get_sample_rate(client);
- fprintf(stderr, "open_jack_plugin: JACK sample rate is %u\n", rate);
-
- // We support up to 2-channel output
-
- for (i = 0; i < 2; ++i) {
- jack_port_t *port = jack_port_register
- (client, (i ? "out_r" : "out_l"),
- JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
- if (!port) {
- fprintf(stderr, "ao_jack_open: failed to register port %u\n", i);
- }
- if (i) this->port_2 = port;
- else this->port_1 = port;
- }
-
- this->buf_read = this->buf_write = 0;
- this->volume = 100;
- this->mute = 0;
-
- if (jack_activate(client)) {
- fprintf(stderr, "ao_jack_open: failed to activate JACK client\n");
- return 0;
- }
-
- if ((port_names = jack_get_ports(client, NULL, NULL,
- JackPortIsPhysical | JackPortIsInput)) != NULL) {
- if (port_names[0]) {
- jack_connect(client, jack_port_name(this->port_1), port_names[0]);
- }
- if (port_names[1] && this->port_2) {
- jack_connect(client, jack_port_name(this->port_2), port_names[1]);
- }
- free(port_names);
+ jack_class_t *class = (jack_class_t *) class_gen;
+ config_values_t *config = class->config;
+ jack_driver_t *this;
+
+ jack_client_t *client;
+ uint32_t rate;
+ char *jack_device;
+ const char **matching_ports = NULL;
+ const char **port_names;
+
+ /* for usability reasons, keep this in sync with audio_oss_out.c */
+ static char *speaker_arrangement[] = {
+ "Mono 1.0", "Stereo 2.0", "Headphones 2.0", "Stereo 2.1",
+ "Surround 3.0", "Surround 4.0", "Surround 4.1", "Surround 5.0",
+ "Surround 5.1", "Surround 6.0",
+ "Surround 6.1", "Surround 7.1", "Pass Through", NULL
+ };
+#define MONO 0
+#define STEREO 1
+#define HEADPHONES 2
+#define SURROUND21 3
+#define SURROUND3 4
+#define SURROUND4 5
+#define SURROUND41 6
+#define SURROUND5 7
+#define SURROUND51 8
+#define SURROUND6 9
+#define SURROUND61 10
+#define SURROUND71 11
+#define A52_PASSTHRU 12
+ int speakers;
+
+ /* Try to create a client called "xine" */
+ if ((client = jack_client_new ("xine")) == 0) {
+ /* If that doesn't work it could be because running two copies of xine - try using a unique name */
+ char name[20];
+ sprintf (name, "xine (%d)", (int) getpid ());
+
+ if ((client = jack_client_new (name)) == 0) {
+ xprintf (class->xine, XINE_VERBOSITY_LOG,
+ "\nopen_jack_plugin: Error: Failed to connect to JACK server\n");
+ xprintf (class->xine, XINE_VERBOSITY_LOG,
+ "open_jack_plugin: (did you start 'jackd' server?)\n");
+ return 0;
}
+ }
+
+ this = calloc(1, sizeof (jack_driver_t));
+
+ rate = jack_get_sample_rate (client);
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG,
+ "open_jack_plugin: JACK sample rate is %u\n", rate);
+
+ /* devname_val is offset used to select auto, /dev/dsp, or /dev/sound/dsp */
+ jack_device = config->register_string (config,
+ "audio.device.jack_device_name",
+ "",
+ _("JACK audio device name"),
+ _("Specifies the jack audio device name, "
+ "leave blank for the default physical output port."),
+ 10, NULL, NULL);
+
+ this->capabilities = 0;
+
+
+ /* for usability reasons, keep this in sync with audio_alsa_out.c */
+ speakers =
+ config->register_enum (config, "audio.output.speaker_arrangement",
+ STEREO, speaker_arrangement,
+ _("speaker arrangement"),
+ _("Select how your speakers are arranged, "
+ "this determines which speakers xine uses for sound output. "
+ "The individual values are:\n\n"
+ "Mono 1.0: You have only one speaker.\n"
+ "Stereo 2.0: You have two speakers for left and right channel.\n"
+ "Headphones 2.0: You use headphones.\n"
+ "Stereo 2.1: You have two speakers for left and right channel, and one "
+ "subwoofer for the low frequencies.\n"
+ "Surround 3.0: You have three speakers for left, right and rear channel.\n"
+ "Surround 4.0: You have four speakers for front left and right and rear "
+ "left and right channels.\n"
+ "Surround 4.1: You have four speakers for front left and right and rear "
+ "left and right channels, and one subwoofer for the low frequencies.\n"
+ "Surround 5.0: You have five speakers for front left, center and right and "
+ "rear left and right channels.\n"
+ "Surround 5.1: You have five speakers for front left, center and right and "
+ "rear left and right channels, and one subwoofer for the low frequencies.\n"
+ "Surround 6.0: You have six speakers for front left, center and right and "
+ "rear left, center and right channels.\n"
+ "Surround 6.1: You have six speakers for front left, center and right and "
+ "rear left, center and right channels, and one subwoofer for the low frequencies.\n"
+ "Surround 7.1: You have seven speakers for front left, center and right, "
+ "left and right and rear left and right channels, and one subwoofer for the "
+ "low frequencies.\n"
+ "Pass Through: Your sound system will receive undecoded digital sound from xine. "
+ "You need to connect a digital surround decoder capable of decoding the "
+ "formats you want to play to your sound card's digital output."),
+ 0, jack_speaker_arrangement_cb, this);
+
+ int port_flags = JackPortIsInput;
+ int num_ports;
+ /* list matching ports */
+ if (!jack_device)
+ port_flags |= JackPortIsPhysical;
+ /* Find all the ports matching either the desired device regexp or physical output ports */
+ matching_ports = jack_get_ports (client, jack_device, NULL, port_flags);
+ /* Count 'em */
+ for (num_ports = 0; matching_ports && matching_ports[num_ports];
+ num_ports++)
+ /**/;
+ if (!num_ports) {
+ xprintf (this->xine, XINE_VERBOSITY_LOG,
+ "open_jack_plugin: no physical ports available\n");
+ goto err_out;
+ }
+
+
+/* TODO: We deliberately don't offer mono, let Xine upsample instead? */
+/* if (num_ports >= 1) { */
+/* this->capabilities |= AO_CAP_MODE_MONO; */
+/* xprintf(class->xine, XINE_VERBOSITY_DEBUG, "mono "); */
+/* } */
+
+ if (num_ports >= 2) {
+ this->capabilities |= AO_CAP_MODE_STEREO;
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG, "stereo ");
+ }
+
+ if (num_ports >= 4) {
+ if (speakers == SURROUND4) {
+ this->capabilities |= AO_CAP_MODE_4CHANNEL;
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG, "4-channel ");
+ } else
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG,
+ "(4-channel not enabled in xine config) ");
+ }
+
+ if (num_ports >= 5) {
+ if (speakers == SURROUND5) {
+ this->capabilities |= AO_CAP_MODE_5CHANNEL;
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG, "5-channel ");
+ } else
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG,
+ "(5-channel not enabled in xine config) ");
+ }
+
+ if (num_ports >= 6) {
+ if (speakers == SURROUND51) {
+ this->capabilities |= AO_CAP_MODE_5_1CHANNEL;
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG, "5.1-channel ");
+ } else
+ xprintf (class->xine, XINE_VERBOSITY_DEBUG,
+ "(5.1-channel not enabled in xine config) ");
+ }
+
+ this->buffer = (unsigned char *) malloc (BUFFSIZE);
+ jack_reset (this);
+
+ this->capabilities |= AO_CAP_MIXER_VOL;
+ this->capabilities |= AO_CAP_MUTE_VOL;
+ /* TODO: Currently not respected by Xine, perhaps v1.2? */
+ this->capabilities |= AO_CAP_FLOAT32;
+
+
+ this->mixer.mute = 0;
+ this->mixer.volume = 100;
+
+ this->output_sample_rate = jack_get_sample_rate (client);
+ this->fragment_size = jack_get_buffer_size (client);
+
+ /* Close our JACK client */
+ jack_client_close (client);
+
+ this->xine = class->xine;
+
+ this->ao_driver.get_capabilities = ao_jack_get_capabilities;
+ this->ao_driver.get_property = ao_jack_get_property;
+ this->ao_driver.set_property = ao_jack_set_property;
+ this->ao_driver.open = ao_jack_open;
+ this->ao_driver.num_channels = ao_jack_num_channels;
+ this->ao_driver.bytes_per_frame = ao_jack_bytes_per_frame;
+ this->ao_driver.delay = ao_jack_delay;
+ this->ao_driver.write = ao_jack_write;
+ this->ao_driver.close = ao_jack_close;
+ this->ao_driver.exit = ao_jack_exit;
+ this->ao_driver.get_gap_tolerance = ao_jack_get_gap_tolerance;
+ this->ao_driver.control = ao_jack_ctrl;
+
+ return &this->ao_driver;
+
+err_out:
+ free (matching_ports);
+ if (client)
+ jack_client_close (client);
+ return 0;
+}
- this->sample_rate = rate;
-
- this->xine = class->xine;
- this->capabilities = AO_CAP_FLOAT32 | AO_CAP_MODE_MONO |
- AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | AO_CAP_MUTE_VOL;
-
- this->ao_driver.get_capabilities = ao_jack_get_capabilities;
- this->ao_driver.get_property = ao_jack_get_property;
- this->ao_driver.set_property = ao_jack_set_property;
- this->ao_driver.open = ao_jack_open;
- this->ao_driver.num_channels = ao_jack_num_channels;
- this->ao_driver.bytes_per_frame = ao_jack_bytes_per_frame;
- this->ao_driver.delay = ao_jack_delay;
- this->ao_driver.write = ao_jack_write;
- this->ao_driver.close = ao_jack_close;
- this->ao_driver.exit = ao_jack_exit;
- this->ao_driver.get_gap_tolerance = ao_jack_get_gap_tolerance;
- this->ao_driver.control = ao_jack_ctrl;
-
- fprintf(stderr, "jack open_jack_plugin returning %p\n", (void *)(&this->ao_driver));
- return &this->ao_driver;
+static void jack_speaker_arrangement_cb (void *user_data,
+ xine_cfg_entry_t *entry)
+{
+ jack_driver_t *this = (jack_driver_t *) user_data;
+ int32_t value = entry->num_value;
+ if (value == SURROUND4) {
+ this->capabilities |= AO_CAP_MODE_4CHANNEL;
+ } else {
+ this->capabilities &= ~AO_CAP_MODE_4CHANNEL;
+ }
+ if (value == SURROUND41) {
+ this->capabilities |= AO_CAP_MODE_4_1CHANNEL;
+ } else {
+ this->capabilities &= ~AO_CAP_MODE_4_1CHANNEL;
+ }
+ if (value == SURROUND5) {
+ this->capabilities |= AO_CAP_MODE_5CHANNEL;
+ } else {
+ this->capabilities &= ~AO_CAP_MODE_5CHANNEL;
+ }
+ if (value >= SURROUND51) {
+ this->capabilities |= AO_CAP_MODE_5_1CHANNEL;
+ } else {
+ this->capabilities &= ~AO_CAP_MODE_5_1CHANNEL;
+ }
}
/*
@@ -401,7 +914,7 @@ static void *init_class (xine_t *xine, void *data) {
jack_class_t *this;
- this = (jack_class_t *) xine_xmalloc (sizeof (jack_class_t));
+ this = calloc(1, sizeof (jack_class_t));
this->driver_class.open_plugin = open_jack_plugin;
this->driver_class.identifier = "jack";
@@ -416,9 +929,7 @@ static void *init_class (xine_t *xine, void *data) {
return this;
}
-static ao_info_t ao_info_jack = {
- 6
-};
+static ao_info_t ao_info_jack = { 6 };
/*
* exported plugin catalog entry
@@ -429,4 +940,3 @@ const plugin_info_t xine_plugin_info[] EXPORTED = {
{ PLUGIN_AUDIO_OUT, AO_OUT_JACK_IFACE_VERSION, "jack", XINE_VERSION_CODE /* XINE_VERSION_CODE */, &ao_info_jack, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
-
diff --git a/src/audio_out/audio_none_out.c b/src/audio_out/audio_none_out.c
index fa6547880..8be61d16d 100644
--- a/src/audio_out/audio_none_out.c
+++ b/src/audio_out/audio_none_out.c
@@ -186,7 +186,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen,
lprintf ("open_plugin called\n");
- this = (none_driver_t *) xine_xmalloc (sizeof (none_driver_t));
+ this = calloc(1, sizeof (none_driver_t));
if (!this)
return NULL;
@@ -220,7 +220,7 @@ static void *init_class (xine_t *xine, void *data) {
lprintf ("init class\n");
- this = (none_class_t *) xine_xmalloc (sizeof (none_class_t));
+ this = calloc(1, sizeof (none_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_oss_out.c b/src/audio_out/audio_oss_out.c
index 89d79fae9..4ec7544a5 100644
--- a/src/audio_out/audio_oss_out.c
+++ b/src/audio_out/audio_oss_out.c
@@ -666,7 +666,7 @@ static int probe_audio_devices(oss_driver_t *this) {
int base_num, i;
int audio_fd, rate;
int best_rate;
- char devname[30];
+ char *devname[30];
strcpy(this->audio_dev, "auto");
@@ -729,7 +729,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
int speakers;
- this = (oss_driver_t *) xine_xmalloc (sizeof (oss_driver_t));
+ this = calloc(1, sizeof (oss_driver_t));
if (!this)
return NULL;
@@ -877,15 +877,10 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
if (this->sync_method == OSS_SYNC_PROBEBUFFER) {
char *buf;
int c;
-
- xprintf(class->xine, XINE_VERBOSITY_LOG,
- _("audio_oss_out: Audio driver realtime sync disabled...\n"
- "audio_oss_out: ...probing output buffer size: "));
+
this->buffer_size = 0;
- if( (buf=malloc(1024)) != NULL ) {
- memset(buf,0,1024);
-
+ if( (buf=calloc(1, 1024)) != NULL ) {
do {
c = write(audio_fd,buf,1024);
if( c != -1 )
@@ -896,7 +891,8 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
}
close(audio_fd);
xprintf(class->xine, XINE_VERBOSITY_LOG,
- _("%d bytes\naudio_oss_out: ...there may be audio/video synchronization issues\n"), this->buffer_size);
+ _("audio_oss_out: Audio driver realtime sync disabled...\n"
+ "audio_oss_out: ...probing output buffer size: %d bytes\naudio_oss_out: ...there may be audio/video synchronization issues\n"), this->buffer_size);
audio_fd=open(this->audio_dev, O_WRONLY|O_NONBLOCK);
@@ -959,48 +955,48 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
0, oss_speaker_arrangement_cb, this);
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "audio_oss_out: supported modes are ");
+ char *logmsg = strdup (_("audio_oss_out: supported modes are"));
num_channels = 1;
status = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &num_channels);
if ( (status != -1) && (num_channels==1) ) {
this->capabilities |= AO_CAP_MODE_MONO;
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "mono ");
+ xine_strcat_realloc (&logmsg, _(" mono"));
}
num_channels = 2;
status = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &num_channels);
if ( (status != -1) && (num_channels==2) ) {
this->capabilities |= AO_CAP_MODE_STEREO;
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "stereo ");
+ xine_strcat_realloc (&logmsg, _(" stereo"));
}
num_channels = 4;
status = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &num_channels);
if ( (status != -1) && (num_channels==4) ) {
if ( speakers == SURROUND4 ) {
this->capabilities |= AO_CAP_MODE_4CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "4-channel ");
+ xine_strcat_realloc (&logmsg, _(" 4-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "(4-channel not enabled in xine config) " );
+ xine_strcat_realloc (&logmsg, _(" (4-channel not enabled in xine config)"));
}
num_channels = 5;
status = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &num_channels);
if ( (status != -1) && (num_channels==5) ) {
if ( speakers == SURROUND5 ) {
this->capabilities |= AO_CAP_MODE_5CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "5-channel ");
+ xine_strcat_realloc (&logmsg, _(" 5-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "(5-channel not enabled in xine config) " );
+ xine_strcat_realloc (&logmsg, _(" (5-channel not enabled in xine config)"));
}
num_channels = 6;
status = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &num_channels);
if ( (status != -1) && (num_channels==6) ) {
if ( speakers == SURROUND51 ) {
this->capabilities |= AO_CAP_MODE_5_1CHANNEL;
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "5.1-channel ");
+ xine_strcat_realloc (&logmsg, _(" 5.1-channel"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "(5.1-channel not enabled in xine config) " );
+ xine_strcat_realloc (&logmsg, _(" (5.1-channel not enabled in xine config)"));
}
ioctl(audio_fd,SNDCTL_DSP_GETFMTS,&caps);
@@ -1010,10 +1006,13 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
if ( speakers == A52_PASSTHRU ) {
this->capabilities |= AO_CAP_MODE_A52;
this->capabilities |= AO_CAP_MODE_AC5;
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "a/52-pass-through ");
+ xine_strcat_realloc (&logmsg, _(" a/52 pass-through"));
}
else
- xprintf(class->xine, XINE_VERBOSITY_DEBUG, "(a/52-pass-through not enabled in xine config)");
+ xine_strcat_realloc (&logmsg, _(" (a/52 pass-through not enabled in xine config)"));
+
+ xprintf(class->xine, XINE_VERBOSITY_DEBUG, "%s\n", logmsg);
+ free (logmsg);
/*
* mixer initialisation.
@@ -1148,7 +1147,7 @@ static void *init_class (xine_t *xine, void *data) {
oss_class_t *this;
- this = (oss_class_t *) xine_xmalloc (sizeof (oss_class_t));
+ this = calloc(1, sizeof (oss_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_pulse_out.c b/src/audio_out/audio_pulse_out.c
index 9b811aaaf..a7a7437e4 100644
--- a/src/audio_out/audio_pulse_out.c
+++ b/src/audio_out/audio_pulse_out.c
@@ -217,8 +217,12 @@ static void __xine_pa_sink_info_callback(pa_context *c, const pa_sink_input_info
return;
this->cvolume = info->volume;
- this->swvolume = pa_sw_volume_to_linear(pa_cvolume_avg(&info->volume));
+ this->swvolume = pa_cvolume_avg(&info->volume);
+#ifdef HAVE_PULSEAUDIO_0_9_7
this->muted = info->mute;
+#else
+ this->muted = pa_cvolume_is_muted (&this->cvolume);
+#endif
}
static int connect_context(pulse_driver_t *this) {
@@ -661,9 +665,27 @@ static int ao_pulse_set_property (ao_driver_t *this_gen, int property, int value
this->muted = value;
+#ifdef HAVE_PULSEAUDIO_0_9_7
o = pa_context_set_sink_input_mute(this->context, pa_stream_get_index(this->stream),
value, __xine_pa_context_success_callback, this);
+#else
+ /* Get the current volume, so we can restore it properly. */
+ o = pa_context_get_sink_input_info(this->context, pa_stream_get_index(this->stream),
+ __xine_pa_sink_info_callback, this);
+
+ if (o) {
+ wait_for_operation(this, o);
+ pa_operation_unref(o);
+ }
+ if ( value )
+ pa_cvolume_mute(&this->cvolume, pa_stream_get_sample_spec(this->stream)->channels);
+ else
+ pa_cvolume_set(&this->cvolume, pa_stream_get_sample_spec(this->stream)->channels, this->swvolume);
+
+ o = pa_context_set_sink_input_volume(this->context, pa_stream_get_index(this->stream),
+ &this->cvolume, __xine_pa_context_success_callback, this);
+#endif
result = value;
}
@@ -723,7 +745,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
lprintf ("audio_pulse_out: open_plugin called\n");
- this = (pulse_driver_t *) xine_xmalloc (sizeof (pulse_driver_t));
+ this = calloc(1, sizeof (pulse_driver_t));
if (!this)
return NULL;
@@ -826,7 +848,7 @@ static void *init_class (xine_t *xine, void *data) {
lprintf ("audio_pulse_out: init class\n");
- this = (pulse_class_t *) xine_xmalloc (sizeof (pulse_class_t));
+ this = calloc(1, sizeof (pulse_class_t));
if (!this)
return NULL;
diff --git a/src/audio_out/audio_sun_out.c b/src/audio_out/audio_sun_out.c
index 921e5fd15..57448b963 100644
--- a/src/audio_out/audio_sun_out.c
+++ b/src/audio_out/audio_sun_out.c
@@ -907,7 +907,7 @@ static ao_driver_t *ao_sun_open_plugin (audio_driver_class_t *class_gen, const v
int status;
audio_info_t info;
- this = (sun_driver_t *) xine_xmalloc (sizeof (sun_driver_t));
+ this = calloc(1, sizeof (sun_driver_t));
if (!this)
return NULL;
@@ -1014,7 +1014,7 @@ static ao_driver_t *ao_sun_open_plugin (audio_driver_class_t *class_gen, const v
static void *ao_sun_init_class (xine_t *xine, void *data) {
sun_class_t *this;
- this = (sun_class_t *) xine_xmalloc (sizeof (sun_class_t));
+ this = calloc(1, sizeof (sun_class_t));
if (!this)
return NULL;
diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c
index 27fe18d9c..4074ff776 100644
--- a/src/combined/ffmpeg/ff_audio_decoder.c
+++ b/src/combined/ffmpeg/ff_audio_decoder.c
@@ -177,7 +177,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->context->bit_rate = audio_header->nAvgBytesPerSec * 8;
if(audio_header->cbSize > 0) {
- this->context->extradata = xine_xmalloc(audio_header->cbSize);
+ this->context->extradata = malloc(audio_header->cbSize);
this->context->extradata_size = audio_header->cbSize;
memcpy( this->context->extradata,
(uint8_t *)audio_header + sizeof(xine_waveformatex),
@@ -202,7 +202,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->context->block_align = _X_BE_32(&this->buf[0x18]);
this->context->extradata_size = 5*sizeof(short);
- this->context->extradata = xine_xmalloc(this->context->extradata_size);
+ this->context->extradata = malloc(this->context->extradata_size);
ptr = (short *) this->context->extradata;
@@ -248,8 +248,8 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
break; /* abort early - extradata length is bad */
this->context->extradata_size = data_len;
- this->context->extradata = xine_xmalloc(this->context->extradata_size +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ this->context->extradata = malloc(this->context->extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
xine_fast_memcpy (this->context->extradata, this->buf + extradata,
this->context->extradata_size);
break;
@@ -275,7 +275,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
this->size = 0;
- this->decode_buffer = xine_xmalloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ this->decode_buffer = calloc(1, AVCODEC_MAX_AUDIO_FRAME_SIZE);
return;
}
@@ -283,8 +283,8 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
(buf->decoder_info[1] == BUF_SPECIAL_STSD_ATOM)) {
this->context->extradata_size = buf->decoder_info[2];
- this->context->extradata = xine_xmalloc(buf->decoder_info[2] +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ this->context->extradata = malloc(buf->decoder_info[2] +
+ FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(this->context->extradata, buf->decoder_info_ptr[2],
buf->decoder_info[2]);
@@ -449,7 +449,7 @@ static audio_decoder_t *ff_audio_open_plugin (audio_decoder_class_t *class_gen,
ff_audio_decoder_t *this ;
- this = (ff_audio_decoder_t *) xine_xmalloc (sizeof (ff_audio_decoder_t));
+ this = calloc(1, sizeof (ff_audio_decoder_t));
this->audio_decoder.decode_data = ff_audio_decode_data;
this->audio_decoder.reset = ff_audio_reset;
@@ -473,7 +473,7 @@ void *init_audio_plugin (xine_t *xine, void *data) {
ff_audio_class_t *this ;
- this = (ff_audio_class_t *) xine_xmalloc (sizeof (ff_audio_class_t));
+ this = calloc(1, sizeof (ff_audio_class_t));
this->decoder_class.open_plugin = ff_audio_open_plugin;
this->decoder_class.identifier = "ffmpeg audio";
diff --git a/src/combined/ffmpeg/ff_mpeg_parser.c b/src/combined/ffmpeg/ff_mpeg_parser.c
index 70901d93b..3c2c2cf48 100644
--- a/src/combined/ffmpeg/ff_mpeg_parser.c
+++ b/src/combined/ffmpeg/ff_mpeg_parser.c
@@ -50,7 +50,7 @@ static const int frame_rate_tab[][2] = {
void mpeg_parser_init (mpeg_parser_t *parser)
{
- parser->chunk_buffer = xine_xmalloc(BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
+ parser->chunk_buffer = malloc(BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
mpeg_parser_reset(parser);
}
diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c
index 951e12deb..c80ee5928 100644
--- a/src/combined/ffmpeg/ff_video_decoder.c
+++ b/src/combined/ffmpeg/ff_video_decoder.c
@@ -116,6 +116,10 @@ struct ff_video_decoder_s {
yuv_planes_t yuv;
AVPaletteControl palette_control;
+
+#ifdef LOG
+ enum PixelFormat debug_fmt;
+#endif
};
@@ -147,7 +151,7 @@ static int get_buffer(AVCodecContext *context, AVFrame *av_frame){
avcodec_align_dimensions(context, &width, &height);
- if( this->context->pix_fmt != PIX_FMT_YUV420P ) {
+ if( this->context->pix_fmt != PIX_FMT_YUV420P && this->context->pix_fmt != PIX_FMT_YUVJ420P ) {
if (!this->is_direct_rendering_disabled) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
_("ffmpeg_video_dec: unsupported frame format, DR1 disabled.\n"));
@@ -372,7 +376,7 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type)
/* Some codecs (eg rv10) copy flags in init so it's necessary to set
* this flag here in case we are going to use direct rendering */
- if(this->codec->capabilities & CODEC_CAP_DR1) {
+ if(this->codec->capabilities & CODEC_CAP_DR1 && this->codec->id != CODEC_ID_H264) {
this->context->flags |= CODEC_FLAG_EMU_EDGE;
}
@@ -584,6 +588,11 @@ static void ff_convert_frame(ff_video_decoder_t *this, vo_frame_t *img) {
int y;
uint8_t *dy, *du, *dv, *sy, *su, *sv;
+#ifdef LOG
+ if (this->debug_fmt != this->context->pix_fmt)
+ printf ("frame format == %08x\n", this->debug_fmt = this->context->pix_fmt);
+#endif
+
dy = img->base[0];
du = img->base[1];
dv = img->base[2];
@@ -881,7 +890,7 @@ static void ff_handle_preview_buffer (ff_video_decoder_t *this, buf_element_t *b
if (codec_type == BUF_VIDEO_MPEG) {
this->is_mpeg12 = 1;
if ( this->mpeg_parser == NULL ) {
- this->mpeg_parser = xine_xmalloc(sizeof(mpeg_parser_t));
+ this->mpeg_parser = calloc(1, sizeof(mpeg_parser_t));
mpeg_parser_init(this->mpeg_parser);
this->decoder_init_mode = 0;
}
@@ -936,7 +945,7 @@ static void ff_handle_header_buffer (ff_video_decoder_t *this, buf_element_t *bu
this->context->sub_id = _X_BE_32(&this->buf[30]);
- this->context->slice_offset = xine_xmalloc(sizeof(int)*SLICE_OFFSET_SIZE);
+ this->context->slice_offset = calloc(SLICE_OFFSET_SIZE, sizeof(int));
this->slice_offset_size = SLICE_OFFSET_SIZE;
this->context->extradata_size = this->size - 26;
@@ -984,8 +993,8 @@ static void ff_handle_special_buffer (ff_video_decoder_t *this, buf_element_t *b
lprintf("BUF_SPECIAL_STSD_ATOM\n");
this->context->extradata_size = buf->decoder_info[2];
- this->context->extradata = xine_xmalloc(buf->decoder_info[2] +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ this->context->extradata = malloc(buf->decoder_info[2] +
+ FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(this->context->extradata, buf->decoder_info_ptr[2],
buf->decoder_info[2]);
@@ -994,8 +1003,8 @@ static void ff_handle_special_buffer (ff_video_decoder_t *this, buf_element_t *b
lprintf("BUF_SPECIAL_DECODER_CONFIG\n");
this->context->extradata_size = buf->decoder_info[2];
- this->context->extradata = xine_xmalloc(buf->decoder_info[2] +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ this->context->extradata = malloc(buf->decoder_info[2] +
+ FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(this->context->extradata, buf->decoder_info_ptr[2],
buf->decoder_info[2]);
@@ -1543,7 +1552,7 @@ static video_decoder_t *ff_video_open_plugin (video_decoder_class_t *class_gen,
lprintf ("open_plugin\n");
- this = (ff_video_decoder_t *) xine_xmalloc (sizeof (ff_video_decoder_t));
+ this = calloc(1, sizeof (ff_video_decoder_t));
this->video_decoder.decode_data = ff_decode_data;
this->video_decoder.flush = ff_flush;
@@ -1562,7 +1571,7 @@ static video_decoder_t *ff_video_open_plugin (video_decoder_class_t *class_gen,
this->decoder_ok = 0;
this->decoder_init_mode = 1;
- this->buf = xine_xmalloc(VIDEOBUFSIZE + FF_INPUT_BUFFER_PADDING_SIZE);
+ this->buf = calloc(1, VIDEOBUFSIZE + FF_INPUT_BUFFER_PADDING_SIZE);
this->bufsize = VIDEOBUFSIZE;
this->is_mpeg12 = 0;
@@ -1576,6 +1585,10 @@ static video_decoder_t *ff_video_open_plugin (video_decoder_class_t *class_gen,
this->dr1_frames = xine_list_new();
+#ifdef LOG
+ this->debug_fmt = -1;
+#endif
+
return &this->video_decoder;
}
@@ -1584,7 +1597,7 @@ void *init_video_plugin (xine_t *xine, void *data) {
ff_video_class_t *this;
config_values_t *config;
- this = (ff_video_class_t *) xine_xmalloc (sizeof (ff_video_class_t));
+ this = calloc(1, sizeof (ff_video_class_t));
this->decoder_class.open_plugin = ff_video_open_plugin;
this->decoder_class.identifier = "ffmpeg video";
diff --git a/src/combined/flac_decoder.c b/src/combined/flac_decoder.c
index 43bad327e..4982a6a6c 100644
--- a/src/combined/flac_decoder.c
+++ b/src/combined/flac_decoder.c
@@ -158,6 +158,7 @@ flac_write_callback (const FLAC__StreamDecoder *decoder,
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
+#ifdef LEGACY_FLAC
static void
flac_metadata_callback (const FLAC__StreamDecoder *decoder,
const FLAC__StreamMetadata *metadata,
@@ -180,6 +181,7 @@ flac_metadata_callback (const FLAC__StreamDecoder *decoder,
return;
}
+#endif
static void
flac_error_callback (const FLAC__StreamDecoder *decoder,
@@ -324,7 +326,7 @@ static audio_decoder_t *
open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
flac_decoder_t *this ;
- this = (flac_decoder_t *) xine_xmalloc (sizeof (flac_decoder_t));
+ this = calloc(1, sizeof (flac_decoder_t));
this->audio_decoder.decode_data = flac_decode_data;
this->audio_decoder.reset = flac_reset;
@@ -383,7 +385,7 @@ static void *
init_plugin (xine_t *xine, void *data) {
flac_class_t *this;
- this = (flac_class_t *) xine_xmalloc (sizeof (flac_class_t));
+ this = calloc(1, sizeof (flac_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "flacdec";
diff --git a/src/combined/flac_demuxer.c b/src/combined/flac_demuxer.c
index 22ee2319b..1105e353a 100644
--- a/src/combined/flac_demuxer.c
+++ b/src/combined/flac_demuxer.c
@@ -592,7 +592,7 @@ open_plugin (demux_class_t *class_gen,
* if we reach this point, the input has been accepted.
*/
- this = xine_xmalloc (sizeof (demux_flac_t));
+ this = calloc(1, sizeof (demux_flac_t));
this->stream = stream;
this->input = input;
@@ -706,7 +706,7 @@ demux_flac_init_class (xine_t *xine, void *data) {
lprintf("demux_flac_init_class\n");
- this = xine_xmalloc (sizeof (demux_flac_class_t));
+ this = calloc(1, sizeof (demux_flac_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/combined/nsf_decoder.c b/src/combined/nsf_decoder.c
index cb3b6e7b0..4ae920dfd 100644
--- a/src/combined/nsf_decoder.c
+++ b/src/combined/nsf_decoder.c
@@ -92,7 +92,7 @@ static void nsf_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
this->song_number = buf->content[4];
/* allocate a buffer for the file */
this->nsf_size = _X_BE_32(&buf->content[0]);
- this->nsf_file = xine_xmalloc(this->nsf_size);
+ this->nsf_file = calloc(1, this->nsf_size);
this->nsf_index = 0;
/* peform any other required initialization */
@@ -207,7 +207,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
nsf_decoder_t *this ;
- this = (nsf_decoder_t *) xine_xmalloc (sizeof (nsf_decoder_t));
+ this = (nsf_decoder_t *) calloc(1, sizeof(nsf_decoder_t));
/* connect the member functions */
this->audio_decoder.decode_data = nsf_decode_data;
@@ -236,7 +236,7 @@ void *decoder_nsf_init_plugin (xine_t *xine, void *data) {
nsf_class_t *this ;
- this = (nsf_class_t *) xine_xmalloc (sizeof (nsf_class_t));
+ this = (nsf_class_t *) calloc(1, sizeof(nsf_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "NSF";
diff --git a/src/combined/nsf_demuxer.c b/src/combined/nsf_demuxer.c
index 451e6e938..ee05f0f90 100644
--- a/src/combined/nsf_demuxer.c
+++ b/src/combined/nsf_demuxer.c
@@ -300,7 +300,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_nsf_t));
+ this = calloc(1, sizeof(demux_nsf_t));
this->stream = stream;
this->input = input;
@@ -340,7 +340,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_nsf_init_plugin (xine_t *xine, void *data) {
demux_nsf_class_t *this;
- this = xine_xmalloc (sizeof (demux_nsf_class_t));
+ this = calloc(1, sizeof(demux_nsf_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("NES Music file demux plugin");
diff --git a/src/combined/wavpack_combined.h b/src/combined/wavpack_combined.h
index 42b0bfd51..87358169b 100644
--- a/src/combined/wavpack_combined.h
+++ b/src/combined/wavpack_combined.h
@@ -21,6 +21,7 @@
*/
#include <xine/os_types.h>
+#include <xine/attributes.h>
#include "bswap.h"
typedef struct {
diff --git a/src/combined/wavpack_decoder.c b/src/combined/wavpack_decoder.c
index 80a14e678..fdf6a5514 100644
--- a/src/combined/wavpack_decoder.c
+++ b/src/combined/wavpack_decoder.c
@@ -293,7 +293,7 @@ static void wavpack_dispose (audio_decoder_t *this_gen) {
}
static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
- wavpack_decoder_t * const this = (wavpack_decoder_t *) xine_xmalloc (sizeof (wavpack_decoder_t));
+ wavpack_decoder_t * const this = calloc(1, sizeof (wavpack_decoder_t));
this->audio_decoder.decode_data = wavpack_decode_data;
this->audio_decoder.reset = wavpack_reset;
@@ -314,7 +314,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre
void *decoder_wavpack_init_plugin (xine_t *xine, void *data) {
wavpack_class_t *this;
- this = (wavpack_class_t *) xine_xmalloc (sizeof (wavpack_class_t));
+ this = calloc(1, sizeof (wavpack_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "wavpackdec";
diff --git a/src/combined/wavpack_demuxer.c b/src/combined/wavpack_demuxer.c
index e32c17e4e..51b2c7af9 100644
--- a/src/combined/wavpack_demuxer.c
+++ b/src/combined/wavpack_demuxer.c
@@ -326,7 +326,7 @@ static int demux_wv_get_optional_data(demux_plugin_t *const this_gen,
static demux_plugin_t *open_plugin (demux_class_t *const class_gen,
xine_stream_t *const stream,
input_plugin_t *const input) {
- demux_wv_t *const this = xine_xmalloc (sizeof (demux_wv_t));
+ demux_wv_t *const this = calloc(1, sizeof (demux_wv_t));
this->stream = stream;
this->input = input;
@@ -363,7 +363,7 @@ static demux_plugin_t *open_plugin (demux_class_t *const class_gen,
}
void *demux_wv_init_plugin (xine_t *const xine, void *const data) {
- demux_wv_class_t *const this = xine_xmalloc (sizeof (demux_wv_class_t));
+ demux_wv_class_t *const this = calloc(1, sizeof (demux_wv_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Wavpack demux plugin");
diff --git a/src/combined/xine_ogg_demuxer.c b/src/combined/xine_ogg_demuxer.c
index 52788612f..670c19781 100644
--- a/src/combined/xine_ogg_demuxer.c
+++ b/src/combined/xine_ogg_demuxer.c
@@ -197,7 +197,7 @@ static int get_stream (demux_ogg_t *this, int serno) {
static int new_stream_info (demux_ogg_t *this, const int cur_serno) {
int stream_num;
- this->si[this->num_streams] = (stream_info_t *)xine_xmalloc(sizeof(stream_info_t));
+ this->si[this->num_streams] = (stream_info_t *)calloc(1, sizeof(stream_info_t));
ogg_stream_init(&this->si[this->num_streams]->oss, cur_serno);
stream_num = this->num_streams;
this->si[stream_num]->buf_types = 0;
@@ -307,10 +307,10 @@ static void send_ogg_packet (demux_ogg_t *this,
buf_element_t *buf;
int done=0,todo=op->bytes;
- int op_size = sizeof(ogg_packet);
+ const size_t op_size = sizeof(ogg_packet);
while (done<todo) {
- int offset=0;
+ size_t offset=0;
buf = fifo->buffer_pool_alloc (fifo);
buf->decoder_flags = decoder_flags;
if (done==0) {
@@ -504,7 +504,7 @@ static void read_chapter_comment (demux_ogg_t *this, ogg_packet *op) {
lprintf("time: %d %d %d %d\n", hour, min,sec,msec);
if (!this->chapter_info) {
- this->chapter_info = (chapter_info_t *)xine_xmalloc(sizeof(chapter_info_t));
+ this->chapter_info = (chapter_info_t *)calloc(1, sizeof(chapter_info_t));
this->chapter_info->current_chapter = -1;
}
this->chapter_info->max_chapter = chapter_no;
@@ -538,34 +538,34 @@ static void update_chapter_display (demux_ogg_t *this, int stream_num, ogg_packe
chapter--;
if (chapter != this->chapter_info->current_chapter){
- xine_event_t uevent;
- xine_ui_data_t data;
- int title_len;
- char *title;
+ xine_ui_data_t data = {
+ .str = { 0, },
+ .str_len = 0
+ };
+ xine_event_t uevent = {
+ .type = XINE_EVENT_UI_SET_TITLE,
+ .stream = this->stream,
+ .data = &data,
+ .data_length = sizeof(data)
+ };
this->chapter_info->current_chapter = chapter;
- if (chapter >= 0) {
- char t_title[256];
+ if (chapter >= 0) {
if (this->title) {
- snprintf(t_title, sizeof (t_title), "%s / %s", this->title, this->chapter_info->entries[chapter].name);
+ data.str_len = snprintf(data.str, sizeof(data.str), "%s / %s", this->title, this->chapter_info->entries[chapter].name);
} else {
- snprintf(t_title, sizeof (t_title), "%s", this->chapter_info->entries[chapter].name);
+ strncpy(data.str, this->chapter_info->entries[chapter].name, sizeof(data.str)-1);
}
- title = t_title;
} else {
- title = this->title;
+ strncpy(data.str, this->title, sizeof(data.str));
}
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, title);
- lprintf("new TITLE: %s\n", title);
-
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);
- title_len = strlen(title) + 1;
- memcpy(data.str, title, title_len);
- data.str_len = title_len;
+ if ( data.str_len == 0 )
+ data.str_len = strlen(data.str);
+
+ _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, data.str);
+ lprintf("new TITLE: %s\n", data.str);
+
xine_event_send(this->stream, &uevent);
}
}
@@ -1279,8 +1279,8 @@ static void decode_annodex_header (demux_ogg_t *this, const int stream_num, ogg_
static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
int64_t granule_rate_n, granule_rate_d;
uint32_t secondary_headers;
- char content_type[1024];
- int content_type_length;
+ const char *content_type = "";
+ size_t content_type_length = 0;
lprintf("AnxData stream detected\n");
@@ -1292,11 +1292,16 @@ static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_
lprintf("granule_rate %" PRId64 "/%" PRId64 ", %d secondary headers\n",
granule_rate_n, granule_rate_d, secondary_headers);
- /* read "Content-Tyoe" MIME header */
- sscanf(&op->packet[28], "Content-Type: %1023s\r\n", content_type);
- content_type_length = strlen(content_type);
+ /* read "Content-Type" MIME header */
+ const char *startline = &op->packet[28];
+ const char *endline;
+ if ( strcmp(&op->packet[28], "Content-Type: ") == 0 &&
+ (endline = strstr(startline, "\r\n")) ) {
+ content_type = startline + sizeof("Content-Type: ");
+ content_type_length = startline - endline;
+ }
- lprintf("Content-Type: %s (length:%d)\n", content_type, content_type_length);
+ lprintf("Content-Type: %s (length:%td)\n", content_type, content_type_length);
/* how many header packets in the AnxData stream? */
this->si[stream_num]->headers = secondary_headers + 1;
@@ -1998,8 +2003,7 @@ static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen,
* if we reach this point, the input has been accepted.
*/
- this = xine_xmalloc (sizeof (demux_ogg_t));
- memset (this, 0, sizeof(demux_ogg_t));
+ this = calloc(1, sizeof(demux_ogg_t));
this->stream = stream;
this->input = input;
@@ -2044,8 +2048,7 @@ static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen,
* if we reach this point, the input has been accepted.
*/
- this = xine_xmalloc (sizeof (demux_ogg_t));
- memset (this, 0, sizeof(demux_ogg_t));
+ this = calloc(1, sizeof(demux_ogg_t));
this->stream = stream;
this->input = input;
@@ -2079,7 +2082,7 @@ static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen,
static void *anx_init_class (xine_t *xine, void *data) {
demux_anx_class_t *this;
- this = xine_xmalloc (sizeof (demux_anx_class_t));
+ this = calloc(1, sizeof(demux_anx_class_t));
this->demux_class.open_plugin = anx_open_plugin;
this->demux_class.description = N_("Annodex demux plugin");
@@ -2103,7 +2106,7 @@ static void *anx_init_class (xine_t *xine, void *data) {
static void *ogg_init_class (xine_t *xine, void *data) {
demux_ogg_class_t *this;
- this = xine_xmalloc (sizeof (demux_ogg_class_t));
+ this = calloc(1, sizeof(demux_ogg_class_t));
this->demux_class.open_plugin = ogg_open_plugin;
this->demux_class.description = N_("OGG demux plugin");
diff --git a/src/combined/xine_speex_decoder.c b/src/combined/xine_speex_decoder.c
index 865232e30..386010929 100644
--- a/src/combined/xine_speex_decoder.c
+++ b/src/combined/xine_speex_decoder.c
@@ -169,15 +169,16 @@ void read_metadata (speex_decoder_t *this, char * comments, int length)
#endif
for (i = 0; i < (sizeof(speex_comment_keys)/sizeof(speex_comment_keys[0])); i++) {
+ size_t keylen = strlen(speex_comment_keys[i].key);
+
if ( !strncasecmp (speex_comment_keys[i].key, c,
- strlen(speex_comment_keys[i].key)) ) {
- int keylen = strlen(speex_comment_keys[i].key);
+ keylen) ) {
char meta_info[(len - keylen) + 1];
lprintf ("known metadata %d %d\n",
i, speex_comment_keys[i].xine_metainfo_index);
- snprintf(meta_info, (len - keylen), "%s", c + keylen);
+ strncpy(meta_info, &c[keylen], len-keylen);
_x_meta_info_set_utf8(this->stream, speex_comment_keys[i].xine_metainfo_index, meta_info);
}
}
@@ -203,7 +204,7 @@ static void speex_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
if (!this->st) {
SpeexMode * spx_mode;
SpeexHeader * spx_header;
- int modeID;
+ unsigned int modeID;
int bitrate;
speex_bits_init (&this->bits);
@@ -215,7 +216,12 @@ static void speex_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
return;
}
- modeID = spx_header->mode;
+ modeID = (unsigned int)spx_header->mode;
+ if (modeID >= SPEEX_NB_MODES) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": invalid mode ID %u\n", modeID);
+ return;
+ }
+
spx_mode = (SpeexMode *) speex_mode_list[modeID];
if (spx_mode->bitstream_version != spx_header->mode_bitstream_version) {
@@ -349,7 +355,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen,
speex_decoder_t *this ;
static SpeexStereoState init_stereo = SPEEX_STEREO_STATE_INIT;
- this = (speex_decoder_t *) xine_xmalloc (sizeof (speex_decoder_t));
+ this = (speex_decoder_t *) calloc(1, sizeof(speex_decoder_t));
this->audio_decoder.decode_data = speex_decode_data;
this->audio_decoder.reset = speex_reset;
@@ -378,7 +384,7 @@ void *speex_init_plugin (xine_t *xine, void *data) {
speex_class_t *this;
- this = (speex_class_t *) xine_xmalloc (sizeof (speex_class_t));
+ this = (speex_class_t *) calloc(1, sizeof(speex_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "speex";
diff --git a/src/combined/xine_theora_decoder.c b/src/combined/xine_theora_decoder.c
index 96d4ca8f0..84cf8fb58 100644
--- a/src/combined/xine_theora_decoder.c
+++ b/src/combined/xine_theora_decoder.c
@@ -312,7 +312,7 @@ static video_decoder_t *theora_open_plugin (video_decoder_class_t *class_gen, xi
theora_decoder_t *this ;
- this = (theora_decoder_t *) xine_xmalloc (sizeof (theora_decoder_t));
+ this = (theora_decoder_t *) calloc(1, sizeof(theora_decoder_t));
this->theora_decoder.decode_data = theora_decode_data;
this->theora_decoder.flush = theora_flush;
@@ -347,7 +347,7 @@ void *theora_init_plugin (xine_t *xine, void *data) {
/*initialize our plugin*/
theora_class_t *this;
- this = (theora_class_t *) xine_xmalloc (sizeof (theora_class_t));
+ this = (theora_class_t *) calloc(1, sizeof(theora_class_t));
this->decoder_class.open_plugin = theora_open_plugin;
this->decoder_class.identifier = "theora video";
diff --git a/src/combined/xine_vorbis_decoder.c b/src/combined/xine_vorbis_decoder.c
index ad3a07188..cc157eb3f 100644
--- a/src/combined/xine_vorbis_decoder.c
+++ b/src/combined/xine_vorbis_decoder.c
@@ -315,7 +315,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen,
vorbis_decoder_t *this ;
- this = (vorbis_decoder_t *) xine_xmalloc (sizeof (vorbis_decoder_t));
+ this = (vorbis_decoder_t *) calloc(1, sizeof(vorbis_decoder_t));
this->audio_decoder.decode_data = vorbis_decode_data;
this->audio_decoder.reset = vorbis_reset;
@@ -328,7 +328,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen,
this->convsize = 0;
this->bufsize = INIT_BUFSIZE;
- this->buf = xine_xmalloc(INIT_BUFSIZE);
+ this->buf = calloc(1, INIT_BUFSIZE);
this->size = 0;
vorbis_info_init(&this->vi);
@@ -346,7 +346,7 @@ void *vorbis_init_plugin (xine_t *xine, void *data) {
vorbis_class_t *this;
- this = (vorbis_class_t *) xine_xmalloc (sizeof (vorbis_class_t));
+ this = (vorbis_class_t *) calloc(1, sizeof(vorbis_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "vorbis";
diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c
index d602445a0..776d6cc03 100644
--- a/src/demuxers/asfheader.c
+++ b/src/demuxers/asfheader.c
@@ -577,10 +577,8 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_
if (buffer_len < 10)
return 0;
- if (! (content = calloc(1, sizeof(asf_content_t))) )
- return 0;
-
- if ( (iconv_cd = iconv_open("UTF-8", "UCS-2LE")) == (iconv_t)-1 )
+ content = calloc(1, sizeof(asf_content_t));
+ if (!content)
return 0;
asf_reader_init(&reader, buffer, buffer_len);
@@ -616,6 +614,10 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
uint32_t object_count;
uint16_t junk;
+ asf_header = calloc(1, sizeof(asf_header_internal_t));
+ if (!asf_header)
+ return NULL;
+
lprintf("parsing_asf_header\n");
if (buffer_len < 6) {
printf("invalid buffer size\n");
@@ -692,7 +694,8 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
}
if (!asf_header->pub.content) {
lprintf("no content object present\n");
- if (! (asf_header->pub.content = calloc(1, sizeof(asf_content_t))) )
+ asf_header->pub.content = calloc(1, sizeof(asf_content_t));
+ if (!asf_header->pub.content)
goto exit_error;
}
diff --git a/src/demuxers/asfheader.h b/src/demuxers/asfheader.h
index 4bd13ab3f..b895a1817 100644
--- a/src/demuxers/asfheader.h
+++ b/src/demuxers/asfheader.h
@@ -389,7 +389,7 @@ struct asf_stream_extension_s {
int asf_find_object_id (GUID *g);
void asf_get_guid (uint8_t *buffer, GUID *value);
-asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len);
+asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) XINE_MALLOC;
void asf_header_choose_streams (asf_header_t *header, uint32_t bandwidth,
int *video_id, int *audio_id);
void asf_header_disable_streams (asf_header_t *header,
diff --git a/src/demuxers/demux_4xm.c b/src/demuxers/demux_4xm.c
index 264806421..f8977d8c8 100644
--- a/src/demuxers/demux_4xm.c
+++ b/src/demuxers/demux_4xm.c
@@ -158,7 +158,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
/* read the whole header */
header_size = _X_LE_32(&preview[4]) - 4;
- header = xine_xmalloc(header_size);
+ header = malloc(header_size);
if (!header || fourxm->input->read(fourxm->input, header, header_size) != header_size) {
free(header);
return 0;
@@ -466,7 +466,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_fourxm_t *this;
- this = xine_xmalloc (sizeof (demux_fourxm_t));
+ this = calloc(1, sizeof(demux_fourxm_t));
this->stream = stream;
this->input = input;
@@ -506,7 +506,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_fourxm_init_plugin (xine_t *xine, void *data) {
demux_fourxm_class_t *this;
- this = xine_xmalloc (sizeof (demux_fourxm_class_t));
+ this = calloc(1, sizeof(demux_fourxm_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("4X Technologies (4xm) demux plugin");
diff --git a/src/demuxers/demux_aac.c b/src/demuxers/demux_aac.c
index 0b02f1d99..e6467ecd9 100644
--- a/src/demuxers/demux_aac.c
+++ b/src/demuxers/demux_aac.c
@@ -250,7 +250,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_aac_t *this;
- this = xine_xmalloc (sizeof (demux_aac_t));
+ this = calloc(1, sizeof(demux_aac_t));
this->stream = stream;
this->input = input;
@@ -287,7 +287,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_aac_init_plugin (xine_t *xine, void *data) {
demux_aac_class_t *this;
- this = xine_xmalloc (sizeof (demux_aac_class_t));
+ this = calloc(1, sizeof(demux_aac_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("ADIF/ADTS AAC demux plugin");
diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c
index 2ccd5217e..601f5c865 100644
--- a/src/demuxers/demux_ac3.c
+++ b/src/demuxers/demux_ac3.c
@@ -411,7 +411,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_ac3_t *this;
- this = xine_xmalloc (sizeof (demux_ac3_t));
+ this = calloc(1, sizeof(demux_ac3_t));
this->stream = stream;
this->input = input;
@@ -451,7 +451,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_ac3_init_plugin (xine_t *xine, void *data) {
demux_ac3_class_t *this;
- this = xine_xmalloc (sizeof (demux_ac3_class_t));
+ this = calloc(1, sizeof(demux_ac3_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Raw AC3 demux plugin");
diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c
index 06ff65680..8e3b63643 100644
--- a/src/demuxers/demux_aiff.c
+++ b/src/demuxers/demux_aiff.c
@@ -85,7 +85,7 @@ typedef struct {
} demux_aiff_class_t;
/* converts IEEE 80bit extended into int, based on FFMPEG code */
-int extended_to_int(const unsigned char p[10])
+static int extended_to_int(const unsigned char p[10])
{
uint64_t m = 0;
int e, i;
@@ -363,7 +363,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_aiff_t *this;
- this = xine_xmalloc (sizeof (demux_aiff_t));
+ this = calloc(1, sizeof(demux_aiff_t));
this->stream = stream;
this->input = input;
@@ -403,7 +403,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_aiff_init_plugin (xine_t *xine, void *data) {
demux_aiff_class_t *this;
- this = xine_xmalloc (sizeof (demux_aiff_class_t));
+ this = calloc(1, sizeof(demux_aiff_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("AIFF file demux plugin");
diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c
index 73f70eeb3..406264558 100644
--- a/src/demuxers/demux_asf.c
+++ b/src/demuxers/demux_asf.c
@@ -2051,7 +2051,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
return NULL;
}
- this = xine_xmalloc (sizeof (demux_asf_t));
+ this = calloc(1, sizeof(demux_asf_t));
this->stream = stream;
this->input = input;
@@ -2094,7 +2094,7 @@ static void *init_class (xine_t *xine, void *data) {
demux_asf_class_t *this;
- this = xine_xmalloc (sizeof (demux_asf_class_t));
+ this = calloc(1, sizeof(demux_asf_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/demuxers/demux_aud.c b/src/demuxers/demux_aud.c
index c58500ab2..5be209125 100644
--- a/src/demuxers/demux_aud.c
+++ b/src/demuxers/demux_aud.c
@@ -265,7 +265,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_aud_t *this;
- this = xine_xmalloc (sizeof (demux_aud_t));
+ this = calloc(1, sizeof(demux_aud_t));
this->stream = stream;
this->input = input;
@@ -304,7 +304,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_aud_init_plugin (xine_t *xine, void *data) {
demux_aud_class_t *this;
- this = xine_xmalloc (sizeof (demux_aud_class_t));
+ this = calloc(1, sizeof(demux_aud_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Westwood Studios AUD file demux plugin");
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index e06caf94f..0f1735f96 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -719,7 +719,7 @@ static void reset_idx(demux_avi_t *this, avi_t *AVI) {
}
}
-static avi_t *AVI_init(demux_avi_t *this) {
+static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) {
avi_t *AVI;
int i, j, idx_type;
@@ -739,7 +739,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
/* Create avi_t structure */
lprintf("start\n");
- AVI = (avi_t *) xine_xmalloc(sizeof(avi_t));
+ AVI = (avi_t *) calloc(1, sizeof(avi_t));
if(AVI==NULL) {
this->AVI_errno = AVI_ERR_NO_MEM;
return 0;
@@ -790,7 +790,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
if(strncasecmp(data,"hdrl",4) == 0) {
hdrl_len = n;
- hdrl_data = (unsigned char *) xine_xmalloc(n);
+ hdrl_data = (unsigned char *) malloc(n);
if(hdrl_data==0)
ERR_EXIT(AVI_ERR_NO_MEM);
if (this->input->read(this->input, hdrl_data,n) != n )
@@ -812,9 +812,8 @@ static avi_t *AVI_init(demux_avi_t *this) {
break if this is not the case */
AVI->n_idx = AVI->max_idx = n / 16;
- if (AVI->idx)
- free(AVI->idx); /* On the off chance there are multiple index chunks */
- AVI->idx = (unsigned char((*)[16])) xine_xmalloc(n);
+ free(AVI->idx); /* On the off chance there are multiple index chunks */
+ AVI->idx = (unsigned char((*)[16])) malloc(n);
if (AVI->idx == 0)
ERR_EXIT(AVI_ERR_NO_MEM);
@@ -877,12 +876,11 @@ static avi_t *AVI_init(demux_avi_t *this) {
} else if (strncasecmp (hdrl_data+i,"auds",4) ==0 /* && ! auds_strh_seen*/) {
if(AVI->n_audio < MAX_AUDIO_STREAMS) {
- avi_audio_t *a = (avi_audio_t *) xine_xmalloc(sizeof(avi_audio_t));
+ avi_audio_t *a = (avi_audio_t *) calloc(1, sizeof(avi_audio_t));
if(a==NULL) {
this->AVI_errno = AVI_ERR_NO_MEM;
return 0;
}
- memset((void *)a,0,sizeof(avi_audio_t));
AVI->audio[AVI->n_audio] = a;
a->audio_strn = num_stream;
@@ -922,7 +920,7 @@ static avi_t *AVI_init(demux_avi_t *this) {
if(lasttag == 1) {
/* lprintf ("size : %d\n",sizeof(AVI->bih)); */
AVI->bih = (xine_bmiheader *)
- xine_xmalloc((n < sizeof(xine_bmiheader)) ? sizeof(xine_bmiheader) : n);
+ malloc((n < sizeof(xine_bmiheader)) ? sizeof(xine_bmiheader) : n);
if(AVI->bih == NULL) {
this->AVI_errno = AVI_ERR_NO_MEM;
return 0;
@@ -2278,7 +2276,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_avi_t));
+ this = calloc(1, sizeof(demux_avi_t));
this->stream = stream;
this->input = input;
@@ -2320,7 +2318,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_class (xine_t *xine, void *data) {
demux_avi_class_t *this;
- this = xine_xmalloc (sizeof (demux_avi_class_t));
+ this = calloc(1, sizeof(demux_avi_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("AVI/RIFF demux plugin");
diff --git a/src/demuxers/demux_cdda.c b/src/demuxers/demux_cdda.c
index 03dcc2605..52c0a8d6d 100644
--- a/src/demuxers/demux_cdda.c
+++ b/src/demuxers/demux_cdda.c
@@ -181,7 +181,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_cdda_t *this;
- this = xine_xmalloc (sizeof (demux_cdda_t));
+ this = calloc(1, sizeof(demux_cdda_t));
this->stream = stream;
this->input = input;
@@ -216,7 +216,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_cdda_init_plugin (xine_t *xine, void *data) {
demux_cdda_class_t *this;
- this = xine_xmalloc (sizeof (demux_cdda_class_t));
+ this = calloc(1, sizeof(demux_cdda_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("CD Digital Audio demux plugin");
diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c
index 750d212f5..b69ba3859 100644
--- a/src/demuxers/demux_dts.c
+++ b/src/demuxers/demux_dts.c
@@ -386,7 +386,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_dts_t *this;
- this = xine_xmalloc (sizeof (demux_dts_t));
+ this = calloc(1, sizeof(demux_dts_t));
this->stream = stream;
this->input = input;
@@ -424,7 +424,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_dts_init_plugin (xine_t *xine, void *data) {
demux_dts_class_t *this;
- this = xine_xmalloc (sizeof (demux_dts_class_t));
+ this = calloc(1, sizeof(demux_dts_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Raw DTS demux plugin");
diff --git a/src/demuxers/demux_eawve.c b/src/demuxers/demux_eawve.c
index 04cc714d7..bf45f432a 100644
--- a/src/demuxers/demux_eawve.c
+++ b/src/demuxers/demux_eawve.c
@@ -345,7 +345,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
if (!INPUT_IS_SEEKABLE(input))
return NULL;
- this = xine_xmalloc(sizeof(demux_eawve_t));
+ this = calloc(1, sizeof(demux_eawve_t));
this->stream = stream;
this->input = input;
@@ -385,7 +385,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
void *demux_eawve_init_plugin(xine_t *xine, void *data) {
demux_eawve_class_t *this;
- this = xine_xmalloc(sizeof(demux_eawve_class_t));
+ this = calloc(1, sizeof(demux_eawve_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Electronics Arts WVE format demux plugin");
diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c
index e653818c4..098c7738e 100644
--- a/src/demuxers/demux_elem.c
+++ b/src/demuxers/demux_elem.c
@@ -227,7 +227,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_mpeg_elem_t));
+ this = calloc(1, sizeof(demux_mpeg_elem_t));
this->stream = stream;
this->input = input;
@@ -249,7 +249,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_elem_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_elem_class_t));
+ this = calloc(1, sizeof(demux_mpeg_elem_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Elementary MPEG stream demux plugin");
diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c
index f7b514e4b..32cf161a0 100644
--- a/src/demuxers/demux_film.c
+++ b/src/demuxers/demux_film.c
@@ -151,7 +151,7 @@ static int open_film_file(demux_film_t *film) {
/* header size = header size - 16-byte FILM signature */
film_header_size = _X_BE_32(&scratch[4]) - 16;
- film_header = xine_xmalloc(film_header_size);
+ film_header = malloc(film_header_size);
if (!film_header)
return 0;
memcpy(film->version, &scratch[8], 4);
@@ -335,8 +335,7 @@ static int open_film_file(demux_film_t *film) {
* first chunk (which will be more than enough for successive chunks) */
if (film->audio_type) {
free(film->interleave_buffer);
- film->interleave_buffer =
- xine_xmalloc(film->sample_table[0].sample_size);
+ film->interleave_buffer = calloc(1, film->sample_table[0].sample_size);
if (!film->interleave_buffer)
goto film_abort;
}
@@ -859,7 +858,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_film_t *this;
- this = xine_xmalloc (sizeof (demux_film_t));
+ this = calloc(1, sizeof(demux_film_t));
this->stream = stream;
this->input = input;
@@ -899,7 +898,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_film_init_plugin (xine_t *xine, void *data) {
demux_film_class_t *this;
- this = xine_xmalloc (sizeof (demux_film_class_t));
+ this = calloc(1, sizeof(demux_film_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("FILM (CPK) demux plugin");
diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c
index 94c599562..f011f2822 100644
--- a/src/demuxers/demux_flac.c
+++ b/src/demuxers/demux_flac.c
@@ -484,7 +484,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_flac_t));
+ this = calloc(1, sizeof(demux_flac_t));
this->stream = stream;
this->input = input;
@@ -524,7 +524,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_flac_init_plugin (xine_t *xine, void *data) {
demux_flac_class_t *this;
- this = xine_xmalloc (sizeof (demux_flac_class_t));
+ this = calloc(1, sizeof(demux_flac_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Free Lossless Audio Codec (flac) demux plugin");
diff --git a/src/demuxers/demux_fli.c b/src/demuxers/demux_fli.c
index 0dad5883a..c097b11b2 100644
--- a/src/demuxers/demux_fli.c
+++ b/src/demuxers/demux_fli.c
@@ -298,7 +298,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_fli_t *this;
- this = xine_xmalloc (sizeof (demux_fli_t));
+ this = calloc(1, sizeof(demux_fli_t));
this->stream = stream;
this->input = input;
@@ -338,7 +338,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_fli_class_t *this;
- this = xine_xmalloc (sizeof (demux_fli_class_t));
+ this = calloc(1, sizeof(demux_fli_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Autodesk Animator FLI/FLC demux plugin");
diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c
index e111468aa..2e712ef5a 100644
--- a/src/demuxers/demux_flv.c
+++ b/src/demuxers/demux_flv.c
@@ -365,7 +365,7 @@ static int parse_flv_var(demux_flv_t *this,
}
static void parse_flv_script(demux_flv_t *this, int size) {
- unsigned char *buf = xine_xmalloc(size);
+ unsigned char *buf = malloc(size);
unsigned char *tmp = buf;
unsigned char *end = buf + size;
int len;
@@ -854,7 +854,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input) {
demux_flv_t *this;
- this = xine_xmalloc(sizeof (demux_flv_t));
+ this = calloc(1, sizeof(demux_flv_t));
this->xine = stream->xine;
this->stream = stream;
this->input = input;
@@ -892,7 +892,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_flv_class_t *this;
- this = xine_xmalloc (sizeof (demux_flv_class_t));
+ this = calloc(1, sizeof(demux_flv_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Flash Video file demux plugin");
diff --git a/src/demuxers/demux_idcin.c b/src/demuxers/demux_idcin.c
index 695470415..3d6ecca51 100644
--- a/src/demuxers/demux_idcin.c
+++ b/src/demuxers/demux_idcin.c
@@ -468,7 +468,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_idcin_t *this;
- this = xine_xmalloc (sizeof (demux_idcin_t));
+ this = calloc(1, sizeof(demux_idcin_t));
this->stream = stream;
this->input = input;
@@ -508,7 +508,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_idcin_init_plugin (xine_t *xine, void *data) {
demux_idcin_class_t *this;
- this = xine_xmalloc (sizeof (demux_idcin_class_t));
+ this = calloc(1, sizeof(demux_idcin_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Id Quake II Cinematic file demux plugin");
diff --git a/src/demuxers/demux_iff.c b/src/demuxers/demux_iff.c
index dcef148b4..67392617b 100644
--- a/src/demuxers/demux_iff.c
+++ b/src/demuxers/demux_iff.c
@@ -212,7 +212,7 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_VHDR_CHUNK:
if( this->vhdr == NULL )
- this->vhdr = (Voice8Header *)xine_xmalloc(sizeof(Voice8Header));
+ this->vhdr = (Voice8Header *)calloc(1, sizeof(Voice8Header));
this->vhdr->oneShotHiSamples = _X_BE_32(&buffer[0]);
this->vhdr->repeatHiSamples = _X_BE_32(&buffer[4]);
this->vhdr->samplesPerHiCycle = _X_BE_32(&buffer[8]);
@@ -330,7 +330,7 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_BMHD_CHUNK:
if( this->bmhd == NULL )
- this->bmhd = (BitMapHeader *)xine_xmalloc(sizeof(BitMapHeader));
+ this->bmhd = (BitMapHeader *)calloc(1, sizeof(BitMapHeader));
this->bmhd->w = _X_BE_16(&buffer[0]);
this->bmhd->h = _X_BE_16(&buffer[2]);
this->bmhd->x = _X_BE_16(&buffer[4]);
@@ -399,20 +399,20 @@ static int read_iff_chunk(demux_iff_t *this) {
case IFF_CMAP_CHUNK:
/* every color contains red, green and blue componente using 8Bit */
this->cmap_num = junk_size / PIC_SIZE_OF_COLOR_REGISTER;
- this->cmap = (ColorRegister *)xine_xmalloc(junk_size);
+ this->cmap = (ColorRegister *)malloc(junk_size);
this->video_send_palette = 1;
if (!this->cmap || this->input->read(this->input, (char *)this->cmap, junk_size) != junk_size)
return 0;
break;
case IFF_GRAB_CHUNK:
if( this->grab == NULL )
- this->grab = (Point2D *)xine_xmalloc(sizeof(Point2D));
+ this->grab = (Point2D *)calloc(1, sizeof(Point2D));
this->grab->x = _X_BE_16(&buffer[0]);
this->grab->y = _X_BE_16(&buffer[2]);
break;
case IFF_DEST_CHUNK:
if( this->dest == NULL )
- this->dest = (DestMerge *)xine_xmalloc(sizeof(DestMerge));
+ this->dest = (DestMerge *)calloc(1, sizeof(DestMerge));
this->dest->depth = buffer[0];
this->dest->pad1 = buffer[1];
this->dest->plane_pick = _X_BE_16(&buffer[2]);
@@ -424,7 +424,7 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_CAMG_CHUNK:
if( this->camg == NULL )
- this->camg = (CamgChunk *)xine_xmalloc(sizeof(CamgChunk));
+ this->camg = (CamgChunk *)calloc(1, sizeof(CamgChunk));
this->camg->view_modes = _X_BE_32(&buffer[0]);
this->bih.biCompression = this->camg->view_modes;
if( this->camg->view_modes & CAMG_PAL &&
@@ -443,7 +443,7 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_CCRT_CHUNK:
if( this->ccrt == NULL )
- this->ccrt = (CcrtChunk *)xine_xmalloc(sizeof(CcrtChunk));
+ this->ccrt = (CcrtChunk *)calloc(1, sizeof(CcrtChunk));
this->ccrt->direction = _X_BE_16(&buffer[0]);
this->ccrt->start = buffer[2];
this->ccrt->end = buffer[3];
@@ -453,13 +453,13 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_DPI_CHUNK:
if( this->dpi == NULL )
- this->dpi = (DPIHeader *)xine_xmalloc(sizeof(DPIHeader));
+ this->dpi = (DPIHeader *)calloc(1, sizeof(DPIHeader));
this->dpi->x = _X_BE_16(&buffer[0]);
this->dpi->y = _X_BE_16(&buffer[0]);
break;
case IFF_ANHD_CHUNK:
if( this->anhd == NULL )
- this->anhd = (AnimHeader *)xine_xmalloc(sizeof(AnimHeader));
+ this->anhd = (AnimHeader *)calloc(1, sizeof(AnimHeader));
this->anhd->operation = buffer[0];
this->anhd->mask = buffer[1];
this->anhd->w = _X_BE_16(&buffer[2]);
@@ -500,7 +500,7 @@ static int read_iff_chunk(demux_iff_t *this) {
break;
case IFF_DPAN_CHUNK:
if( this->dpan == NULL )
- this->dpan = (DPAnimChunk *)xine_xmalloc(sizeof(DPAnimChunk));
+ this->dpan = (DPAnimChunk *)calloc(1, sizeof(DPAnimChunk));
this->dpan->version = _X_BE_16(&buffer[0]);
this->dpan->nframes = _X_BE_16(&buffer[2]);
this->dpan->fps = buffer[4];
@@ -711,14 +711,14 @@ static int demux_iff_send_chunk(demux_plugin_t *this_gen) {
if (this->audio_interleave_buffer_size > 0)
{
this->audio_interleave_buffer =
- xine_xmalloc(this->audio_interleave_buffer_size);
+ calloc(1, this->audio_interleave_buffer_size);
if (!this->audio_interleave_buffer)
return this->status = DEMUX_FINISHED;
}
if (this->audio_read_buffer_size > 0)
{
this->audio_read_buffer =
- xine_xmalloc(this->audio_read_buffer_size);
+ calloc(1, this->audio_read_buffer_size);
if (!this->audio_read_buffer)
return this->status = DEMUX_FINISHED;
}
@@ -1179,7 +1179,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_iff_t *this;
- this = xine_xmalloc (sizeof (demux_iff_t));
+ this = calloc(1, sizeof(demux_iff_t));
this->stream = stream;
this->input = input;
@@ -1219,7 +1219,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_iff_class_t *this;
- this = xine_xmalloc (sizeof (demux_iff_class_t));
+ this = calloc(1, sizeof(demux_iff_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("IFF demux plugin");
diff --git a/src/demuxers/demux_image.c b/src/demuxers/demux_image.c
index cb6f8c8fe..234ee3e07 100644
--- a/src/demuxers/demux_image.c
+++ b/src/demuxers/demux_image.c
@@ -180,7 +180,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
* if we reach this point, the input has been accepted.
*/
- this = xine_xmalloc (sizeof (demux_image_t));
+ this = calloc(1, sizeof(demux_image_t));
this->stream = stream;
this->input = input;
@@ -207,7 +207,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
static void *init_class (xine_t *xine, void *data) {
demux_image_class_t *this;
- this = xine_xmalloc (sizeof (demux_image_class_t));
+ this = calloc(1, sizeof(demux_image_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("image demux plugin");
diff --git a/src/demuxers/demux_ipmovie.c b/src/demuxers/demux_ipmovie.c
index 88fd70811..18982336c 100644
--- a/src/demuxers/demux_ipmovie.c
+++ b/src/demuxers/demux_ipmovie.c
@@ -672,7 +672,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_ipmovie_t *this;
- this = xine_xmalloc (sizeof (demux_ipmovie_t));
+ this = calloc(1, sizeof(demux_ipmovie_t));
this->stream = stream;
this->input = input;
@@ -713,7 +713,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_ipmovie_init_plugin (xine_t *xine, void *data) {
demux_ipmovie_class_t *this;
- this = xine_xmalloc (sizeof (demux_ipmovie_class_t));
+ this = calloc(1, sizeof(demux_ipmovie_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Interplay MVE Movie demux plugin");
diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c
index 713995e97..b0919036f 100644
--- a/src/demuxers/demux_matroska.c
+++ b/src/demuxers/demux_matroska.c
@@ -58,13 +58,6 @@
#define WRAP_THRESHOLD 90000
-#if !defined(MIN)
-#define MIN(a, b) ((a)<(b)?(a):(b))
-#endif
-#if !defined(MAX)
-#define MAX(a, b) ((a)>(b)?(a):(b))
-#endif
-
typedef struct {
int track_num;
off_t *pos;
@@ -1210,7 +1203,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
lprintf("Video\n");
if (track->video_track)
return 1;
- track->video_track = (matroska_video_track_t *)xine_xmalloc(sizeof(matroska_video_track_t));
+ track->video_track = (matroska_video_track_t *)calloc(1, sizeof(matroska_video_track_t));
if (!ebml_read_master (ebml, &elem))
return 0;
if ((elem.len > 0) && !parse_video_track(this, track->video_track))
@@ -1221,7 +1214,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
lprintf("Audio\n");
if (track->audio_track)
return 1;
- track->audio_track = (matroska_audio_track_t *)xine_xmalloc(sizeof(matroska_audio_track_t));
+ track->audio_track = (matroska_audio_track_t *)calloc(1, sizeof(matroska_audio_track_t));
if (!ebml_read_master (ebml, &elem))
return 0;
if ((elem.len > 0) && !parse_audio_track(this, track->audio_track))
@@ -1515,7 +1508,7 @@ static int parse_tracks(demux_matroska_t *this) {
matroska_track_t *track;
/* alloc and initialize a track with 0 */
- track = xine_xmalloc(sizeof(matroska_track_t));
+ track = calloc(1, sizeof(matroska_track_t));
track->compress_algo = MATROSKA_COMPRESS_NONE;
this->tracks[this->num_tracks] = track;
@@ -2832,7 +2825,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_matroska_t));
+ this = calloc(1, sizeof(demux_matroska_t));
this->demux_plugin.send_headers = demux_matroska_send_headers;
this->demux_plugin.send_chunk = demux_matroska_send_chunk;
@@ -2879,7 +2872,7 @@ static void *init_class (xine_t *xine, void *data) {
demux_matroska_class_t *this;
- this = xine_xmalloc (sizeof (demux_matroska_class_t));
+ this = calloc(1, sizeof(demux_matroska_class_t));
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
diff --git a/src/demuxers/demux_mng.c b/src/demuxers/demux_mng.c
index 18c4b1b57..f54245744 100644
--- a/src/demuxers/demux_mng.c
+++ b/src/demuxers/demux_mng.c
@@ -260,7 +260,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
demux_mng_t *this;
- this = xine_xmalloc (sizeof (demux_mng_t));
+ this = calloc(1, sizeof(demux_mng_t));
this->stream = stream;
this->input = input;
@@ -327,7 +327,7 @@ static demux_plugin_t* open_plugin(demux_class_t *class_gen, xine_stream_t *stre
static void *init_plugin(xine_t *xine, void *data){
demux_mng_class_t *this;
- this = xine_xmalloc (sizeof (demux_mng_class_t));
+ this = calloc(1, sizeof(demux_mng_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Multiple-image Network Graphics demux plugin");
diff --git a/src/demuxers/demux_mod.c b/src/demuxers/demux_mod.c
index 17e744b94..c424ffc81 100644
--- a/src/demuxers/demux_mod.c
+++ b/src/demuxers/demux_mod.c
@@ -302,7 +302,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_mod_t));
+ this = calloc(1, sizeof(demux_mod_t));
this->stream = stream;
this->input = input;
@@ -341,7 +341,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *demux_mod_init_plugin (xine_t *xine, void *data) {
demux_mod_class_t *this;
- this = xine_xmalloc (sizeof (demux_mod_class_t));
+ this = calloc(1, sizeof(demux_mod_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("ModPlug Amiga MOD Music file demux plugin");
diff --git a/src/demuxers/demux_mpc.c b/src/demuxers/demux_mpc.c
index 6a4cfb285..e11d85ee4 100644
--- a/src/demuxers/demux_mpc.c
+++ b/src/demuxers/demux_mpc.c
@@ -318,7 +318,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_mpc_t *this;
- this = xine_xmalloc (sizeof (demux_mpc_t));
+ this = calloc(1, sizeof(demux_mpc_t));
this->stream = stream;
this->input = input;
@@ -357,13 +357,15 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_mpc_init_plugin (xine_t *xine, void *data) {
demux_mpc_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpc_class_t));
+ this = calloc(1, sizeof(demux_mpc_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Musepack demux plugin");
this->demux_class.identifier = "Musepack";
- this->demux_class.mimetypes = NULL;
- this->demux_class.extensions = "mpc mp+";
+ this->demux_class.mimetypes =
+ "audio/musepack: mpc, mp+, mpp: Musepack audio;"
+ "audio/x-musepack: mpc, mp+, mpp: Musepack audio;";
+ this->demux_class.extensions = "mpc mp+ mpp";
this->demux_class.dispose = default_demux_class_dispose;
return this;
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 8c339fd88..39d4a575d 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -1062,7 +1062,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input) {
demux_mpeg_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_t));
+ this = calloc(1, sizeof(demux_mpeg_t));
this->stream = stream;
this->input = input;
@@ -1206,7 +1206,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_class_t));
+ this = calloc(1, sizeof(demux_mpeg_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("MPEG program stream demux plugin");
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index 7f7f71b97..8d2ec26a2 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -1372,7 +1372,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_mpeg_block_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_block_t));
+ this = calloc(1, sizeof(demux_mpeg_block_t));
this->stream = stream;
this->input = input;
@@ -1486,7 +1486,7 @@ static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_block_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_block_class_t));
+ this = calloc(1, sizeof(demux_mpeg_block_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c
index 21701f141..2687e21e8 100644
--- a/src/demuxers/demux_mpeg_pes.c
+++ b/src/demuxers/demux_mpeg_pes.c
@@ -275,7 +275,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode)
while ((p[2] != 1) || p[0] || p[1]) {
/* resync code */
- for(n=0;n<5;n++) p[n]=p[n+1];
+ memmove(p, p+1, 5);
i = read_data(this, p+5, (off_t) 1);
if (i != 1) {
this->status = DEMUX_FINISHED;
@@ -307,8 +307,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode)
p = buf->mem;
/* copy local buffer to fifo element. */
- for (n = 0; n < sizeof (buf6); n++)
- p[ n ] = buf6[ n ];
+ memcpy(p, buf6, sizeof(buf6));
if (preview_mode)
buf->decoder_flags = BUF_FLAG_PREVIEW;
@@ -1614,7 +1613,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
input_plugin_t *input = (input_plugin_t *) input_gen;
demux_mpeg_pes_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_pes_t));
+ this = calloc(1, sizeof(demux_mpeg_pes_t));
this->stream = stream;
this->input = input;
@@ -1747,7 +1746,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_mpeg_pes_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpeg_pes_class_t));
+ this = calloc(1, sizeof(demux_mpeg_pes_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index 6eb4ee622..4171b1de8 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -316,8 +316,8 @@ static int parse_frame_header(mpg_audio_frame_t *const frame, const uint8_t *con
* Parse a Xing header
* return the Xing header or NULL on error
*/
-static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame,
- uint8_t *buf, int bufsize) {
+static xing_header_t *XINE_MALLOC parse_xing_header(mpg_audio_frame_t *frame,
+ uint8_t *buf, int bufsize) {
uint8_t *ptr = buf;
xing_header_t *xing = NULL;
@@ -341,7 +341,7 @@ static xing_header_t* parse_xing_header(mpg_audio_frame_t *frame,
int has_frames_flag = 0;
int has_bytes_flag = 0;
- xing = xine_xmalloc (sizeof (xing_header_t));
+ xing = calloc(1, sizeof(xing_header_t));
if (!xing)
goto exit_error;
@@ -420,14 +420,14 @@ exit_error:
* Parse a Vbri header
* return the Vbri header or NULL on error
*/
-static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame,
- uint8_t *buf, int bufsize) {
+static vbri_header_t *XINE_MALLOC parse_vbri_header(mpg_audio_frame_t *frame,
+ uint8_t *buf, int bufsize) {
int i;
uint8_t *ptr = buf;
vbri_header_t *vbri;
- vbri = xine_xmalloc (sizeof (vbri_header_t));
+ vbri = calloc(1, sizeof(vbri_header_t));
if (!vbri)
return NULL;
@@ -1129,7 +1129,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_mpgaudio_t));
+ this = calloc(1, sizeof(demux_mpgaudio_t));
this->demux_plugin.send_headers = demux_mpgaudio_send_headers;
this->demux_plugin.send_chunk = demux_mpgaudio_send_chunk;
@@ -1161,7 +1161,7 @@ void *demux_mpgaudio_init_class (xine_t *xine, void *data) {
demux_mpgaudio_class_t *this;
- this = xine_xmalloc (sizeof (demux_mpgaudio_class_t));
+ this = calloc(1, sizeof(demux_mpgaudio_class_t));
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
diff --git a/src/demuxers/demux_nsv.c b/src/demuxers/demux_nsv.c
index 43b1fbc88..9c3b85e86 100644
--- a/src/demuxers/demux_nsv.c
+++ b/src/demuxers/demux_nsv.c
@@ -597,7 +597,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_nsv_t *this;
- this = xine_xmalloc (sizeof (demux_nsv_t));
+ this = calloc(1, sizeof(demux_nsv_t));
this->stream = stream;
this->input = input;
@@ -637,7 +637,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *demux_nsv_init_plugin (xine_t *xine, void *data) {
demux_nsv_class_t *this;
- this = xine_xmalloc (sizeof (demux_nsv_class_t));
+ this = calloc(1, sizeof(demux_nsv_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Nullsoft Video demux plugin");
diff --git a/src/demuxers/demux_pva.c b/src/demuxers/demux_pva.c
index 9987da057..64ba078db 100644
--- a/src/demuxers/demux_pva.c
+++ b/src/demuxers/demux_pva.c
@@ -425,7 +425,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_pva_t));
+ this = calloc(1, sizeof(demux_pva_t));
this->stream = stream;
this->input = input;
@@ -464,7 +464,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_pva_class_t *this;
- this = xine_xmalloc (sizeof (demux_pva_class_t));
+ this = calloc(1, sizeof(demux_pva_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("TechnoTrend PVA demux plugin");
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index b8e0acb12..b5ca5c59e 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -591,7 +591,7 @@ static void find_moov_atom(input_plugin_t *input, off_t *moov_offset,
static qt_info *create_qt_info(void) {
qt_info *info;
- info = (qt_info *)xine_xmalloc(sizeof(qt_info));
+ info = (qt_info *)calloc(1, sizeof(qt_info));
if (!info)
return NULL;
@@ -1263,10 +1263,11 @@ static qt_error parse_trak_atom (qt_trak *trak,
if (_X_BE_32(&trak_atom[atom_pos + 0x2C]))
trak->stsd_atoms[k].audio.bytes_per_sample =
_X_BE_32(&trak_atom[atom_pos + 0x2C]);
- trak->stsd_atoms[k].audio.samples_per_frame =
- (trak->stsd_atoms[k].audio.bytes_per_frame /
- trak->stsd_atoms[k].audio.bytes_per_packet) *
- trak->stsd_atoms[k].audio.samples_per_packet;
+ if (trak->stsd_atoms[k].audio.bytes_per_packet)
+ trak->stsd_atoms[k].audio.samples_per_frame =
+ (trak->stsd_atoms[k].audio.bytes_per_frame /
+ trak->stsd_atoms[k].audio.bytes_per_packet) *
+ trak->stsd_atoms[k].audio.samples_per_packet;
}
/* see if the trak deserves a promotion to VBR */
@@ -3046,7 +3047,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_qt_t));
+ this = calloc(1, sizeof(demux_qt_t));
this->stream = stream;
this->input = input;
@@ -3132,7 +3133,7 @@ static void *init_plugin (xine_t *xine, void *data) {
demux_qt_class_t *this;
- this = xine_xmalloc (sizeof (demux_qt_class_t));
+ this = calloc(1, sizeof(demux_qt_class_t));
this->config = xine->config;
this->xine = xine;
@@ -3143,7 +3144,9 @@ static void *init_plugin (xine_t *xine, void *data) {
"video/quicktime: mov,qt: Quicktime animation;"
"video/x-quicktime: mov,qt: Quicktime animation;"
"audio/x-m4a: m4a,m4b: MPEG-4 audio;"
- "application/x-quicktimeplayer: qtl: Quicktime list;";
+ "application/x-quicktimeplayer: qtl: Quicktime list;"
+ "video/mp4: mp4,mpg4: MPEG-4 video;"
+ "audio/mp4: mp4,mpg4: MPEG-4 audio;";
this->demux_class.extensions = "mov qt mp4 m4a m4b";
this->demux_class.dispose = default_demux_class_dispose;
diff --git a/src/demuxers/demux_rawdv.c b/src/demuxers/demux_rawdv.c
index 10b3170e6..da83a625c 100644
--- a/src/demuxers/demux_rawdv.c
+++ b/src/demuxers/demux_rawdv.c
@@ -341,7 +341,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_raw_dv_t *this;
- this = xine_xmalloc (sizeof (demux_raw_dv_t));
+ this = calloc(1, sizeof(demux_raw_dv_t));
this->stream = stream;
this->input = input;
@@ -396,7 +396,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_raw_dv_class_t *this;
- this = xine_xmalloc (sizeof (demux_raw_dv_class_t));
+ this = calloc(1, sizeof(demux_raw_dv_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Raw DV Video stream");
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index cc6a214e0..b7f2fc569 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -240,7 +240,7 @@ static void real_parse_index(demux_real_t *this) {
if(index && entries)
/* Allocate memory for index */
- *index = xine_xcalloc(entries, sizeof(real_index_entry_t));
+ *index = calloc(entries, sizeof(real_index_entry_t));
if(index && entries && *index) {
/* Read index */
@@ -434,7 +434,7 @@ static void real_parse_headers (demux_real_t *this) {
case CONT_TAG:
chunk_size -= PREAMBLE_SIZE;
- chunk_buffer = xine_xmalloc(chunk_size);
+ chunk_buffer = malloc(chunk_size);
if (this->input->read(this->input, chunk_buffer, chunk_size) !=
chunk_size) {
free (chunk_buffer);
@@ -769,7 +769,7 @@ unknown:
this->video_stream->mdpr->avg_bit_rate);
/* Allocate fragment offset table */
- this->fragment_tab = xine_xcalloc(FRAGMENT_TAB_SIZE, sizeof(uint32_t));
+ this->fragment_tab = calloc(FRAGMENT_TAB_SIZE, sizeof(uint32_t));
this->fragment_tab_max = FRAGMENT_TAB_SIZE;
}
@@ -1386,7 +1386,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
frames = (stream_read_word(this) & 0xf0) >> 4;
/* 2 bytes per frame size */
- sizes = xine_xcalloc(frames, sizeof(int));
+ sizes = calloc(frames, sizeof(int));
for(i = 0; i < frames; i++)
sizes[i] = stream_read_word(this);
@@ -1737,7 +1737,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
- this = xine_xmalloc (sizeof (demux_real_t));
+ this = calloc(1, sizeof(demux_real_t));
this->stream = stream;
this->input = input;
@@ -1770,7 +1770,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_class (xine_t *xine, void *data) {
demux_real_class_t *this;
- this = xine_xmalloc (sizeof (demux_real_class_t));
+ this = calloc(1, sizeof(demux_real_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("RealMedia file demux plugin");
diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c
index 2873a522e..81d4da274 100644
--- a/src/demuxers/demux_realaudio.c
+++ b/src/demuxers/demux_realaudio.c
@@ -110,7 +110,7 @@ static int open_ra_file(demux_ra_t *this) {
}
/* allocate for and read header data */
- this->header = xine_xmalloc(this->header_size);
+ this->header = malloc(this->header_size);
if (!this->header || _x_demux_read_header(this->input, this->header, this->header_size) != this->header_size) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_realaudio: unable to read header\n");
@@ -243,12 +243,10 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) {
}
if (this->audio_type == BUF_AUDIO_28_8 || this->audio_type == BUF_AUDIO_SIPRO) {
- int x;
uint8_t * buffer;
buffer = this->frame_buffer;
if (this->audio_type == BUF_AUDIO_SIPRO) {
- int n;
int len = this->h * this->w;
if(this->input->read(this->input, this->frame_buffer, len) < len) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
@@ -395,7 +393,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_ra_t *this;
- this = xine_xmalloc (sizeof (demux_ra_t));
+ this = calloc(1, sizeof(demux_ra_t));
this->stream = stream;
this->input = input;
this->frame_buffer = NULL;
@@ -436,7 +434,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_realaudio_init_plugin (xine_t *xine, void *data) {
demux_ra_class_t *this;
- this = xine_xmalloc (sizeof (demux_ra_class_t));
+ this = calloc(1, sizeof(demux_ra_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("RealAudio file demux plugin");
diff --git a/src/demuxers/demux_roq.c b/src/demuxers/demux_roq.c
index 83e589be0..028f3bcaf 100644
--- a/src/demuxers/demux_roq.c
+++ b/src/demuxers/demux_roq.c
@@ -406,7 +406,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_roq_t));
+ this = calloc(1, sizeof(demux_roq_t));
this->stream = stream;
this->input = input;
@@ -446,7 +446,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_roq_init_plugin (xine_t *xine, void *data) {
demux_roq_class_t *this;
- this = xine_xmalloc (sizeof (demux_roq_class_t));
+ this = calloc(1, sizeof(demux_roq_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Id RoQ file demux plugin");
diff --git a/src/demuxers/demux_shn.c b/src/demuxers/demux_shn.c
index d5e46f873..d72a999fd 100644
--- a/src/demuxers/demux_shn.c
+++ b/src/demuxers/demux_shn.c
@@ -176,7 +176,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_shn_t *this;
- this = xine_xmalloc (sizeof (demux_shn_t));
+ this = calloc(1, sizeof(demux_shn_t));
this->stream = stream;
this->input = input;
@@ -213,7 +213,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_shn_init_plugin (xine_t *xine, void *data) {
demux_shn_class_t *this;
- this = xine_xmalloc (sizeof (demux_shn_class_t));
+ this = calloc(1, sizeof(demux_shn_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Shorten demux plugin");
diff --git a/src/demuxers/demux_slave.c b/src/demuxers/demux_slave.c
index 80a5ebbf8..25fd1ab63 100644
--- a/src/demuxers/demux_slave.c
+++ b/src/demuxers/demux_slave.c
@@ -186,10 +186,8 @@ static int demux_slave_next (demux_slave_t *this) {
buf->decoder_flags = decoder_flags;
/* set decoder info */
- for( i = 0; i < BUF_NUM_DEC_INFO; i++ ) {
- buf->decoder_info[i] = this->decoder_info[i];
- buf->decoder_info_ptr[i] = this->decoder_info_ptr[i];
- }
+ memcpy(buf->decoder_info, this->decoder_info, sizeof(this->decoder_info));
+ memcpy(buf->decoder_info_ptr, this->decoder_info_ptr, sizeof(this->decoder_info));
memset(this->decoder_info, 0, sizeof(this->decoder_info));
memset(this->decoder_info_ptr, 0, sizeof(this->decoder_info_ptr));
@@ -331,7 +329,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_slave_t *this;
static char slave_id_str[] = "master xine v1\n";
- this = xine_xmalloc (sizeof (demux_slave_t));
+ this = calloc(1, sizeof(demux_slave_t));
switch (stream->content_detection_method) {
@@ -383,7 +381,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_slave_class_t *this;
- this = xine_xmalloc (sizeof (demux_slave_class_t));
+ this = calloc(1, sizeof(demux_slave_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = "";
diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c
index d9b436032..1c7d7a28e 100644
--- a/src/demuxers/demux_smjpeg.c
+++ b/src/demuxers/demux_smjpeg.c
@@ -398,7 +398,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_smjpeg_t));
+ this = calloc(1, sizeof(demux_smjpeg_t));
this->stream = stream;
this->input = input;
@@ -438,7 +438,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_smjpeg_init_plugin (xine_t *xine, void *data) {
demux_smjpeg_class_t *this;
- this = xine_xmalloc (sizeof (demux_smjpeg_class_t));
+ this = calloc(1, sizeof(demux_smjpeg_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("SMJPEG file demux plugin");
diff --git a/src/demuxers/demux_snd.c b/src/demuxers/demux_snd.c
index d7bdd0839..17a783bef 100644
--- a/src/demuxers/demux_snd.c
+++ b/src/demuxers/demux_snd.c
@@ -312,7 +312,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_snd_t *this;
- this = xine_xmalloc (sizeof (demux_snd_t));
+ this = calloc(1, sizeof(demux_snd_t));
this->stream = stream;
this->input = input;
@@ -352,7 +352,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_snd_init_plugin (xine_t *xine, void *data) {
demux_snd_class_t *this;
- this = xine_xmalloc (sizeof (demux_snd_class_t));
+ this = calloc(1, sizeof(demux_snd_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("SND/AU file demux plugin");
diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c
index f125f09c5..aec526eb6 100644
--- a/src/demuxers/demux_str.c
+++ b/src/demuxers/demux_str.c
@@ -188,9 +188,7 @@ static int open_str_file(demux_str_t *this) {
unsigned char check_bytes[STR_CHECK_BYTES];
int local_offset, sector, channel;
- for (channel = 0; channel < STR_MAX_CHANNELS; channel++) {
- this->channel_type[channel] = 0;
- }
+ memset(this->channel_type, 0, sizeof(this->channel_type));
this->input->seek(this->input, 0, SEEK_SET);
if (this->input->read(this->input, check_bytes, STR_CHECK_BYTES) !=
@@ -550,7 +548,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_str_t));
+ this = calloc(1, sizeof(demux_str_t));
this->stream = stream;
this->input = input;
@@ -589,7 +587,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_str_init_plugin (xine_t *xine, void *data) {
demux_str_class_t *this;
- this = xine_xmalloc (sizeof (demux_str_class_t));
+ this = calloc(1, sizeof(demux_str_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Sony Playstation STR file demux plugin");
diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c
index 1bc33b44c..785f404d4 100644
--- a/src/demuxers/demux_ts.c
+++ b/src/demuxers/demux_ts.c
@@ -187,9 +187,6 @@
#define INVALID_PROGRAM ((unsigned int)(-1))
#define INVALID_CC ((unsigned int)(-1))
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
#define PROG_STREAM_MAP 0xBC
#define PRIVATE_STREAM1 0xBD
#define PADDING_STREAM 0xBE
@@ -222,7 +219,9 @@
ISO_13818_PART7_AUDIO = 0x0f, /* ISO/IEC 13818-7 Audio with ADTS transport sytax */
ISO_14496_PART2_VIDEO = 0x10, /* ISO/IEC 14496-2 Visual (MPEG-4) */
ISO_14496_PART3_AUDIO = 0x11, /* ISO/IEC 14496-3 Audio with LATM transport syntax */
- ISO_14496_PART10_VIDEO = 0x1b /* ISO/IEC 14496-10 Video (MPEG-4 part 10/AVC, aka H.264) */
+ ISO_14496_PART10_VIDEO = 0x1b, /* ISO/IEC 14496-10 Video (MPEG-4 part 10/AVC, aka H.264) */
+ STREAM_VIDEO_MPEG = 0x80,
+ STREAM_AUDIO_AC3 = 0x81,
} streamType;
#define WRAP_THRESHOLD 270000
@@ -248,7 +247,7 @@ typedef struct {
int64_t pts;
buf_element_t *buf;
unsigned int counter;
- uint8_t descriptor_tag;
+ uint16_t descriptor_tag; /* +0x100 for PES stream IDs (no available TS descriptor tag?) */
int64_t packet_count;
int corrupted_pes;
uint32_t buffered_bytes;
@@ -734,21 +733,21 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
* do not include any of the ac3 header info in their audio tracks
* these "raw" streams may begin with a byte that looks like a stream type.
*/
- if((m->descriptor_tag == 0x81) || /* ac3 - raw */
+ if((m->descriptor_tag == STREAM_AUDIO_AC3) || /* ac3 - raw */
(p[0] == 0x0B && p[1] == 0x77)) { /* ac3 - syncword */
m->content = p;
m->size = packet_len;
- m->type |= BUF_AUDIO_A52;
+ m->type = BUF_AUDIO_A52;
return 1;
- } else if (m->descriptor_tag == 0x06
+ } else if (m->descriptor_tag == ISO_13818_PES_PRIVATE
&& p[0] == 0x20 && p[1] == 0x00) {
/* DVBSUB */
long payload_len = ((buf[4] << 8) | buf[5]) - header_len - 3;
m->content = p;
m->size = packet_len;
- m->type |= BUF_SPU_DVB;
+ m->type = BUF_SPU_DVB;
m->buf->decoder_info[2] = payload_len;
return 1;
} else if ((p[0] & 0xE0) == 0x20) {
@@ -762,7 +761,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
m->content = p+4;
m->size = packet_len - 4;
- m->type |= BUF_AUDIO_A52;
+ m->type = BUF_AUDIO_A52;
return 1;
} else if ((p[0]&0xf0) == 0xa0) {
@@ -778,7 +777,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
m->content = p+pcm_offset;
m->size = packet_len-pcm_offset;
- m->type |= BUF_AUDIO_LPCM_BE;
+ m->type = BUF_AUDIO_LPCM_BE;
return 1;
}
@@ -789,6 +788,7 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
switch (m->descriptor_tag) {
case ISO_11172_VIDEO:
case ISO_13818_VIDEO:
+ case STREAM_VIDEO_MPEG:
lprintf ("demux_ts: found MPEG video type.\n");
m->type = BUF_VIDEO_MPEG;
break;
@@ -815,16 +815,16 @@ static int demux_ts_parse_pes_header (xine_t *xine, demux_ts_media *m,
case ISO_11172_AUDIO:
case ISO_13818_AUDIO:
lprintf ("demux_ts: found MPEG audio track.\n");
- m->type |= BUF_AUDIO_MPEG;
+ m->type = BUF_AUDIO_MPEG;
break;
case ISO_13818_PART7_AUDIO:
case ISO_14496_PART3_AUDIO:
lprintf ("demux_ts: found AAC audio track.\n");
- m->type |= BUF_AUDIO_AAC;
+ m->type = BUF_AUDIO_AAC;
break;
default:
lprintf ("demux_ts: unknown audio type: %d, defaulting to MPEG.\n", m->descriptor_tag);
- m->type |= BUF_AUDIO_MPEG;
+ m->type = BUF_AUDIO_MPEG;
break;
}
return 1;
@@ -963,7 +963,7 @@ static void demux_ts_pes_new(demux_ts_t*this,
unsigned int mediaIndex,
unsigned int pid,
fifo_buffer_t *fifo,
- uint8_t descriptor) {
+ uint16_t descriptor) {
demux_ts_media *m = &this->media[mediaIndex];
@@ -1220,6 +1220,15 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
}
}
+ /*
+ * Forget the current video, audio and subtitle PIDs; if the PMT has not
+ * changed, we'll pick them up again when we parse this PMT, while if the
+ * PMT has changed (e.g. an IPTV streamer that's just changed its source),
+ * we'll get new PIDs that we should follow.
+ */
+ this->audio_tracks_count = 0;
+ this->videoPid = INVALID_PID;
+ this->spu_pid = INVALID_PID;
/*
* ES definitions start here...we are going to learn upto one video
@@ -1333,7 +1342,7 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num
printf ("demux_ts: PMT AC3 audio pid 0x%.4x type %2.2x\n", pid, stream[0]);
#endif
demux_ts_pes_new(this, this->media_num, pid,
- this->audio_fifo, 0x81);
+ this->audio_fifo, STREAM_AUDIO_AC3);
this->audio_tracks[this->audio_tracks_count].pid = pid;
this->audio_tracks[this->audio_tracks_count].media_index = this->media_num;
@@ -1826,7 +1835,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) {
} else if (!found) {
this->videoPid = pid;
this->videoMedia = this->media_num;
- demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, pes_stream_id);
+ demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, 0x100 + pes_stream_id);
}
if (this->videoPid != INVALID_PID) {
@@ -1852,7 +1861,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) {
this->audio_tracks[this->audio_tracks_count].media_index = this->media_num;
this->media[this->media_num].type = this->audio_tracks_count;
demux_ts_pes_new(this, this->media_num++, pid,
- this->audio_fifo,pes_stream_id);
+ this->audio_fifo, 0x100 + pes_stream_id);
this->audio_tracks_count++;
}
}
@@ -2189,7 +2198,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
* if we reach this point, the input has been accepted.
*/
- this = xine_xmalloc(sizeof(*this));
+ this = calloc(1, sizeof(*this));
this->stream = stream;
this->input = input;
this->class = class_gen;
@@ -2231,10 +2240,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
this->status = DEMUX_FINISHED;
-#ifdef TS_READ_STATS
- memset(this-rstat, 0, sizeof(*this->rstat)*NPKT_PER_READ);
-#endif
-
/* DVBSUB */
this->spu_pid = INVALID_PID;
this->spu_langs_count = 0;
@@ -2255,7 +2260,7 @@ static void *init_class (xine_t *xine, void *data) {
demux_ts_class_t *this;
- this = xine_xmalloc (sizeof (demux_ts_class_t));
+ this = calloc(1, sizeof(demux_ts_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c
index 2d35a60e8..07b2096e2 100644
--- a/src/demuxers/demux_tta.c
+++ b/src/demuxers/demux_tta.c
@@ -226,7 +226,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_tta_t *this;
- this = xine_xmalloc (sizeof (demux_tta_t));
+ this = calloc(1, sizeof(demux_tta_t));
this->stream = stream;
this->input = input;
@@ -266,7 +266,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_tta_init_plugin (xine_t *xine, void *data) {
demux_tta_class_t *this;
- this = xine_xmalloc (sizeof (demux_tta_class_t));
+ this = calloc(1, sizeof(demux_tta_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("True Audio demux plugin");
diff --git a/src/demuxers/demux_vmd.c b/src/demuxers/demux_vmd.c
index d1d98f534..cbd413b4a 100644
--- a/src/demuxers/demux_vmd.c
+++ b/src/demuxers/demux_vmd.c
@@ -415,7 +415,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_vmd_t *this;
- this = xine_xmalloc (sizeof (demux_vmd_t));
+ this = calloc(1, sizeof(demux_vmd_t));
this->stream = stream;
this->input = input;
@@ -455,7 +455,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_vmd_init_plugin (xine_t *xine, void *data) {
demux_vmd_class_t *this;
- this = xine_xmalloc (sizeof (demux_vmd_class_t));
+ this = calloc(1, sizeof(demux_vmd_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Sierra VMD file demux plugin");
diff --git a/src/demuxers/demux_voc.c b/src/demuxers/demux_voc.c
index ce42d61d8..6312c568c 100644
--- a/src/demuxers/demux_voc.c
+++ b/src/demuxers/demux_voc.c
@@ -290,7 +290,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_voc_t *this;
- this = xine_xmalloc (sizeof (demux_voc_t));
+ this = calloc(1, sizeof(demux_voc_t));
this->stream = stream;
this->input = input;
@@ -330,7 +330,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_voc_init_plugin (xine_t *xine, void *data) {
demux_voc_class_t *this;
- this = xine_xmalloc (sizeof (demux_voc_class_t));
+ this = calloc(1, sizeof(demux_voc_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("VOC file demux plugin");
diff --git a/src/demuxers/demux_vox.c b/src/demuxers/demux_vox.c
index 306f2414f..12de83ac9 100644
--- a/src/demuxers/demux_vox.c
+++ b/src/demuxers/demux_vox.c
@@ -191,7 +191,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- this = xine_xmalloc (sizeof (demux_vox_t));
+ this = calloc(1, sizeof(demux_vox_t));
this->stream = stream;
this->input = input;
@@ -213,7 +213,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_vox_init_plugin (xine_t *xine, void *data) {
demux_vox_class_t *this;
- this = xine_xmalloc (sizeof (demux_vox_class_t));
+ this = calloc(1, sizeof(demux_vox_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Dialogic VOX file demux plugin");
diff --git a/src/demuxers/demux_vqa.c b/src/demuxers/demux_vqa.c
index 3acd56bc1..05331d39d 100644
--- a/src/demuxers/demux_vqa.c
+++ b/src/demuxers/demux_vqa.c
@@ -328,7 +328,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_vqa_t *this;
- this = xine_xmalloc (sizeof (demux_vqa_t));
+ this = calloc(1, sizeof(demux_vqa_t));
this->stream = stream;
this->input = input;
@@ -368,7 +368,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_vqa_init_plugin (xine_t *xine, void *data) {
demux_vqa_class_t *this;
- this = xine_xmalloc (sizeof (demux_vqa_class_t));
+ this = calloc(1, sizeof(demux_vqa_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Westwood Studios VQA file demux plugin");
diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c
index 2beb43291..3fff4ef3d 100644
--- a/src/demuxers/demux_wav.c
+++ b/src/demuxers/demux_wav.c
@@ -111,9 +111,6 @@ static int find_chunk_by_tag(demux_wav_t *this, const uint32_t given_chunk_tag,
/* returns 1 if the WAV file was opened successfully, 0 otherwise */
static int open_wav_file(demux_wav_t *this) {
uint8_t signature[WAV_SIGNATURE_SIZE];
- uint32_t chunk_tag;
- uint32_t chunk_size;
- uint8_t chunk_preamble[8];
off_t wave_pos;
/* check the signature */
@@ -129,7 +126,7 @@ static int open_wav_file(demux_wav_t *this) {
return 0;
this->input->seek(this->input, wave_pos, SEEK_SET);
- this->wave = xine_xmalloc( this->wave_size );
+ this->wave = malloc( this->wave_size );
if (!this->wave || this->input->read(this->input, (void *)this->wave, this->wave_size) !=
this->wave_size) {
@@ -360,7 +357,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_wav_t *this;
uint32_t align;
- this = xine_xmalloc (sizeof (demux_wav_t));
+ this = calloc(1, sizeof(demux_wav_t));
this->stream = stream;
this->input = input;
@@ -409,7 +406,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_wav_init_plugin (xine_t *xine, void *data) {
demux_wav_class_t *this;
- this = xine_xmalloc (sizeof (demux_wav_class_t));
+ this = calloc(1, sizeof(demux_wav_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("WAV file demux plugin");
diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c
index 5be59b12b..11c9d4bf9 100644
--- a/src/demuxers/demux_wc3movie.c
+++ b/src/demuxers/demux_wc3movie.c
@@ -672,7 +672,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_mve_t *this;
- this = xine_xmalloc (sizeof (demux_mve_t));
+ this = calloc(1, sizeof(demux_mve_t));
this->stream = stream;
this->input = input;
@@ -712,7 +712,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
void *demux_wc3movie_init_plugin (xine_t *xine, void *data) {
demux_mve_class_t *this;
- this = xine_xmalloc (sizeof (demux_mve_class_t));
+ this = calloc(1, sizeof(demux_mve_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("Wing Commander III Movie (MVE) demux plugin");
diff --git a/src/demuxers/demux_yuv4mpeg2.c b/src/demuxers/demux_yuv4mpeg2.c
index a0bf31bce..69b1a8baa 100644
--- a/src/demuxers/demux_yuv4mpeg2.c
+++ b/src/demuxers/demux_yuv4mpeg2.c
@@ -397,7 +397,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
demux_yuv4mpeg2_t *this;
- this = xine_xmalloc (sizeof (demux_yuv4mpeg2_t));
+ this = calloc(1, sizeof(demux_yuv4mpeg2_t));
this->stream = stream;
this->input = input;
@@ -437,7 +437,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
static void *init_plugin (xine_t *xine, void *data) {
demux_yuv4mpeg2_class_t *this;
- this = xine_xmalloc (sizeof (demux_yuv4mpeg2_class_t));
+ this = calloc(1, sizeof(demux_yuv4mpeg2_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("YUV4MPEG2 file demux plugin");
diff --git a/src/demuxers/demux_yuv_frames.c b/src/demuxers/demux_yuv_frames.c
index 0cef51f60..d960e8d4c 100644
--- a/src/demuxers/demux_yuv_frames.c
+++ b/src/demuxers/demux_yuv_frames.c
@@ -197,7 +197,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
* if we reach this point, the input has been accepted.
*/
- this = xine_xmalloc (sizeof (demux_yuv_frames_t));
+ this = calloc(1, sizeof(demux_yuv_frames_t));
this->stream = stream;
this->input = input;
@@ -224,7 +224,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen,
static void *init_class (xine_t *xine, void *data) {
demux_yuv_frames_class_t *this;
- this = xine_xmalloc (sizeof (demux_yuv_frames_class_t));
+ this = calloc(1, sizeof(demux_yuv_frames_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.description = N_("YUV frames dummy demux plugin");
diff --git a/src/demuxers/ebml.h b/src/demuxers/ebml.h
index a090bb130..764f416ff 100644
--- a/src/demuxers/ebml.h
+++ b/src/demuxers/ebml.h
@@ -65,7 +65,7 @@ typedef struct ebml_parser_s {
} ebml_parser_t;
-ebml_parser_t *new_ebml_parser (xine_t *xine, input_plugin_t *input);
+ebml_parser_t *new_ebml_parser (xine_t *xine, input_plugin_t *input) XINE_MALLOC;
void dispose_ebml_parser (ebml_parser_t *ebml);
diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c
index 71cb5e743..b57d1bd82 100644
--- a/src/demuxers/id3.c
+++ b/src/demuxers/id3.c
@@ -329,9 +329,9 @@ static int id3v22_interp_frame(input_plugin_t *input,
}
-int id3v22_parse_tag(input_plugin_t *input,
- xine_stream_t *stream,
- uint32_t id3_signature) {
+static int id3v22_parse_tag(input_plugin_t *input,
+ xine_stream_t *stream,
+ uint32_t id3_signature) {
id3v2_header_t tag_header;
id3v22_frame_header_t tag_frame_header;
int pos = 0;
@@ -514,9 +514,9 @@ static int id3v23_interp_frame(input_plugin_t *input,
}
}
-int id3v23_parse_tag(input_plugin_t *input,
- xine_stream_t *stream,
- uint32_t id3_signature) {
+static int id3v23_parse_tag(input_plugin_t *input,
+ xine_stream_t *stream,
+ uint32_t id3_signature) {
id3v2_header_t tag_header;
id3v23_frame_header_t tag_frame_header;
id3v23_frame_ext_header_t tag_frame_ext_header;
@@ -759,9 +759,9 @@ static int id3v24_interp_frame(input_plugin_t *input,
}
}
-int id3v24_parse_tag(input_plugin_t *input,
- xine_stream_t *stream,
- uint32_t id3_signature) {
+static int id3v24_parse_tag(input_plugin_t *input,
+ xine_stream_t *stream,
+ uint32_t id3_signature) {
id3v2_header_t tag_header;
id3v24_frame_header_t tag_frame_header;
id3v24_frame_ext_header_t tag_frame_ext_header;
@@ -849,6 +849,6 @@ int id3v2_parse_tag(input_plugin_t *input,
default:
xprintf(stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": Unknown ID3v2 signature: 0x%08x.\n", be2me_32(id3_signature));
}
-
+
return 0;
}
diff --git a/src/demuxers/id3.h b/src/demuxers/id3.h
index 542a17bc4..837d8243f 100644
--- a/src/demuxers/id3.h
+++ b/src/demuxers/id3.h
@@ -152,19 +152,16 @@ typedef struct {
int id3v1_parse_tag (input_plugin_t *input, xine_stream_t *stream);
-int id3v22_parse_tag(input_plugin_t *input,
- xine_stream_t *stream,
- uint32_t id3_signature);
-
-int id3v23_parse_tag(input_plugin_t *input,
- xine_stream_t *stream,
- uint32_t id3_signature);
-
-int id3v24_parse_tag(input_plugin_t *input,
- xine_stream_t *stream,
- uint32_t id3_signature);
-
-/* Generic function that switch between the three above */
+/**
+ * @brief Generic function for ID3v2 tags parsing.
+ * @param input Pointer to the input plugin used by the demuxer, used
+ * to access the tag's data.
+ * @param stream Pointer to the xine stream currently being read.
+ * @param mp3_frame_header Header of the MP3 frame carrying the tag.
+ *
+ * @note This function will take care of calling the proper function for
+ * parsing ID3v2.2, ID3v2.3 or ID3v2.4 tags.
+ */
int id3v2_parse_tag(input_plugin_t *input,
xine_stream_t *stream,
uint32_t id3_signature);
diff --git a/src/dxr3/dxr3_decode_spu.c b/src/dxr3/dxr3_decode_spu.c
index 01dd20b05..74dcc3aad 100644
--- a/src/dxr3/dxr3_decode_spu.c
+++ b/src/dxr3/dxr3_decode_spu.c
@@ -177,7 +177,7 @@ static void *dxr3_spudec_init_plugin(xine_t *xine, void* data)
{
dxr3_spudec_class_t *this;
- this = (dxr3_spudec_class_t *)xine_xmalloc(sizeof(dxr3_spudec_class_t));
+ this = calloc(1, sizeof(dxr3_spudec_class_t));
if (!this) return NULL;
this->spu_decoder_class.open_plugin = dxr3_spudec_open_plugin;
@@ -200,7 +200,7 @@ static spu_decoder_t *dxr3_spudec_open_plugin(spu_decoder_class_t *class_gen, xi
if (class->instance) return NULL;
if (!dxr3_present(stream)) return NULL;
- this = (dxr3_spudec_t *)xine_xmalloc(sizeof(dxr3_spudec_t));
+ this = calloc(1, sizeof(dxr3_spudec_t));
if (!this) return NULL;
this->spu_decoder.decode_data = dxr3_spudec_decode_data;
@@ -337,7 +337,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf)
printf("dxr3_decode_spu: DEBUG: allocating new PCI node for hli_s_ptm %d\n", pci.hli.hl_gi.hli_s_ptm);
/* append PCI at the end of the list */
while (node->next) node = node->next;
- node->next = (pci_node_t *)xine_xmalloc(sizeof(pci_node_t));
+ node->next = calloc(1, sizeof(pci_node_t));
node->next->vpts = this->stream->metronom->got_spu_packet(this->stream->metronom, pci.hli.hl_gi.hli_s_ptm);
node->next->next = NULL;
xine_fast_memcpy(&node->next->pci, &pci, sizeof(pci_t));
diff --git a/src/dxr3/dxr3_decode_video.c b/src/dxr3/dxr3_decode_video.c
index 4347fb808..a6be99758 100644
--- a/src/dxr3/dxr3_decode_video.c
+++ b/src/dxr3/dxr3_decode_video.c
@@ -171,7 +171,7 @@ static void *dxr3_init_plugin(xine_t *xine, void *data)
{
dxr3_decoder_class_t *this;
- this = (dxr3_decoder_class_t *)xine_xmalloc(sizeof (dxr3_decoder_class_t));
+ this = calloc(1, sizeof (dxr3_decoder_class_t));
if (!this) return NULL;
this->video_decoder_class.open_plugin = dxr3_open_plugin;
@@ -198,7 +198,7 @@ static video_decoder_t *dxr3_open_plugin(video_decoder_class_t *class_gen, xine_
if (class->instance) return NULL;
if (!dxr3_present(stream)) return NULL;
- this = (dxr3_decoder_t *)xine_xmalloc(sizeof (dxr3_decoder_t));
+ this = calloc(1, sizeof (dxr3_decoder_t));
if (!this) return NULL;
cfg = stream->xine->config;
diff --git a/src/dxr3/dxr3_mpeg_encoders.c b/src/dxr3/dxr3_mpeg_encoders.c
index cd9180eb6..9ab4792ac 100644
--- a/src/dxr3/dxr3_mpeg_encoders.c
+++ b/src/dxr3/dxr3_mpeg_encoders.c
@@ -119,7 +119,7 @@ int dxr3_rte_init(dxr3_driver_t *drv)
return 0;
}
- this = xine_xmalloc(sizeof(rte_data_t));
+ this = calloc(1, sizeof(rte_data_t));
if (!this) return 0;
this->encoder_data.type = ENC_RTE;
@@ -311,7 +311,7 @@ int dxr3_fame_init(dxr3_driver_t *drv)
{
fame_data_t *this;
- this = xine_xmalloc(sizeof(fame_data_t));
+ this = calloc(1, sizeof(fame_data_t));
if (!this) return 0;
this->encoder_data.type = ENC_FAME;
diff --git a/src/dxr3/dxr3_scr.c b/src/dxr3/dxr3_scr.c
index 8fb049656..c95ab00a7 100644
--- a/src/dxr3/dxr3_scr.c
+++ b/src/dxr3/dxr3_scr.c
@@ -70,7 +70,7 @@ dxr3_scr_t *dxr3_scr_init(xine_t *xine)
int devnum;
char tmpstr[128];
- this = (dxr3_scr_t *)xine_xmalloc(sizeof(dxr3_scr_t));
+ this = calloc(1, sizeof(dxr3_scr_t));
devnum = xine->config->register_num(xine->config,
CONF_KEY, 0, CONF_NAME, CONF_HELP, 10, NULL, NULL);
diff --git a/src/dxr3/ffmpeg_encoder.c b/src/dxr3/ffmpeg_encoder.c
index 06eee8c17..ca132167c 100644
--- a/src/dxr3/ffmpeg_encoder.c
+++ b/src/dxr3/ffmpeg_encoder.c
@@ -38,7 +38,11 @@
#include "video_out_dxr3.h"
-#include <avcodec.h>
+#ifdef HAVE_FFMPEG_AVUTIL_H
+# include <avcodec.h>
+#else
+# include <libavcodec/avcodec.h>
+#endif
/* buffer size for encoded mpeg1 stream; will hold one intra frame
* at 640x480 typical sizes are <50 kB. 512 kB should be plenty */
@@ -77,7 +81,7 @@ int dxr3_lavc_init(dxr3_driver_t *drv, plugin_node_t *plugin)
avcodec_register_all();
lprintf("lavc init , version %x\n", avcodec_version());
- this = xine_xmalloc(sizeof(lavc_data_t));
+ this = calloc(1, sizeof(lavc_data_t));
if (!this) return 0;
this->encoder_data.type = ENC_LAVC;
diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c
index 70937cfd0..672c2c409 100644
--- a/src/dxr3/video_out_dxr3.c
+++ b/src/dxr3/video_out_dxr3.c
@@ -169,7 +169,7 @@ static dxr3_driver_class_t *dxr3_vo_init_plugin(xine_t *xine, void *visual_gen)
{
dxr3_driver_class_t *this;
- this = (dxr3_driver_class_t *)xine_xmalloc(sizeof(dxr3_driver_class_t));
+ this = calloc(1, sizeof(dxr3_driver_class_t));
if (!this) return NULL;
this->devnum = xine->config->register_num(xine->config,
@@ -223,7 +223,7 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v
if (class->instance) return NULL;
- this = (dxr3_driver_t *)xine_xmalloc(sizeof(dxr3_driver_t));
+ this = calloc(1, sizeof(dxr3_driver_t));
if (!this) return NULL;
this->vo_driver.get_capabilities = dxr3_get_capabilities;
@@ -514,7 +514,7 @@ static vo_frame_t *dxr3_alloc_frame(vo_driver_t *this_gen)
dxr3_frame_t *frame;
dxr3_driver_t *this = (dxr3_driver_t *)this_gen;
- frame = (dxr3_frame_t *)xine_xmalloc(sizeof(dxr3_frame_t));
+ frame = calloc(1, sizeof(dxr3_frame_t));
pthread_mutex_init(&frame->vo_frame.mutex, NULL);
@@ -1305,7 +1305,7 @@ static int lookup_parameter(struct lut_entry *lut, char *name,
static int dxr3_overlay_read_state(dxr3_overlay_t *this)
{
char *loc;
- char fname[256], tmp[128], line[256];
+ char *fname, line[256];
FILE *fp;
struct lut_entry lut[] = {
{"xoffset", TYPE_INT, &this->xoffset},
@@ -1330,18 +1330,16 @@ static int dxr3_overlay_read_state(dxr3_overlay_t *this)
* (used by .overlay/res file) */
setlocale(LC_NUMERIC, "C");
- snprintf(tmp, sizeof(tmp), "/res_%dx%dx%d",
+ asprintf(&fname, "%s/.overlay/res_%dx%dx%d", getenv("HOME"),
this->screen_xres, this->screen_yres, this->screen_depth);
- strncpy(fname, getenv("HOME"), sizeof(fname) - strlen(tmp) - sizeof("/.overlay"));
- fname[sizeof(fname) - strlen(tmp) - sizeof("/.overlay")] = '\0';
- strcat(fname, "/.overlay");
- strcat(fname, tmp);
llprintf(LOG_OVR, "attempting to open %s\n", fname);
if (!(fp = fopen(fname, "r"))) {
xprintf(this->xine, XINE_VERBOSITY_LOG,
_("video_out_dxr3: ERROR Reading overlay init file. Run autocal!\n"));
+ free(fname);
return -1;
}
+ free(fname);
while (!feof(fp)) {
if (!fgets(line, 256, fp))
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index cc873bb16..9cf0d934d 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -375,7 +375,7 @@ static cdrom_toc * init_cdrom_toc(void) {
cdrom_toc *toc;
- toc = (cdrom_toc *) xine_xmalloc(sizeof (cdrom_toc));
+ toc = calloc(1, sizeof (cdrom_toc));
toc->first_track = toc->last_track = toc->total_tracks = 0;
toc->toc_entries = NULL;
@@ -1406,7 +1406,6 @@ static int _cdda_cddb_handle_code(char *buf) {
* Try to load cached cddb infos
*/
static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
- char *cdir = NULL;
DIR *dir;
const char *const xdg_cache_home = xdgCacheHome(this->stream->xine->basedir_handle);
@@ -1414,9 +1413,9 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
if(this == NULL)
return 0;
- cdir = alloca(strlen(xdg_cache_home) + sizeof("/"PACKAGE"/cddb"));
- strcpy(cdir, xdg_cache_home);
- strcat(cdir, "/"PACKAGE"/cddb");
+ const size_t cdir_size = strlen(xdg_cache_home) + sizeof("/"PACKAGE"/cddb") + 10 + 1;
+ char *const cdir = alloca(cdir_size);
+ sprintf(cdir, "%s/" PACKAGE "/cddb", xdg_cache_home);
if((dir = opendir(cdir)) != NULL) {
struct dirent *pdir;
@@ -1428,9 +1427,8 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
if(!strcasecmp(pdir->d_name, discid)) {
FILE *fd;
- int size = strlen(cdir);
- snprintf(cdir + size, sizeof(cdir) - size, "/%s", discid);
+ snprintf(cdir + cdir_size, 10, "/%s", discid);
if((fd = fopen(cdir, "r")) == NULL) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"input_cdda: fopen(%s) failed: %s.\n", cdir, strerror(errno));
@@ -1508,14 +1506,9 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
int nyear;
y = strstr(buffer, "YEAR:");
- if(y) {
- if (sscanf(y+5, "%4d", &nyear) == 1) {
- char year[5];
-
- snprintf(year, 5, "%d", nyear);
- if (this->cddb.disc_year == NULL)
- this->cddb.disc_year = strdup(year);
- }
+ if (y && this->cddb.disc_year == NULL) {
+ if (sscanf(y+5, "%4d", &nyear) == 1)
+ asprintf(&this->cddb.disc_year, "%d", nyear);
}
}
}
@@ -1695,12 +1688,11 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
/* Send query command */
memset(&buffer, 0, sizeof(buffer));
- sprintf(buffer, "cddb query %08lx %d ", this->cddb.disc_id, this->cddb.num_tracks);
+ size_t size = sprintf(buffer, "cddb query %08lx %d ", this->cddb.disc_id, this->cddb.num_tracks);
for (i = 0; i < this->cddb.num_tracks; i++) {
- int size = strlen(buffer);
- snprintf(buffer + size, sizeof(buffer) - size, "%d ", this->cddb.track[i].start);
+ size += snprintf(buffer + size, sizeof(buffer) - size, "%d ", this->cddb.track[i].start);
}
- snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), "%d\n", this->cddb.disc_length);
+ snprintf(buffer + strlen(buffer), sizeof(buffer) - size, "%d\n", this->cddb.disc_length);
if ((err = _cdda_cddb_send_command(this, buffer)) <= 0) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"input_cdda: error while sending cddb query command.\n");
@@ -1787,7 +1779,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
while (strcmp(buffer, ".")) {
char buf[2048];
int tnum;
- int bufsize = strlen(buffercache);
+ size_t bufsize = strlen(buffercache);
memset(&buffer, 0, sizeof(buffer));
_cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1);
@@ -1855,14 +1847,9 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
int nyear;
y = strstr(buffer, "YEAR:");
- if (y) {
- if (sscanf(y+5, "%4d", &nyear) == 1) {
- char year[5];
-
- snprintf(year, 5, "%d", nyear);
- if (this->cddb.disc_year == NULL)
- this->cddb.disc_year = strdup(year);
- }
+ if (y && this->cddb.disc_year == NULL) {
+ if (sscanf(y+5, "%4d", &nyear) == 1)
+ asprintf(&this->cddb.disc_year, "%d", nyear);
}
}
}
@@ -2418,7 +2405,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) {
if(this->cddb.num_tracks) {
int t;
- this->cddb.track = (trackinfo_t *) xine_xcalloc(this->cddb.num_tracks, sizeof(trackinfo_t));
+ this->cddb.track = (trackinfo_t *) calloc(this->cddb.num_tracks, sizeof(trackinfo_t));
for(t = 0; t < this->cddb.num_tracks; t++) {
int length = (toc->toc_entries[t].first_frame_minute * CD_SECONDS_PER_MINUTE +
@@ -2479,7 +2466,6 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen,
cdda_input_class_t *this = (cdda_input_class_t *) this_gen;
cdda_input_plugin_t *ip = this->ip;
cdrom_toc *toc;
- char trackmrl[20];
int fd, i, err = -1;
int num_tracks;
@@ -2501,7 +2487,7 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen,
* device we are going to open; but it is possible that this function
* gets called, before a plugin instance has been created;
* let's create a dummy instance in such a condition */
- ip = (cdda_input_plugin_t *)xine_xmalloc(sizeof(cdda_input_plugin_t));
+ ip = calloc(1, sizeof(cdda_input_plugin_t));
ip->stream = NULL;
ip->fd = -1;
ip->net_fd = -1;
@@ -2545,10 +2531,8 @@ static char ** cdda_class_get_autoplay_list (input_class_t *this_gen,
num_tracks = toc->last_track - toc->first_track;
if (toc->ignore_last_track)
num_tracks--;
- for ( i = 0; i <= num_tracks; i++ ) {
- sprintf(trackmrl,"cdda:/%d",i+toc->first_track);
- this->autoplaylist[i] = strdup(trackmrl);
- }
+ for ( i = 0; i <= num_tracks; i++ )
+ asprintf(&this->autoplaylist[i],"cdda:/%d",i+toc->first_track);
*num_files = toc->last_track - toc->first_track + 1;
@@ -2602,7 +2586,7 @@ static input_plugin_t *cdda_class_get_instance (input_class_t *cls_gen, xine_str
} else
return NULL;
- this = (cdda_input_plugin_t *) xine_xmalloc (sizeof (cdda_input_plugin_t));
+ this = calloc(1, sizeof (cdda_input_plugin_t));
class->ip = this;
this->stream = stream;
@@ -2678,7 +2662,7 @@ static void *init_plugin (xine_t *xine, void *data) {
cdda_input_class_t *this;
config_values_t *config;
- this = (cdda_input_class_t *) xine_xmalloc (sizeof (cdda_input_class_t));
+ this = calloc(1, sizeof (cdda_input_class_t));
this->xine = xine;
this->config = xine->config;
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c
index 425f90fd9..d3a7a918d 100644
--- a/src/input/input_dvb.c
+++ b/src/input/input_dvb.c
@@ -67,7 +67,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
/* pthread.h must be included first so rest of the headers are imported
@@ -377,6 +377,7 @@ static const Param bw_list [] = {
{ "BANDWIDTH_6_MHZ", BANDWIDTH_6_MHZ },
{ "BANDWIDTH_7_MHZ", BANDWIDTH_7_MHZ },
{ "BANDWIDTH_8_MHZ", BANDWIDTH_8_MHZ },
+ { "BANDWIDTH_AUTO", BANDWIDTH_AUTO },
{ NULL, 0 }
};
@@ -399,6 +400,7 @@ static const Param guard_list [] = {
{"GUARD_INTERVAL_1_32", GUARD_INTERVAL_1_32},
{"GUARD_INTERVAL_1_4", GUARD_INTERVAL_1_4},
{"GUARD_INTERVAL_1_8", GUARD_INTERVAL_1_8},
+ {"GUARD_INTERVAL_AUTO", GUARD_INTERVAL_AUTO},
{ NULL, 0 }
};
@@ -407,6 +409,7 @@ static const Param hierarchy_list [] = {
{ "HIERARCHY_2", HIERARCHY_2 },
{ "HIERARCHY_4", HIERARCHY_4 },
{ "HIERARCHY_NONE", HIERARCHY_NONE },
+ { "HIERARCHY_AUTO", HIERARCHY_AUTO },
{ NULL, 0 }
};
@@ -425,12 +428,14 @@ static const Param qam_list [] = {
{ "QAM_256", QAM_256 },
{ "QAM_32", QAM_32 },
{ "QAM_64", QAM_64 },
+ { "QAM_AUTO", QAM_AUTO },
{ NULL, 0 }
};
static const Param transmissionmode_list [] = {
{ "TRANSMISSION_MODE_2K", TRANSMISSION_MODE_2K },
{ "TRANSMISSION_MODE_8K", TRANSMISSION_MODE_8K },
+ { "TRANSMISSION_MODE_AUTO", TRANSMISSION_MODE_AUTO },
{ NULL, 0 }
};
@@ -499,7 +504,7 @@ static time_t dvb_mjdtime (uint8_t *buf)
int i;
unsigned int year, month, day, hour, min, sec;
unsigned long int mjd;
- struct tm *tma = xine_xmalloc(sizeof(struct tm));
+ struct tm *tma = calloc(1, sizeof(struct tm));
time_t t;
_x_assert(tma != NULL);
@@ -558,7 +563,7 @@ static void tuner_dispose(tuner_t * this)
}
-static tuner_t *tuner_init(xine_t * xine, int adapter)
+static tuner_t *XINE_MALLOC tuner_init(xine_t * xine, int adapter)
{
tuner_t *this;
@@ -573,8 +578,7 @@ static tuner_t *tuner_init(xine_t * xine, int adapter)
xprintf(this->xine, XINE_VERBOSITY_DEBUG, "tuner_init adapter=%d\n", adapter);
this->fd_frontend = -1;
- for (x = 0; x < MAX_FILTERS; x++)
- this->fd_pidfilter[x] = 0;
+ memset(this->fd_pidfilter, 0, sizeof(this->fd_pidfilter));
this->xine = xine;
this->adapter_num = adapter;
@@ -877,7 +881,6 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
channel_t *channels = NULL;
int num_channels = 0;
int num_alloc = 0;
- int i;
struct stat st;
snprintf(filename, BUFSIZE, "%s/"PACKAGE"/channels.conf", xdgConfigHome(xine->basedir_handle));
@@ -902,8 +905,8 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
while ( fgets (str, BUFSIZE, f)) {
channel_t channel = {0};
- /* lose trailing spaces & control characters */
- i = strlen (str);
+ /* lose trailing spaces & control characters */
+ size_t i = strlen (str);
while (i && str[i - 1] <= ' ')
--i;
if (i == 0)
@@ -914,7 +917,7 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
continue;
if (num_channels >= num_alloc) {
- channel_t *new_channels = xine_xmalloc((num_alloc += 32) * sizeof (channel_t));
+ channel_t *new_channels = calloc((num_alloc += 32), sizeof (channel_t));
_x_assert(new_channels != NULL);
memcpy(new_channels, channels, num_channels * sizeof (channel_t));
free(channels);
@@ -925,8 +928,7 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
/* Initially there's no EPG data in the EPG structs. */
channels[num_channels].epg_count = 0;
- for (i = 0; i < MAX_EPG_ENTRIES_PER_CHANNEL; ++i)
- channels[num_channels].epg[i] = NULL;
+ memset(channels[num_channels].epg, 0, sizeof(channels[num_channels].epg));
num_channels++;
}
@@ -1221,7 +1223,7 @@ static void dvb_parse_si(dvb_input_plugin_t *this) {
struct pollfd pfd;
tuner_t *tuner = this->tuner;
- tmpbuffer = xine_xmalloc (8192);
+ tmpbuffer = calloc(1, 8192);
_x_assert(tmpbuffer != NULL);
@@ -1429,13 +1431,10 @@ static void load_epg_data(dvb_input_plugin_t *this)
already "found" in the stream. This information is used to initialize the
channel's EPG structs when the EPG information for the channel is seen in
the stream the first time. */
- seen_channels = xine_xmalloc(this->num_channels*sizeof(char));
+ seen_channels = calloc(this->num_channels, sizeof(char));
_x_assert(seen_channels != NULL);
- for (i = 0; i < this->num_channels; i++) {
- seen_channels[i] = 0;
- }
- foo = xine_xmalloc(8192);
+ foo = calloc(1, 8192);
_x_assert(foo != NULL);
fd.fd = this->tuner->fd_pidfilter[EITFILTER];
@@ -1485,19 +1484,19 @@ static void load_epg_data(dvb_input_plugin_t *this)
Allocate space for the strings. */
if (current_channel->epg[current_channel->epg_count] == NULL) {
current_channel->epg[current_channel->epg_count] =
- xine_xmalloc(sizeof(epg_entry_t));
+ calloc(1, sizeof(epg_entry_t));
_x_assert(current_channel->epg[current_channel->epg_count] != NULL);
current_channel->epg[current_channel->epg_count]->progname =
- xine_xmalloc((MAX_EPG_PROGRAM_NAME_LENGTH + 1) * sizeof(char));
+ malloc(MAX_EPG_PROGRAM_NAME_LENGTH + 1);
_x_assert(current_channel->epg[current_channel->epg_count]->progname != NULL);
current_channel->epg[current_channel->epg_count]->description =
- xine_xmalloc((MAX_EPG_PROGRAM_DESCRIPTION_LENGTH + 1) * sizeof(char));
+ malloc(MAX_EPG_PROGRAM_DESCRIPTION_LENGTH + 1);
_x_assert(current_channel->epg[current_channel->epg_count]->description != NULL);
current_channel->epg[current_channel->epg_count]->content =
- xine_xmalloc((MAX_EPG_CONTENT_TYPE_LENGTH + 1) * sizeof(char));
+ malloc(MAX_EPG_CONTENT_TYPE_LENGTH + 1);
_x_assert(current_channel->epg[current_channel->epg_count]->content != NULL);
current_channel->epg[current_channel->epg_count]->running = 0;
@@ -1657,7 +1656,7 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, char*
/* The line to be printed next. */
char text_line[512];
int text_width, text_height;
- int old_line_length, line_cursor;
+ size_t old_line_length, line_cursor;
char* bound, *old_bound;
*height = 0;
@@ -1817,7 +1816,7 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y,
if (epg_data == NULL || epg_data->progname == NULL)
return;
- buffer = xine_xmalloc(512);
+ buffer = calloc(1, 512);
_x_assert(buffer != NULL);
@@ -1834,8 +1833,7 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y,
/*Content type and rating, if any. */
if (strlen(epg_data->content) > 3) {
-
- snprintf(buffer, 94, "%s", epg_data->content);
+ strncpy(buffer, epg_data->content, 94-1);
prog_rating = epg_data->rating;
if (prog_rating > 0) {
@@ -1865,7 +1863,7 @@ static void show_program_info(int x, int y, int max_x, int max_y, int* last_y,
/* Print the description. */
if (epg_data->description && strlen(epg_data->description) > 0) {
renderer->set_font(osd, "sans", EPG_DESCRIPTION_FONT_SIZE);
- sprintf(buffer, "%s", epg_data->description);
+ strcpy(buffer, epg_data->description);
/* If the description is not complete (i.e., there is no comma at the end),
add "..." to the end. In my locale they often seem to send incomplete description
texts :( */
@@ -2199,7 +2197,7 @@ static void do_record (dvb_input_plugin_t *this) {
this->stream->osd_renderer->hide (this->paused_osd, 0);
this->record_paused=0;
} else {
- t=xine_xmalloc(sizeof(time_t));
+ t=calloc(1, sizeof(time_t));
_x_assert(t != NULL);
@@ -2761,7 +2759,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
xine_config_lookup_entry(this->stream->xine, "media.dvb.gui_enabled", &gui_enabled);
this->dvb_gui_enabled = gui_enabled.num_value;
xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("input_dvb: DVB GUI %s\n"), this->dvb_gui_enabled ? "enabled" : "disabled");
-
+
xine_config_lookup_entry(this->stream->xine, "media.dvb.adapter", &adapter);
if (!(tuner = tuner_init(this->class->xine,adapter.num_value))) {
@@ -2819,7 +2817,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
* that the channels have really ugly names, sometimes prefixed
* by numbers...
*/
- int chanlen = strlen(channame);
+ size_t chanlen = strlen(channame);
size_t offset = 0;
xprintf(this->class->xine, XINE_VERBOSITY_LOG,
@@ -2873,7 +2871,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
}
ptr = this->mrl;
ptr += 7;
- channels = xine_xmalloc(sizeof(channel_t));
+ channels = calloc(1, sizeof(channel_t));
_x_assert(channels != NULL);
if (extract_channel_from_string(channels, ptr, tuner->feinfo.type) < 0) {
free(channels);
@@ -2893,7 +2891,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
}
ptr = this->mrl;
ptr += 7;
- channels = xine_xmalloc(sizeof(channel_t));
+ channels = calloc(1, sizeof(channel_t));
_x_assert(channels != NULL);
if (extract_channel_from_string(channels, ptr, tuner->feinfo.type) < 0) {
free(channels);
@@ -2916,7 +2914,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
}
ptr = this->mrl;
ptr += 7;
- channels = xine_xmalloc(sizeof(channel_t));
+ channels = calloc(1, sizeof(channel_t));
_x_assert(channels != NULL);
if (extract_channel_from_string(channels, ptr, tuner->feinfo.type) < 0)
{
@@ -2942,7 +2940,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
}
ptr = this->mrl;
ptr += 7;
- channels = xine_xmalloc(sizeof(channel_t));
+ channels = calloc(1, sizeof(channel_t));
_x_assert(channels != NULL);
if (extract_channel_from_string(channels, ptr, tuner->feinfo.type) < 0)
{
@@ -3105,7 +3103,7 @@ static input_plugin_t *dvb_class_get_instance (input_class_t *class_gen,
fprintf(stderr, "input_dvb: continuing in get_instance\n");
- this = (dvb_input_plugin_t *) xine_xmalloc (sizeof(dvb_input_plugin_t));
+ this = calloc(1, sizeof(dvb_input_plugin_t));
_x_assert(this != NULL);
@@ -3213,21 +3211,19 @@ static char **dvb_class_get_autoplay_list(input_class_t * this_gen,
for (ch = 0, apch = !!lastchannel_enable.num_value;
ch < num_channels && ch < MAX_AUTOCHANNELS;
++ch, ++apch) {
- snprintf(foobuffer, BUFSIZE, "dvb://%s", channels[ch].name);
- free(class->autoplaylist[apch]);
- class->autoplaylist[apch] = strdup(foobuffer);
- _x_assert(class->autoplaylist[apch] != NULL);
+ free(class->autoplaylist[apch]);
+ asprintf(&(class->autoplaylist[apch]), "dvb://%s", channels[ch].name);
+ _x_assert(class->autoplaylist[apch] != NULL);
}
if (lastchannel_enable.num_value){
+ free(class->autoplaylist[0]);
if (default_channel != -1)
/* plugin has been used before - channel is valid */
- sprintf (foobuffer, "dvb://%s", channels[default_channel].name);
+ asprintf (&(class->autoplaylist[0]), "dvb://%s", channels[default_channel].name);
else
/* set a reasonable default - the first channel */
- sprintf (foobuffer, "dvb://%s", num_channels ? channels[0].name : "0");
- free(class->autoplaylist[0]);
- class->autoplaylist[0]=strdup(foobuffer);
+ asprintf (&(class->autoplaylist[0]), "dvb://%s", num_channels ? channels[0].name : "0");
}
free_channel_list(channels, num_channels);
@@ -3243,7 +3239,7 @@ static void *init_class (xine_t *xine, void *data) {
dvb_input_class_t *this;
config_values_t *config = xine->config;
- this = (dvb_input_class_t *) xine_xmalloc (sizeof (dvb_input_class_t));
+ this = calloc(1, sizeof (dvb_input_class_t));
_x_assert(this != NULL);
this->xine = xine;
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index 02017956e..58e7dbb8b 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -351,9 +351,14 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction
}
static int update_title_display(dvd_input_plugin_t *this) {
- char ui_title[MAX_STR_LEN + 1];
+ xine_ui_data_t data;
+ xine_event_t uevent = {
+ .type = XINE_EVENT_UI_SET_TITLE,
+ .stream = this->stream,
+ .data = &data,
+ .data_length = sizeof(data)
+ };
int tt=-1, pr=-1;
- size_t ui_str_length=0;
int num_tt = 0;
if(!this || !(this->stream))
@@ -383,15 +388,15 @@ static int update_title_display(dvd_input_plugin_t *this) {
dvdnav_get_number_of_parts(this->dvdnav, tt, &num_part);
dvdnav_get_angle_info(this->dvdnav, &cur_angle, &num_angle);
if(num_angle > 1) {
- snprintf(ui_title, MAX_STR_LEN,
- "Title %i, Chapter %i, Angle %i of %i",
- tt,pr,cur_angle, num_angle);
+ data.str_len = snprintf(data.str, sizeof(data.str),
+ "Title %i, Chapter %i, Angle %i of %i",
+ tt,pr,cur_angle, num_angle);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,cur_angle);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,num_angle);
} else {
- snprintf(ui_title, MAX_STR_LEN,
- "Title %i, Chapter %i",
- tt,pr);
+ data.str_len = snprintf(data.str, sizeof(data.str),
+ "Title %i, Chapter %i",
+ tt,pr);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0);
}
@@ -400,9 +405,9 @@ static int update_title_display(dvd_input_plugin_t *this) {
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,pr);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_COUNT,num_part);
} else if (tt == 0 && dvdnav_menu_table[pr]) {
- snprintf(ui_title, MAX_STR_LEN,
- "DVD %s Menu",
- dvdnav_menu_table[pr]);
+ data.str_len = snprintf(data.str, sizeof(data.str),
+ "DVD %s Menu",
+ dvdnav_menu_table[pr]);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_NUMBER,tt);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_COUNT,num_tt);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,0);
@@ -410,7 +415,8 @@ static int update_title_display(dvd_input_plugin_t *this) {
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0);
} else {
- strcpy(ui_title, "DVD Menu");
+ strcpy(data.str, "DVD Menu");
+ data.str_len = strlen(data.str);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_COUNT,num_tt);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,0);
@@ -418,29 +424,16 @@ static int update_title_display(dvd_input_plugin_t *this) {
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0);
}
- ui_str_length = strlen(ui_title);
if (this->dvd_name && this->dvd_name[0] &&
- (ui_str_length + strlen(this->dvd_name) < MAX_STR_LEN)) {
- snprintf(ui_title+ui_str_length, MAX_STR_LEN - ui_str_length,
- ", %s", this->dvd_name);
+ (data.str_len + strlen(this->dvd_name) < sizeof(data.str))) {
+ data.str_len += snprintf(data.str+data.str_len, sizeof(data.str) - data.str_len,
+ ", %s", this->dvd_name);
}
#ifdef INPUT_DEBUG
- printf("input_dvd: Changing title to read '%s'\n", ui_title);
+ printf("input_dvd: Changing title to read '%s'\n", data.str);
#endif
- {
- xine_ui_data_t data;
- xine_event_t uevent;
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);
-
- memcpy(data.str, ui_title, strlen(ui_title) + 1);
- data.str_len = strlen(ui_title) + 1;
-
- xine_event_send(this->stream, &uevent);
- }
+ xine_event_send(this->stream, &uevent);
return 1;
}
@@ -1318,7 +1311,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen,
if(this && this->stream && this->dvdnav) {
if(!(dvdnav_is_domain_vts(this->dvdnav))) {
- sprintf(data, "%s", "menu");
+ strcpy(data, "menu");
if (channel <= 0)
return INPUT_OPTIONAL_SUCCESS;
else
@@ -1341,7 +1334,7 @@ static int dvd_plugin_get_optional_data (input_plugin_t *this_gen,
return INPUT_OPTIONAL_SUCCESS;
} else {
if(channel == -1) {
- sprintf(data, "%s", "none");
+ strcpy(data, "none");
return INPUT_OPTIONAL_SUCCESS;
}
}
@@ -1629,14 +1622,14 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st
if (strncasecmp (data, handled_mrl, sizeof(handled_mrl)-1 ) != 0)
return NULL;
- this = (dvd_input_plugin_t *) xine_xmalloc (sizeof (dvd_input_plugin_t));
+ this = calloc(1, sizeof (dvd_input_plugin_t));
if (!this) {
return NULL;
}
this->mem_stack = 0;
this->mem_stack_max = 1024;
- this->mem = xine_xcalloc(this->mem_stack_max, sizeof(unsigned char *));
+ this->mem = calloc(this->mem_stack_max, sizeof(unsigned char *));
if (!this->mem) {
free(this);
return NULL;
@@ -1750,7 +1743,7 @@ static void *init_class (xine_t *xine, void *data) {
printf("input_dvd.c: config = %p\n", config);
#endif
- this = (dvd_input_class_t *) xine_xmalloc (sizeof (dvd_input_class_t));
+ this = (dvd_input_class_t *) calloc(1, sizeof (dvd_input_class_t));
if (!this)
return NULL;
diff --git a/src/input/input_file.c b/src/input/input_file.c
index 2fe3925ea..31c682ad7 100644
--- a/src/input/input_file.c
+++ b/src/input/input_file.c
@@ -420,7 +420,7 @@ static input_plugin_t *file_class_get_instance (input_class_t *cls_gen, xine_str
return NULL;
}
- this = (file_input_plugin_t *) xine_xmalloc (sizeof (file_input_plugin_t));
+ this = (file_input_plugin_t *) calloc(1, sizeof (file_input_plugin_t));
this->stream = stream;
this->mrl = mrl;
this->fh = -1;
@@ -680,9 +680,9 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
return NULL;
}
- dir_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
- hide_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
- norm_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
+ dir_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t));
+ hide_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t));
+ norm_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t));
while((pdirent = readdir(pdir)) != NULL) {
@@ -699,11 +699,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
}
else {
- dir_files[num_dir_files].mrl = (char *)
- xine_xmalloc(strlen(current_dir_slashed) + 1 + strlen(pdirent->d_name) + 1);
-
dir_files[num_dir_files].origin = strdup(current_dir);
- sprintf(dir_files[num_dir_files].mrl, "%s%s",
+ asprintf(&(dir_files[num_dir_files].mrl), "%s%s",
current_dir_slashed, pdirent->d_name);
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = get_file_type(fullfilename, current_dir, this->xine);
@@ -721,8 +718,9 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
xprintf (this->xine, XINE_VERBOSITY_DEBUG,
"input_file: readlink() failed: %s\n", strerror(errno));
else {
- dir_files[num_dir_files].link = (char *) xine_xmalloc(linksize + 1);
- strncpy(dir_files[num_dir_files].link, linkbuf, linksize);
+ dir_files[num_dir_files].link =
+ strndup(linkbuf, linksize);
+
dir_files[num_dir_files].type |= get_file_type(dir_files[num_dir_files].link, current_dir, this->xine);
}
}
@@ -737,11 +735,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
/* if user don't want to see hidden files, ignore them */
if(this->show_hidden_files) {
- hide_files[num_hide_files].mrl = (char *)
- xine_xmalloc(strlen(current_dir_slashed) + 1 + strlen(pdirent->d_name) + 1);
-
hide_files[num_hide_files].origin = strdup(current_dir);
- sprintf(hide_files[num_hide_files].mrl, "%s%s",
+ asprintf(&(hide_files[num_hide_files].mrl), "%s%s",
current_dir_slashed, pdirent->d_name);
hide_files[num_hide_files].link = NULL;
hide_files[num_hide_files].type = get_file_type(fullfilename, current_dir, this->xine);
@@ -760,9 +755,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
"input_file: readlink() failed: %s\n", strerror(errno));
}
else {
- hide_files[num_hide_files].link = (char *)
- xine_xmalloc(linksize + 1);
- strncpy(hide_files[num_hide_files].link, linkbuf, linksize);
+ hide_files[num_hide_files].link =
+ strndup(linkbuf, linksize);
hide_files[num_hide_files].type |= get_file_type(hide_files[num_hide_files].link, current_dir, this->xine);
}
}
@@ -773,11 +767,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
} /* So a *normal* one. */
else {
- norm_files[num_norm_files].mrl = (char *)
- xine_xmalloc(strlen(current_dir_slashed) + 1 + strlen(pdirent->d_name) + 1);
-
norm_files[num_norm_files].origin = strdup(current_dir);
- sprintf(norm_files[num_norm_files].mrl, "%s%s",
+ asprintf(&(norm_files[num_norm_files].mrl), "%s%s",
current_dir_slashed, pdirent->d_name);
norm_files[num_norm_files].link = NULL;
norm_files[num_norm_files].type = get_file_type(fullfilename, current_dir, this->xine);
@@ -796,9 +787,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
"input_file: readlink() failed: %s\n", strerror(errno));
}
else {
- norm_files[num_norm_files].link = (char *)
- xine_xmalloc(linksize + 1);
- strncpy(norm_files[num_norm_files].link, linkbuf, linksize);
+ norm_files[num_norm_files].link =
+ strndup(linkbuf, linksize);
norm_files[num_norm_files].type |= get_file_type(norm_files[num_norm_files].link, current_dir, this->xine);
}
}
@@ -840,7 +830,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
if(num_files >= this->mrls_allocated_entries) {
++this->mrls_allocated_entries;
this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*));
- this->mrls[num_files] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t));
+ this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t));
}
else
memset(this->mrls[num_files], 0, sizeof(xine_mrl_t));
@@ -858,7 +848,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
if(num_files >= this->mrls_allocated_entries) {
++this->mrls_allocated_entries;
this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*));
- this->mrls[num_files] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t));
+ this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t));
}
else
memset(this->mrls[num_files], 0, sizeof(xine_mrl_t));
@@ -876,7 +866,7 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
if(num_files >= this->mrls_allocated_entries) {
++this->mrls_allocated_entries;
this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*));
- this->mrls[num_files] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t));
+ this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t));
}
else
memset(this->mrls[num_files], 0, sizeof(xine_mrl_t));
@@ -956,7 +946,7 @@ static void *init_plugin (xine_t *xine, void *data) {
file_input_class_t *this;
config_values_t *config;
- this = (file_input_class_t *) xine_xmalloc (sizeof (file_input_class_t));
+ this = (file_input_class_t *) calloc(1, sizeof (file_input_class_t));
this->xine = xine;
this->config = xine->config;
@@ -970,7 +960,7 @@ static void *init_plugin (xine_t *xine, void *data) {
this->input_class.dispose = file_class_dispose;
this->input_class.eject_media = NULL;
- this->mrls = (xine_mrl_t **) xine_xmalloc(sizeof(xine_mrl_t*));
+ this->mrls = (xine_mrl_t **) calloc(1, sizeof(xine_mrl_t*));
this->mrls_allocated_entries = 0;
{
diff --git a/src/input/input_http.c b/src/input/input_http.c
index a5a25f0af..242bea8d0 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -83,6 +83,8 @@ typedef struct {
char preview[MAX_PREVIEW_SIZE];
off_t preview_size;
+ char *mime_type;
+
char *proto;
char *user;
char *password;
@@ -556,17 +558,20 @@ static const char* http_plugin_get_mrl (input_plugin_t *this_gen) {
}
static int http_plugin_get_optional_data (input_plugin_t *this_gen,
- void *data, int data_type) {
+ void *const data, int data_type) {
+ void **const ptr = (void **const) data;
http_input_plugin_t *this = (http_input_plugin_t *) this_gen;
switch (data_type) {
case INPUT_OPTIONAL_DATA_PREVIEW:
-
memcpy (data, this->preview, this->preview_size);
return this->preview_size;
- break;
+ case INPUT_OPTIONAL_DATA_MIME_TYPE:
+ *ptr = this->mime_type;
+ case INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE:
+ return *this->mime_type ? INPUT_OPTIONAL_SUCCESS : INPUT_OPTIONAL_UNSUPPORTED;
}
return INPUT_OPTIONAL_UNSUPPORTED;
@@ -615,11 +620,13 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
int done, len, linenum;
int httpcode;
int res;
- int buflen;
+ size_t buflen;
int use_proxy;
int proxyport;
int mpegurl_redirect = 0;
-
+ char mime_type[256];
+
+ mime_type[0] = 0;
use_proxy = this_class->proxyhost && strlen(this_class->proxyhost);
if (!_x_parse_url(this->mrl, &this->proto, &this->host, &this->port,
@@ -661,9 +668,8 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
this->curpos = 0;
- if (this->fh == -1) {
+ if (this->fh == -1)
return -2;
- }
{
uint32_t timeout, progress;
@@ -887,7 +893,11 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
/* content type */
if (!strncasecmp(this->buf, TAG_CONTENT_TYPE, sizeof(TAG_CONTENT_TYPE) - 1)) {
- if (!strncasecmp(this->buf + sizeof(TAG_CONTENT_TYPE) - 1, "video/nsv", 9)) {
+ const char *type = this->buf + sizeof (TAG_CONTENT_TYPE) - 1;
+ while (isspace (*type))
+ ++type;
+ sprintf (mime_type, "%.255s", type);
+ if (!strncasecmp (type, "video/nsv", 9)) {
lprintf("shoutcast nsv detected\n");
this->is_nsv = 1;
}
@@ -962,6 +972,8 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
lprintf("preview_size=%"PRId64"\n", this->preview_size);
this->curpos = 0;
+ if (*mime_type)
+ this->mime_type = strdup (mime_type);
return 1;
}
@@ -979,11 +991,10 @@ static input_plugin_t *http_class_get_instance (input_class_t *cls_gen, xine_str
strncasecmp (mrl, "peercast://pls/", 15)) {
return NULL;
}
- this = (http_input_plugin_t *) xine_xmalloc(sizeof(http_input_plugin_t));
+ this = calloc(1, sizeof(http_input_plugin_t));
if (!strncasecmp (mrl, "peercast://pls/", 15)) {
- this->mrl = xine_xmalloc (30 + strlen(mrl) - 15);
- sprintf (this->mrl, "http://127.0.0.1:7144/stream/%s", mrl+15);
+ asprintf (&this->mrl, "http://127.0.0.1:7144/stream/%s", mrl+15);
} else {
this->mrl = strdup (mrl);
}
@@ -1021,7 +1032,7 @@ static void *init_class (xine_t *xine, void *data) {
config_values_t *config;
char *proxy_env;
- this = (http_input_class_t *) xine_xmalloc (sizeof (http_input_class_t));
+ this = calloc(1, sizeof (http_input_class_t));
this->xine = xine;
this->config = xine->config;
@@ -1038,25 +1049,21 @@ static void *init_class (xine_t *xine, void *data) {
/*
* honour http_proxy envvar
*/
- if((proxy_env = getenv("http_proxy")) && (strlen(proxy_env))) {
+ if((proxy_env = getenv("http_proxy")) && *proxy_env) {
int proxy_port = DEFAULT_HTTP_PORT;
- char *http_proxy = xine_xmalloc(strlen(proxy_env) + 1);
char *p;
if(!strncmp(proxy_env, "http://", 7))
proxy_env += 7;
+
+ this->proxyhost_env = strdup(proxy_env);
- sprintf(http_proxy, "%s", proxy_env);
-
- if((p = strrchr(&http_proxy[0], ':')) && (strlen(p) > 1)) {
+ if((p = strrchr(this->proxyhost_env, ':')) && (strlen(p) > 1)) {
*p++ = '\0';
proxy_port = (int) strtol(p, &p, 10);
}
- this->proxyhost_env = strdup(http_proxy);
this->proxyport_env = proxy_port;
-
- free(http_proxy);
}
else
proxy_env = NULL; /* proxy_env can be "" */
diff --git a/src/input/input_mms.c b/src/input/input_mms.c
index 0287e0060..136307c80 100644
--- a/src/input/input_mms.c
+++ b/src/input/input_mms.c
@@ -400,7 +400,7 @@ static input_plugin_t *mms_class_get_instance (input_class_t *cls_gen, xine_stre
return NULL;
}
- this = (mms_input_plugin_t *) xine_xmalloc (sizeof (mms_input_plugin_t));
+ this = calloc(1, sizeof (mms_input_plugin_t));
cls->ip = this;
this->stream = stream;
this->mms = NULL;
@@ -450,7 +450,7 @@ static void *init_class (xine_t *xine, void *data) {
mms_input_class_t *this;
- this = (mms_input_class_t *) xine_xmalloc (sizeof (mms_input_class_t));
+ this = calloc(1, sizeof (mms_input_class_t));
this->xine = xine;
this->ip = NULL;
diff --git a/src/input/input_net.c b/src/input/input_net.c
index 8a4874203..4b74d705d 100644
--- a/src/input/input_net.c
+++ b/src/input/input_net.c
@@ -481,7 +481,7 @@ static input_plugin_t *net_class_get_instance (input_class_t *cls_gen, xine_stre
return NULL;
}
- this = xine_xmalloc(sizeof(net_input_plugin_t));
+ this = calloc(1, sizeof(net_input_plugin_t));
this->mrl = strdup(mrl);
this->host_port = strdup(filename);
this->stream = stream;
@@ -515,7 +515,7 @@ static void *init_class (xine_t *xine, void *data) {
net_input_class_t *this;
- this = (net_input_class_t *) xine_xmalloc(sizeof(net_input_class_t));
+ this = calloc(1, sizeof(net_input_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c
index e11e3b361..66d8a9196 100644
--- a/src/input/input_pnm.c
+++ b/src/input/input_pnm.c
@@ -230,7 +230,7 @@ static input_plugin_t *pnm_class_get_instance (input_class_t *cls_gen, xine_stre
return NULL;
}
- this = (pnm_input_plugin_t *) xine_xmalloc (sizeof (pnm_input_plugin_t));
+ this = calloc(1, sizeof (pnm_input_plugin_t));
this->stream = stream;
this->pnm = NULL;
@@ -261,7 +261,7 @@ static void *init_class (xine_t *xine, void *data) {
pnm_input_class_t *this;
- this = (pnm_input_class_t *) xine_xmalloc (sizeof (pnm_input_class_t));
+ this = calloc(1, sizeof (pnm_input_class_t));
this->xine = xine;
diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c
index 740d51665..17c251c40 100644
--- a/src/input/input_pvr.c
+++ b/src/input/input_pvr.c
@@ -376,10 +376,10 @@ static void pvrscr_exit (scr_plugin_t *scr) {
free(this);
}
-static pvrscr_t* pvrscr_init (void) {
+static pvrscr_t *XINE_MALLOC pvrscr_init (void) {
pvrscr_t *this;
- this = (pvrscr_t *) xine_xmalloc(sizeof(pvrscr_t));
+ this = calloc(1, sizeof(pvrscr_t));
this->scr.interface_version = 3;
this->scr.get_priority = pvrscr_get_priority;
@@ -505,10 +505,8 @@ static void pvr_adjust_realtime_speed(pvr_input_plugin_t *this, fifo_buffer_t *f
}
#define PVR_FILENAME "%s%08d_%08d.vob"
-#define PVR_FILENAME_SIZE 1+8+1+8+4+1
static char *make_temp_name(pvr_input_plugin_t *this, int page) {
-
char *filename;
asprintf(&filename, PVR_FILENAME, this->tmp_prefix, this->session, page);
@@ -517,10 +515,8 @@ static char *make_temp_name(pvr_input_plugin_t *this, int page) {
}
#define SAVE_BASE_FILENAME "ch%03d %02d-%02d-%04d %02d:%02d:%02d"
-#define SAVE_BASE_FILENAME_SIZE 2+3+1+2+1+2+1+4+1+2+1+2+1+2+1
static char *make_base_save_name(int channel, time_t tm) {
-
struct tm rec_time;
char *filename;
@@ -534,10 +530,8 @@ static char *make_base_save_name(int channel, time_t tm) {
}
#define SAVE_FILENAME "%s%s_%04d.vob"
-#define SAVE_FILENAME_SIZE 1+4+4+1
static char *make_save_name(pvr_input_plugin_t *this, char *base, int page) {
-
char *filename;
asprintf(&filename, SAVE_FILENAME, this->save_prefix, base, page);
@@ -1472,7 +1466,7 @@ static input_plugin_t *pvr_class_get_instance (input_class_t *cls_gen, xine_stre
mrl = strdup(data);
aux = &mrl[5];
- this = (pvr_input_plugin_t *) xine_xmalloc (sizeof (pvr_input_plugin_t));
+ this = calloc(1, sizeof (pvr_input_plugin_t));
this->class = cls;
this->stream = stream;
this->dev_fd = -1;
@@ -1540,7 +1534,7 @@ static void *init_plugin (xine_t *xine, void *data) {
pvr_input_class_t *this;
- this = (pvr_input_class_t *) xine_xmalloc (sizeof (pvr_input_class_t));
+ this = calloc(1, sizeof (pvr_input_class_t));
this->xine = xine;
this->config = xine->config;
diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c
index 33183e555..2c9de54d4 100644
--- a/src/input/input_rtp.c
+++ b/src/input/input_rtp.c
@@ -718,7 +718,7 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen,
}
}
- this = (rtp_input_plugin_t *) xine_xmalloc(sizeof(rtp_input_plugin_t));
+ this = calloc(1, sizeof(rtp_input_plugin_t));
this->stream = stream;
this->mrl = mrl;
this->filename = filename;
@@ -770,7 +770,7 @@ static void *init_class (xine_t *xine, void *data) {
rtp_input_class_t *this;
- this = (rtp_input_class_t *) xine_xmalloc(sizeof(rtp_input_class_t));
+ this = calloc(1, sizeof(rtp_input_class_t));
this->config = xine->config;
this->xine = xine;
diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c
index e2b1bae99..3fbd7631f 100644
--- a/src/input/input_rtsp.c
+++ b/src/input/input_rtsp.c
@@ -244,7 +244,7 @@ static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_str
if (strncasecmp (mrl, "rtsp://", 6))
return NULL;
- this = (rtsp_input_plugin_t *) xine_xmalloc (sizeof (rtsp_input_plugin_t));
+ this = calloc(1, sizeof (rtsp_input_plugin_t));
this->stream = stream;
this->rtsp = NULL;
@@ -252,8 +252,7 @@ static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_str
/* since we handle only real streams yet, we can savely add
* an .rm extention to force handling by demux_real.
*/
- this->public_mrl = xine_xmalloc (sizeof (char)*(strlen(this->mrl)+10));
- sprintf(this->public_mrl, "%s.rm", this->mrl);
+ asprintf(&this->public_mrl, "%s.rm", this->mrl);
this->nbc = nbc_init (stream);
@@ -281,7 +280,7 @@ static void *init_class (xine_t *xine, void *data) {
rtsp_input_class_t *this;
- this = (rtsp_input_class_t *) xine_xmalloc (sizeof (rtsp_input_class_t));
+ this = calloc(1, sizeof (rtsp_input_class_t));
this->xine = xine;
diff --git a/src/input/input_smb.c b/src/input/input_smb.c
index 44fa96bfd..2c7fb3bc9 100644
--- a/src/input/input_smb.c
+++ b/src/input/input_smb.c
@@ -245,8 +245,8 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
}
if ((dir = smbc_opendir(current_path_smb)) >= 0){
- xine_mrl_t *dir_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
- xine_mrl_t *norm_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
+ xine_mrl_t *dir_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t));
+ xine_mrl_t *norm_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t));
int num_dir_files=0;
int num_norm_files=0;
while ((pdirent = smbc_readdir(dir)) != NULL){
@@ -254,9 +254,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].origin = strdup(current_path);
- dir_files[num_dir_files].mrl = (char *) xine_xmalloc(
- strlen(current_path) + 1 + strlen(pdirent->name) + 1);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, pdirent->name);
+ asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name);
dir_files[num_dir_files].size = pdirent->dirlen;
num_dir_files ++;
}else if (pdirent->smbc_type == SMBC_SERVER){
@@ -264,17 +262,14 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].origin = strdup("smb:/");
- dir_files[num_dir_files].mrl = (char *) xine_xmalloc(strlen("smb:/") + 4);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", "smb:/", "..");
+ asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", "smb:/", "..");
dir_files[num_dir_files].size = pdirent->dirlen;
num_dir_files ++;
}
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].origin = strdup("smb:/");
- dir_files[num_dir_files].mrl =
- (char *) xine_xmalloc(strlen("smb:/") + 1 + strlen(pdirent->name) + 1);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", "smb:/", pdirent->name);
+ asprintf(*(dir_files[num_dir_files].mrl), "%s/%s", "smb:/", pdirent->name);
dir_files[num_dir_files].size = pdirent->dirlen;
num_dir_files ++;
} else if (pdirent->smbc_type == SMBC_FILE_SHARE){
@@ -282,9 +277,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].origin = strdup(current_path);
- dir_files[num_dir_files].mrl = (char *) xine_xmalloc(
- strlen(current_path) + 3);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, "..");
+ asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, "..");
dir_files[num_dir_files].type |= mrl_file_directory;
dir_files[num_dir_files].size = pdirent->dirlen;
num_dir_files ++;
@@ -293,9 +286,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].origin = strdup(current_path);
- dir_files[num_dir_files].mrl = (char *) xine_xmalloc(
- strlen(current_path) + 1 + strlen(pdirent->name) + 1);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, pdirent->name);
+ asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name);
dir_files[num_dir_files].size = pdirent->dirlen;
num_dir_files ++;
}
@@ -303,18 +294,14 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].origin = strdup(current_path);
- dir_files[num_dir_files].mrl =
- (char *) xine_xmalloc(strlen(current_path) + 1 + strlen(pdirent->name) + 1);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, pdirent->name);
+ asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name);
dir_files[num_dir_files].size = pdirent->dirlen;
num_dir_files ++;
}else if (pdirent->smbc_type == SMBC_FILE){
norm_files[num_norm_files].link = NULL;
norm_files[num_norm_files].type = mrl_file | mrl_file_normal;
norm_files[num_norm_files].origin = strdup(current_path);
- norm_files[num_norm_files].mrl =
- (char *) xine_xmalloc(strlen(current_path) + 1 + strlen(pdirent->name) + 1);
- sprintf(norm_files[num_norm_files].mrl, "%s/%s", current_path, pdirent->name);
+ asprintf(&(norm_files[num_norm_files].mrl), "%s/%s", current_path, pdirent->name);
norm_files[num_norm_files].size = pdirent->dirlen;
num_norm_files ++;
}
@@ -324,8 +311,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
if (num_dir_files == 0) {
dir_files[num_dir_files].link = NULL;
dir_files[num_dir_files].origin = strdup(current_path);
- dir_files[num_dir_files].mrl = (char *) xine_xmalloc(strlen(current_path) + 4);
- sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, "..");
+ asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, "..");
dir_files[num_dir_files].type = mrl_file | mrl_file_directory;
dir_files[num_dir_files].size = 0;
num_dir_files ++;
@@ -348,7 +334,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
++this->mrls_allocated_entries;
this->mrls = realloc(this->mrls,
(this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*));
- this->mrls[num_files] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t));
+ this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t));
}else
memset(this->mrls[num_files], 0, sizeof(xine_mrl_t));
@@ -365,7 +351,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
++this->mrls_allocated_entries;
this->mrls = realloc(this->mrls,
(this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*));
- this->mrls[num_files] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t));
+ this->mrls[num_files] = calloc(1, sizeof(xine_mrl_t));
}else
memset(this->mrls[num_files], 0, sizeof(xine_mrl_t));
@@ -456,7 +442,7 @@ smb_class_get_instance (input_class_t *class_gen, xine_stream_t *stream,
if (strncmp (mrl, "smb://",6))
return NULL;
- this = (smb_input_t *)xine_xmalloc(sizeof(smb_input_t));
+ this = calloc(1, sizeof(smb_input_t));
this->stream = stream;
this->mrl = strdup (mrl);
this->fd = -1;
@@ -495,7 +481,7 @@ static void
if (smbc_init(smb_auth,(xine->verbosity >= XINE_VERBOSITY_DEBUG)))
goto _exit_error;
- this = (smb_input_class_t *) xine_xmalloc(sizeof(smb_input_class_t));
+ this = calloc(1, sizeof(smb_input_class_t));
this->xine = xine;
this->input_class.get_instance = smb_class_get_instance;
diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c
index d67954ea8..648f17438 100644
--- a/src/input/input_stdin_fifo.c
+++ b/src/input/input_stdin_fifo.c
@@ -312,7 +312,7 @@ static input_plugin_t *stdin_class_get_instance (input_class_t *class_gen,
* => create plugin instance
*/
- this = (stdin_input_plugin_t *) xine_xmalloc(sizeof(stdin_input_plugin_t));
+ this = calloc(1, sizeof(stdin_input_plugin_t));
this->stream = stream;
this->curpos = 0;
@@ -348,7 +348,7 @@ static void *init_class (xine_t *xine, void *data) {
stdin_input_class_t *this;
- this = (stdin_input_class_t *) xine_xmalloc (sizeof (stdin_input_class_t));
+ this = calloc(1, sizeof (stdin_input_class_t));
this->xine = xine;
diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c
index df0e0e48b..302b96b57 100644
--- a/src/input/input_v4l.c
+++ b/src/input/input_v4l.c
@@ -110,9 +110,6 @@ static const resolution_t resolutions[] = {
{ 160, 120 }
};
-static const char *const tv_standard_names[] = { "PAL", "NTSC", "SECAM", NULL };
-static const int tv_standard_values[] = { VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM };
-
#define NUM_RESOLUTIONS (sizeof(resolutions)/sizeof(resolutions[0]))
#define RADIO_DEV "/dev/radio0"
#define VIDEO_DEV "/dev/video0"
@@ -120,6 +117,9 @@ static const int tv_standard_values[] = { VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO
#define AUDIO_DEV "plughw:0,0"
#endif
+static const char *const tv_standard_names[] = { "AUTO", "PAL", "NTSC", "SECAM", "OLD", NULL };
+static const int tv_standard_values[] = { VIDEO_MODE_AUTO, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM, -1 };
+
#if !defined(NDELAY) && defined(O_NDELAY)
#define FNDELAY O_NDELAY
#endif
@@ -143,6 +143,10 @@ typedef struct {
int old_zoomx;
int old_zoomy;
int audio_only;
+
+ buf_element_t *frames_base;
+ void *audio_content_base;
+ void *video_content_base;
/* Audio */
buf_element_t *aud_frames;
@@ -368,11 +372,11 @@ static void pvrscr_exit (scr_plugin_t *scr)
free(this);
}
-static pvrscr_t* pvrscr_init (void)
+static pvrscr_t *XINE_MALLOC pvrscr_init (void)
{
pvrscr_t *this;
- this = (pvrscr_t *) xine_xmalloc(sizeof(pvrscr_t));
+ this = calloc(1, sizeof(pvrscr_t));
this->scr.interface_version = 3;
this->scr.get_priority = pvrscr_get_priority;
@@ -690,11 +694,14 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source)
tv_standard_entry = this->stream->xine->config->lookup_entry(this->stream->xine->config,
"media.video4linux.tv_standard");
this->tuner_name = input_source;
- this->video_channel.norm = tv_standard_values[ tv_standard_entry->num_value ];
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- "input_v4l: TV Standard configured as STD %s (%d)\n",
- tv_standard_names[ tv_standard_entry->num_value ], this->video_channel.norm );
- ret = ioctl(fd, VIDIOCSCHAN, &this->video_channel);
+ if (tv_standard_entry->num_value != 0) {
+ this->video_channel.norm = tv_standard_values[ tv_standard_entry->num_value ];
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ "input_v4l: TV Standard configured as STD %s (%d)\n",
+ tv_standard_names[ tv_standard_entry->num_value ], this->video_channel.norm );
+ ret = ioctl(fd, VIDIOCSCHAN, &this->video_channel);
+ } else
+ ret = ioctl(fd, VIDIOCSCHAN, &this->input);
lprintf("(%d) Set channel to %d\n", ret, this->input);
@@ -742,23 +749,50 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source)
return 1;
}
-static void allocate_audio_frames(v4l_input_plugin_t *this)
+static void allocate_frames(v4l_input_plugin_t *this, unsigned dovideo)
{
+ const size_t framescount = dovideo ? 2*NUM_FRAMES : NUM_FRAMES;
+
+ /* Allocate a single memory area for both audio and video frames */
+ buf_element_t *frames = this->frames_base =
+ calloc(framescount, sizeof(buf_element_t));
+ extra_info_t *infos =
+ calloc(framescount, sizeof(extra_info_t));
+
int i;
-
+
+ uint8_t *audio_content = this->audio_content_base =
+ calloc(NUM_FRAMES, this->periodsize);
+
+ /* Set up audio frames */
for (i = 0; i < NUM_FRAMES; i++) {
- buf_element_t *frame;
-
/* Audio frame */
- frame = xine_xmalloc(sizeof(buf_element_t));
-
- frame->content = xine_xmalloc(this->periodsize);
- frame->type = BUF_AUDIO_LPCM_LE;
- frame->source = this;
- frame->free_buffer = store_aud_frame;
- frame->extra_info = xine_xmalloc(sizeof(extra_info_t));
+ frames[i].content = audio_content;
+ frames[i].type = BUF_AUDIO_LPCM_LE;
+ frames[i].source = this;
+ frames[i].free_buffer = store_aud_frame;
+ frames[i].extra_info = &infos[i];
- store_aud_frame(frame);
+ audio_content += this->periodsize;
+ store_aud_frame(&frames[i]);
+ }
+
+ if ( dovideo ) {
+ uint8_t *video_content = this->video_content_base =
+ calloc(NUM_FRAMES, this->frame_size);
+
+ /* Set up video frames */
+ for (i = NUM_FRAMES; i < 2*NUM_FRAMES; i++) {
+ /* Video frame */
+ frames[i].content = video_content;
+ frames[i].type = this->frame_format;
+ frames[i].source = this;
+ frames[i].free_buffer = store_vid_frame;
+ frames[i].extra_info = &infos[i];
+
+ video_content += this->frame_size;
+ store_vid_frame(&frames[i]);
+ }
}
}
@@ -809,7 +843,7 @@ static int open_radio_capture_device(v4l_input_plugin_t *this)
/* Pre-allocate some frames for audio so it doesn't have to be done during
* capture */
- allocate_audio_frames(this);
+ allocate_frames(this, 0);
this->audio_only = 1;
@@ -881,7 +915,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this)
/* Pre-allocate some frames for audio and video so it doesn't have to be
* done during capture */
- allocate_audio_frames(this);
+ allocate_frames(this, 1);
/* Unmute audio off video capture device */
unmute_audio(this);
@@ -985,20 +1019,6 @@ static int open_video_capture_device(v4l_input_plugin_t *this)
break;
}
- for (i = 0; i < NUM_FRAMES; i++) {
- buf_element_t *frame;
-
- frame = xine_xmalloc (sizeof (buf_element_t));
-
- frame->content = xine_xmalloc (this->frame_size);
- frame->type = this->frame_format;
- frame->source = this;
- frame->free_buffer = store_vid_frame;
- frame->extra_info = xine_xmalloc(sizeof(extra_info_t));
-
- store_vid_frame(frame);
- }
-
/* Strip the vbi / sync signal from the image by zooming in */
this->old_zoomx = xine_get_param(this->stream, XINE_PARAM_VO_ZOOM_X);
this->old_zoomy = xine_get_param(this->stream, XINE_PARAM_VO_ZOOM_Y);
@@ -1600,52 +1620,18 @@ static void v4l_plugin_dispose (input_plugin_t *this_gen) {
if (this->event_queue)
xine_event_dispose_queue (this->event_queue);
-
- lprintf("Freeing allocated audio frames");
- if (this->aud_frames) {
- buf_element_t *cur_frame = this->aud_frames;
-
- while (cur_frame != NULL) {
- buf_element_t *next_frame = cur_frame->next;
-#ifdef LOG
- printf(".");
-#endif
-
- if (cur_frame->content)
- free(cur_frame->content);
-
- if (cur_frame->extra_info)
- free(cur_frame->extra_info);
-
- free(cur_frame);
- cur_frame = next_frame;
- }
- }
-#ifdef LOG
- printf("\n");
-#endif
-
- lprintf("Freeing allocated video frames");
- if (this->vid_frames) {
- buf_element_t *cur_frame = this->vid_frames;
-
- while (cur_frame != NULL) {
- buf_element_t *next_frame = cur_frame->next;
-#ifdef LOG
- printf(".");
-#endif
+ /* All the frames, both video and audio, are allocated in a single
+ memory area pointed by the frames_base pointer. The content of
+ the frames is divided in two areas, one pointed by
+ audio_content_base and the other by video_content_base. The
+ extra_info structures are all allocated in the first frame
+ data. */
+ free(this->audio_content_base);
+ free(this->video_content_base);
+ free(this->frames_base->extra_info);
+ free(this->frames_base);
- if (cur_frame->content)
- free(cur_frame->content);
-
- if (cur_frame->extra_info)
- free(cur_frame->extra_info);
-
- free(cur_frame);
- cur_frame = next_frame;
- }
- }
#ifdef LOG
printf("\n");
#endif
@@ -1746,7 +1732,7 @@ static input_plugin_t *v4l_class_get_instance (input_class_t *cls_gen,
return NULL;
}
- this = (v4l_input_plugin_t *) xine_xmalloc (sizeof (v4l_input_plugin_t));
+ this = calloc(1, sizeof (v4l_input_plugin_t));
extract_mrl(this, mrl);
@@ -1912,7 +1898,7 @@ static void *init_video_class (xine_t *xine, void *data)
v4l_input_class_t *this;
config_values_t *config = xine->config;
- this = (v4l_input_class_t *) xine_xmalloc (sizeof (v4l_input_class_t));
+ this = calloc(1, sizeof (v4l_input_class_t));
this->xine = xine;
@@ -1929,12 +1915,6 @@ static void *init_video_class (xine_t *xine, void *data)
_("v4l video device"),
_("The path to your Video4Linux video device."),
10, NULL, NULL);
-
- config->register_enum (config, "media.video4linux.tv_standard", 0,
- tv_standard_names, _("v4l TV standard"),
- _("Selects the TV standard of the input signals. "
- "Either: PAL, NTSC and SECAM. "), 20, NULL, NULL);
-
#ifdef HAVE_ALSA
config->register_filename (config, "media.video4linux.audio_device",
AUDIO_DEV, 0,
@@ -1942,7 +1922,11 @@ static void *init_video_class (xine_t *xine, void *data)
_("The name of the audio device which corresponds "
"to your Video4Linux video device."),
10, NULL, NULL);
-#endif
+#endif
+ config->register_enum (config, "media.video4linux.tv_standard", 0 /* auto */,
+ tv_standard_names, _("v4l TV standard"),
+ _("Selects the TV standard of the input signals. "
+ "Either: AUTO, PAL, NTSC or SECAM. "), 20, NULL, NULL);
return this;
}
@@ -1952,7 +1936,7 @@ static void *init_radio_class (xine_t *xine, void *data)
v4l_input_class_t *this;
config_values_t *config = xine->config;
- this = (v4l_input_class_t *) xine_xmalloc (sizeof (v4l_input_class_t));
+ this = calloc(1, sizeof (v4l_input_class_t));
this->xine = xine;
diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c
index 4b624a9e7..18cc55ab8 100644
--- a/src/input/input_vcd.c
+++ b/src/input/input_vcd.c
@@ -84,7 +84,7 @@ typedef struct {
const char *device;
- char *filelist[100];
+ char **filelist;
int mrls_allocated_entries;
xine_mrl_t **mrls;
@@ -892,7 +892,7 @@ static input_plugin_t *vcd_class_get_instance (input_class_t *cls_gen, xine_stre
return 0;
}
- this = (vcd_input_plugin_t *) xine_xmalloc(sizeof(vcd_input_plugin_t));
+ this = calloc(1, sizeof(vcd_input_plugin_t));
this->stream = stream;
this->mrl = mrl;
@@ -918,6 +918,18 @@ static input_plugin_t *vcd_class_get_instance (input_class_t *cls_gen, xine_stre
/*
* vcd input plugin class stuff
*/
+static void vcd_filelist_dispose(vcd_input_class_t *this) {
+ if ( this->filelist == NULL ) return;
+
+ char **entry = this->filelist;
+
+ while(*(entry)) {
+ free(*(entry++));
+ }
+
+ free(this->filelist);
+}
+
static void vcd_class_dispose (input_class_t *this_gen) {
vcd_input_class_t *this = (vcd_input_class_t *) this_gen;
@@ -926,9 +938,7 @@ static void vcd_class_dispose (input_class_t *this_gen) {
config->unregister_callback(config, "media.vcd.device");
- for (i = 0; i < 100; i++)
- free (this->filelist[i]);
-
+ vcd_filelist_dispose(this);
free (this->mrls);
free (this);
}
@@ -976,33 +986,19 @@ static xine_mrl_t **vcd_class_get_dir (input_class_t *this_gen, const char *file
/* printf ("%d tracks\n", this->total_tracks); */
for (i=1; i<this->total_tracks; i++) { /* FIXME: check if track 0 contains valid data */
- char mrl[1024];
-
- memset(&mrl, 0, sizeof (mrl));
- sprintf(mrl, "vcdo:/%d",i);
-
if((i-1) >= this->mrls_allocated_entries) {
++this->mrls_allocated_entries;
/* note: 1 extra pointer for terminating NULL */
this->mrls = realloc(this->mrls, (this->mrls_allocated_entries+1) * sizeof(xine_mrl_t*));
- this->mrls[(i-1)] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t));
+ this->mrls[(i-1)] = calloc(1, sizeof(xine_mrl_t));
}
else {
memset(this->mrls[(i-1)], 0, sizeof(xine_mrl_t));
}
- if(this->mrls[(i-1)]->mrl) {
- this->mrls[(i-1)]->mrl = (char *)
- realloc(this->mrls[(i-1)]->mrl, strlen(mrl) + 1);
- }
- else {
- this->mrls[(i-1)]->mrl = (char *) xine_xmalloc(strlen(mrl) + 1);
- }
-
- this->mrls[i-1]->origin = NULL;
- sprintf(this->mrls[i-1]->mrl, "%s", mrl);
- this->mrls[i-1]->link = NULL;
- this->mrls[i-1]->type = (0 | mrl_vcd);
+ asprintf(&(this->mrls[i-1]->mrl), "vcdo:/%d", i);
+
+ this->mrls[i-1]->type = mrl_vcd;
/* hack */
this->mrls[i-1]->size = vcd_plugin_get_length ((input_plugin_t *) this);
@@ -1049,20 +1045,15 @@ static char ** vcd_class_get_autoplay_list (input_class_t *this_gen, int *num_fi
fd = -1;
*num_files = this->total_tracks - 1;
-
- /* printf ("%d tracks\n", this->total_tracks); */
- for (i = 1; i < this->total_tracks; i++) { /* FIXME: check if track 0 contains valid data */
+ vcd_filelist_dispose(this);
+ this->filelist = calloc(this->total_tracks+1, sizeof(char*));
- if(this->filelist[i - 1] == NULL)
- this->filelist[i - 1] = (char *) realloc(this->filelist[i - 1], sizeof(char *) * 256);
+ /* FIXME: check if track 0 contains valid data */
+ for (i = 1; i < this->total_tracks; i++)
+ asprintf(&this->filelist[i-1], "vcdo:/%d", i);
- sprintf (this->filelist[i - 1], "vcdo:/%d",i);
- /* printf ("list[%d] : %d %s\n", i, this->filelist[i-1], this->filelist[i-1]); */
- }
-
- this->filelist[i - 1] = (char *) realloc(this->filelist[i-1], sizeof(char *));
- this->filelist[i - 1] = NULL;
+ /* printf ("%d tracks\n", this->total_tracks); */
return this->filelist;
}
@@ -1073,7 +1064,7 @@ static void *init_class (xine_t *xine, void *data) {
config_values_t *config = xine->config;
int i;
- this = (vcd_input_class_t *) xine_xmalloc (sizeof (vcd_input_class_t));
+ this = calloc(1, sizeof (vcd_input_class_t));
this->xine = xine;
@@ -1091,13 +1082,9 @@ static void *init_class (xine_t *xine, void *data) {
"you intend to play your VideoCDs with."),
10, device_change_cb, (void *)this);
- this->mrls = (xine_mrl_t **) xine_xmalloc(sizeof(xine_mrl_t*));
+ this->mrls = calloc(1, sizeof(xine_mrl_t*));
this->mrls_allocated_entries = 0;
- for (i = 0; i < 100; i++) {
- this->filelist[i] = (char *) xine_xmalloc(sizeof(char *) * 256);
- }
-
return this;
}
diff --git a/src/input/libreal/asmrp.c b/src/input/libreal/asmrp.c
index 9fc7a3867..48b54f3a0 100644
--- a/src/input/libreal/asmrp.c
+++ b/src/input/libreal/asmrp.c
@@ -95,7 +95,7 @@ typedef struct {
} asmrp_t;
-static asmrp_t *asmrp_new () {
+static asmrp_t *XINE_MALLOC asmrp_new () {
asmrp_t *p;
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index 078b12757..d9f175748 100644
--- a/src/input/libreal/real.c
+++ b/src/input/libreal/real.c
@@ -48,9 +48,6 @@ static const unsigned char xor_table[] = {
#define _X_BE_32C(x,y) do { *(uint32_t *)(x) = be2me_32((y)); } while(0)
#define _X_LE_32C(x,y) do { *(uint32_t *)(x) = le2me_32((y)); } while(0)
-#define MAX(x,y) ((x>y) ? x : y)
-
-
static void hash(char *field, char *param) {
uint32_t a, b, c, d;
@@ -313,7 +310,7 @@ static void calc_response_string (char *result, char *challenge) {
void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) {
- int ch_len, resp_len;
+ size_t ch_len, resp_len;
int i;
char *ptr;
char buf[128] = { 0, };
@@ -448,7 +445,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
if (!desc) return NULL;
buf=xine_buffer_init(2048);
- header = xine_xmalloc(sizeof(rmff_header_t));
+ header = calloc(1, sizeof(rmff_header_t));
header->fileheader=rmff_new_fileheader(4+desc->stream_count);
header->cont=rmff_new_cont(
@@ -457,7 +454,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
desc->copyright,
desc->abstract);
header->data=rmff_new_dataheader(0,0);
- header->streams = xine_xcalloc((desc->stream_count+1), sizeof(rmff_mdpr_t*));
+ header->streams = calloc((desc->stream_count+1), sizeof(rmff_mdpr_t*));
lprintf("number of streams: %u\n", desc->stream_count);
for (i=0; i<desc->stream_count; i++) {
@@ -659,7 +656,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid
lprintf("Stream description size: %i\n", size);
- description = calloc(size+1, sizeof(char));
+ description = malloc(size+1);
if( rtsp_read_data(rtsp_session, description, size) <= 0) {
xine_buffer_free(buf);
diff --git a/src/input/libreal/rmff.h b/src/input/libreal/rmff.h
index 3fe3af284..285d8c978 100644
--- a/src/input/libreal/rmff.h
+++ b/src/input/libreal/rmff.h
@@ -32,10 +32,10 @@
#include <string.h>
#include <inttypes.h>
-
#ifndef HAVE_RMFF_H
#define HAVE_RMFF_H
+#include <xine/attributes.h>
#define RMFF_HEADER_SIZE 0x12
@@ -220,7 +220,7 @@ rmff_data_t *rmff_new_dataheader(
/*
* reads header infos from data and returns a newly allocated header struct
*/
-rmff_header_t *rmff_scan_header(const char *data);
+rmff_header_t *rmff_scan_header(const char *data) XINE_MALLOC;
#if 0
/*
@@ -232,7 +232,7 @@ void rmff_scan_pheader(rmff_pheader_t *h, char *data);
/*
* reads header infos from stream and returns a newly allocated header struct
*/
-rmff_header_t *rmff_scan_header_stream(int fd);
+rmff_header_t *rmff_scan_header_stream(int fd) XINE_MALLOC;
/*
* prints header information in human readible form to stdout
diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c
index 7920bdc40..d4be0959b 100644
--- a/src/input/libreal/sdpplin.c
+++ b/src/input/libreal/sdpplin.c
@@ -41,7 +41,7 @@ static char *nl(char *data) {
static int filter(const char *in, const char *filter, char **out) {
- int flen=strlen(filter);
+ size_t flen=strlen(filter);
size_t len;
if (!in)
@@ -62,9 +62,9 @@ static int filter(const char *in, const char *filter, char **out) {
return 0;
}
-static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
+static sdpplin_stream_t *XINE_MALLOC sdpplin_parse_stream(char **data) {
- sdpplin_stream_t *desc = xine_xmalloc(sizeof(sdpplin_stream_t));
+ sdpplin_stream_t *desc = calloc(1, sizeof(sdpplin_stream_t));
char *buf=xine_buffer_init(32);
int handled;
@@ -179,7 +179,7 @@ static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
sdpplin_t *sdpplin_parse(char *data) {
- sdpplin_t *desc = xine_xmalloc(sizeof(sdpplin_t));
+ sdpplin_t *desc = calloc(1, sizeof(sdpplin_t));
sdpplin_stream_t *stream;
char *buf=xine_buffer_init(32);
int handled;
diff --git a/src/input/libreal/sdpplin.h b/src/input/libreal/sdpplin.h
index 72cbaf731..1604ee38c 100644
--- a/src/input/libreal/sdpplin.h
+++ b/src/input/libreal/sdpplin.h
@@ -101,7 +101,7 @@ typedef struct {
} sdpplin_t;
-sdpplin_t *sdpplin_parse(char *data);
+sdpplin_t *sdpplin_parse(char *data) XINE_MALLOC;
void sdpplin_free(sdpplin_t *description);
diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c
index c660751fe..cc1f398ac 100644
--- a/src/input/librtsp/rtsp.c
+++ b/src/input/librtsp/rtsp.c
@@ -21,6 +21,10 @@
* *not* RFC 2326 compilant yet.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <config.h>
#include <unistd.h>
@@ -123,8 +127,8 @@ static char *rtsp_get(rtsp_t *s) {
static void rtsp_put(rtsp_t *s, const char *string) {
- int len=strlen(string);
- char buf[len+2];
+ size_t len=strlen(string);
+ char *buf = malloc(sizeof(char)*len+2);
lprintf(">> '%s'", string);
@@ -169,9 +173,9 @@ static int rtsp_get_code(rtsp_t *s, const char *string) {
static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) {
char **payload=s->scheduled;
- char buf[strlen(type)+strlen(what)+strlen(rtsp_protocol_version)+3];
+ char *buf;
- sprintf(buf,"%s %s %s",type, what, rtsp_protocol_version);
+ asprintf(&buf,"%s %s %s",type, what, rtsp_protocol_version);
rtsp_put(s,buf);
if (payload)
@@ -195,8 +199,8 @@ static void rtsp_schedule_standard(rtsp_t *s) {
rtsp_schedule_field(s, tmp);
if (s->session) {
- char buf[strlen(s->session)+15];
- sprintf(buf, "Session: %s", s->session);
+ char *buf;
+ asprintf(&buf, "Session: %s", s->session);
rtsp_schedule_field(s, buf);
}
}
@@ -226,35 +230,31 @@ static int rtsp_get_answers(rtsp_t *s) {
if (!answer)
return 0;
- if (!strncasecmp(answer,"Cseq:",5)) {
- sscanf(answer,"%*s %u",&answer_seq);
+ if (!strncasecmp(answer,"Cseq: ",6)) {
+ sscanf(answer+6,"%u",&answer_seq);
if (s->cseq != answer_seq) {
lprintf("warning: Cseq mismatch. got %u, assumed %u", answer_seq, s->cseq);
s->cseq=answer_seq;
}
}
- if (!strncasecmp(answer,"Server:",7)) {
- char buf[strlen(answer)];
- sscanf(answer,"%*s %s",buf);
- if (s->server) free(s->server);
- s->server=strdup(buf);
+ if (!strncasecmp(answer,"Server: ",8)) {
+ free(s->server);
+ s->server = strdup(answer + 8);
}
- if (!strncasecmp(answer,"Session:",8)) {
- char buf[strlen(answer)];
- sscanf(answer,"%*s %s",buf);
+ if (!strncasecmp(answer,"Session: ",9)) {
+ char *tmp = answer + 9;
if (s->session) {
- if (strcmp(buf, s->session)) {
+ if (strcmp(tmp, s->session)) {
xprintf(s->stream->xine, XINE_VERBOSITY_DEBUG,
- "rtsp: warning: setting NEW session: %s\n", buf);
- free(s->session);
- s->session=strdup(buf);
+ "rtsp: warning: setting NEW session: %s\n", tmp);
+ s->session=strdup(tmp);
}
} else
{
lprintf("setting session id to: %s\n", buf);
- s->session=strdup(buf);
+ s->session=strdup(tmp);
}
}
*answer_ptr=answer;
diff --git a/src/input/librtsp/rtsp.h b/src/input/librtsp/rtsp.h
index 1cec57e1e..8aee8e049 100644
--- a/src/input/librtsp/rtsp.h
+++ b/src/input/librtsp/rtsp.h
@@ -40,7 +40,7 @@
typedef struct rtsp_s rtsp_t;
-rtsp_t* rtsp_connect (xine_stream_t *stream, const char *mrl, const char *user_agent);
+rtsp_t* rtsp_connect (xine_stream_t *stream, const char *mrl, const char *user_agent) XINE_MALLOC;
int rtsp_request_options(rtsp_t *s, const char *what);
int rtsp_request_describe(rtsp_t *s, const char *what);
diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c
index d8f7ae583..88e0f87d1 100644
--- a/src/input/librtsp/rtsp_session.c
+++ b/src/input/librtsp/rtsp_session.c
@@ -78,7 +78,7 @@ static const char *const rtsp_bandwidth_strs[]={"14.4 Kbps (Modem)", "19.2 Kbps
rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) {
- rtsp_session_t *rtsp_session = xine_xmalloc(sizeof(rtsp_session_t));
+ rtsp_session_t *rtsp_session = calloc(1, sizeof(rtsp_session_t));
xine_t *xine = stream->xine;
char *server;
char *mrl_line=strdup(mrl);
diff --git a/src/input/librtsp/rtsp_session.h b/src/input/librtsp/rtsp_session.h
index b47db0730..33ac579e1 100644
--- a/src/input/librtsp/rtsp_session.h
+++ b/src/input/librtsp/rtsp_session.h
@@ -25,7 +25,7 @@
typedef struct rtsp_session_s rtsp_session_t;
-rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl);
+rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) XINE_MALLOC;
void rtsp_session_set_start_time(rtsp_session_t *this, int start_time);
diff --git a/src/input/mms.c b/src/input/mms.c
index ba584b4f8..812e2ed43 100644
--- a/src/input/mms.c
+++ b/src/input/mms.c
@@ -202,9 +202,9 @@ static void mms_buffer_put_64 (mms_buffer_t *mms_buffer, uint64_t value) {
}
+#ifdef LOG
static void print_command (char *data, int len) {
-#ifdef LOG
int i;
int dir = _X_LE_32 (data + 36) >> 16;
int comm = _X_LE_32 (data + 36) & 0xFFFF;
@@ -240,8 +240,10 @@ static void print_command (char *data, int len) {
if (len > CMD_HEADER_LEN)
printf ("\n");
printf ("----------------------------------------------\n");
+}
+#else
+# define print_command(data, len)
#endif
-}
@@ -678,7 +680,7 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) {
if (!url)
return NULL;
- this = (mms_t*) xine_xmalloc (sizeof (mms_t));
+ this = calloc(1, sizeof (mms_t));
this->stream = stream;
this->url = strdup (url);
@@ -769,12 +771,10 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) {
/* command 0x5 */
{
mms_buffer_t command_buffer;
- char *path;
- int pathlen;
+ char *path = this->uri;
+ size_t pathlen = strlen(path);
/* remove the first '/' */
- path = this->uri;
- pathlen = strlen(path);
if (pathlen > 1) {
path++;
pathlen--;
diff --git a/src/input/mmsh.c b/src/input/mmsh.c
index 3a33e8d7f..1f69680f9 100644
--- a/src/input/mmsh.c
+++ b/src/input/mmsh.c
@@ -190,11 +190,9 @@ struct mmsh_s {
};
static int send_command (mmsh_t *this, char *cmd) {
- int length;
-
lprintf ("send_command:\n%s\n", cmd);
- length = strlen(cmd);
+ const size_t length = strlen(cmd);
if (_x_io_tcp_write(this->stream, this->s, cmd, length) != length) {
xprintf (this->stream->xine, XINE_LOG_MSG, _("libmmsh: send error\n"));
return 0;
@@ -636,7 +634,7 @@ mmsh_t *mmsh_connect (xine_stream_t *stream, const char *url, int bandwidth) {
report_progress (stream, 0);
- this = (mmsh_t*) xine_xmalloc (sizeof (mmsh_t));
+ this = calloc(1, sizeof (mmsh_t));
this->stream = stream;
this->url = strdup(url);
diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c
index 03a24d38f..1883a9462 100644
--- a/src/input/net_buf_ctrl.c
+++ b/src/input/net_buf_ctrl.c
@@ -492,7 +492,7 @@ static void nbc_get_cb (fifo_buffer_t *fifo,
nbc_t *nbc_init (xine_stream_t *stream) {
- nbc_t *this = (nbc_t *) xine_xmalloc (sizeof (nbc_t));
+ nbc_t *this = calloc(1, sizeof (nbc_t));
fifo_buffer_t *video_fifo = stream->video_fifo;
fifo_buffer_t *audio_fifo = stream->audio_fifo;
double video_fifo_factor, audio_fifo_factor;
diff --git a/src/input/net_buf_ctrl.h b/src/input/net_buf_ctrl.h
index 87d6d84a1..e71cbedde 100644
--- a/src/input/net_buf_ctrl.h
+++ b/src/input/net_buf_ctrl.h
@@ -27,7 +27,7 @@
typedef struct nbc_s nbc_t;
-nbc_t *nbc_init (xine_stream_t *xine);
+nbc_t *nbc_init (xine_stream_t *xine) XINE_MALLOC;
void nbc_close (nbc_t *this);
diff --git a/src/input/pnm.c b/src/input/pnm.c
index 564151279..3caaf41bd 100644
--- a/src/input/pnm.c
+++ b/src/input/pnm.c
@@ -21,6 +21,10 @@
* based upon code from joschka
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <config.h>
#include <unistd.h>
@@ -413,8 +417,8 @@ static void pnm_send_request(pnm_t *p, uint32_t bandwidth) {
*/
static void pnm_send_response(pnm_t *p, const char *response) {
-
- int size=strlen(response);
+ /** @TODO should check that sze is always < 256 */
+ size_t size=strlen(response);
p->buffer[0]=0x23;
p->buffer[1]=0;
@@ -629,10 +633,7 @@ static int pnm_get_stream_chunk(pnm_t *p) {
*/
n=0;
while (p->buffer[0] != 0x5a) {
- int i;
- for (i=1; i<8; i++) {
- p->buffer[i-1]=p->buffer[i];
- }
+ memmove(p->buffer, &p->buffer[1], 8);
_x_io_tcp_read (p->stream, p->s, &p->buffer[7], 1);
n++;
}
@@ -718,7 +719,7 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) {
mrl_ptr+=6;
- p = xine_xmalloc(sizeof(pnm_t));
+ p = calloc(1, sizeof(pnm_t));
p->stream = stream;
p->port=7070;
p->url=strdup(mrl);
diff --git a/src/input/vcd/xine-extra.c b/src/input/vcd/xine-extra.c
index 79c962a79..e3b6da912 100644
--- a/src/input/vcd/xine-extra.c
+++ b/src/input/vcd/xine-extra.c
@@ -45,8 +45,10 @@ static xine_t *my_xine = NULL;
void
xine_vlog_msg(xine_t *this, int buf, const char *format, va_list args)
{
+ va_list copy;
+ va_copy (copy, args);
xine_vlog(this, buf, format, args);
- vfprintf(stdout, format, args);
+ vfprintf(stdout, format, copy);
}
/*! This routine is like xine_log, except it takes a va_list instead
@@ -59,8 +61,10 @@ xine_vlog_msg(xine_t *this, int buf, const char *format, va_list args)
void
xine_vlog_err(xine_t *this, int buf, const char *format, va_list args)
{
+ va_list copy;
+ va_copy (copy, args);
xine_vlog(this, buf, format, args);
- vfprintf(stderr, format, args);
+ vfprintf(stderr, format, copy);
}
/*! Call this before calling any of the xine_log_msg or xine_log_err
@@ -116,8 +120,8 @@ xine_log_err(const char *format, ...)
{
va_list args;
- va_start(args, format);
if (NULL == my_xine) return false;
+ va_start(args, format);
xine_vlog_err(my_xine, XINE_LOG_MSG, format, args);
va_end(args);
return true;
diff --git a/src/input/vcd/xineplug_inp_vcd.c b/src/input/vcd/xineplug_inp_vcd.c
index 27b1cfbbf..8c222c7ab 100644
--- a/src/input/vcd/xineplug_inp_vcd.c
+++ b/src/input/vcd/xineplug_inp_vcd.c
@@ -1740,7 +1740,7 @@ vcd_init (xine_t *xine, void *data)
dbg_print(INPUT_DBG_CALL, "Called\n");
- class = (vcd_input_class_t *) xine_xmalloc (sizeof (vcd_input_class_t));
+ class = calloc(1, sizeof (vcd_input_class_t));
class->xine = xine;
class->config = config = xine->config;
diff --git a/src/libmpeg2new/xine_mpeg2new_decoder.c b/src/libmpeg2new/xine_mpeg2new_decoder.c
index eeafee9c1..7494791b1 100644
--- a/src/libmpeg2new/xine_mpeg2new_decoder.c
+++ b/src/libmpeg2new/xine_mpeg2new_decoder.c
@@ -449,7 +449,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
mpeg2_video_decoder_t *this ;
int32_t n;
- this = (mpeg2_video_decoder_t *) xine_xmalloc (sizeof (mpeg2_video_decoder_t));
+ this = (mpeg2_video_decoder_t *) calloc(1, sizeof(mpeg2_video_decoder_t));
this->video_decoder.decode_data = mpeg2_video_decode_data;
this->video_decoder.flush = mpeg2_video_flush;
@@ -477,7 +477,7 @@ static void *init_plugin (xine_t *xine, void *data) {
mpeg2_class_t *this;
- this = (mpeg2_class_t *) xine_xmalloc (sizeof (mpeg2_class_t));
+ this = (mpeg2_class_t *) calloc(1, sizeof(mpeg2_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "mpeg2new";
diff --git a/src/libreal/xine_real_audio_decoder.c b/src/libreal/xine_real_audio_decoder.c
index a12518c1e..e59941379 100644
--- a/src/libreal/xine_real_audio_decoder.c
+++ b/src/libreal/xine_real_audio_decoder.c
@@ -310,14 +310,14 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
if (this->sps) {
this->frame_size = this->w/this->sps*this->h*this->sps;
- this->frame_buffer = xine_xmalloc (this->frame_size);
- this->frame_reordered = xine_xmalloc (this->frame_size);
+ this->frame_buffer = calloc (1, this->frame_size);
+ this->frame_reordered = calloc (1, this->frame_size);
this->frame_num_bytes = 0;
} else {
this->frame_size = this->w*this->h;
- this->frame_buffer = xine_xmalloc (this->frame_size);
+ this->frame_buffer = calloc (this->w, this->h);
this->frame_reordered = this->frame_buffer;
this->frame_num_bytes = 0;
@@ -477,7 +477,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen,
real_class_t *cls = (real_class_t *) class_gen;
realdec_decoder_t *this ;
- this = (realdec_decoder_t *) xine_xmalloc (sizeof (realdec_decoder_t));
+ this = (realdec_decoder_t *) calloc(1, sizeof(realdec_decoder_t));
this->audio_decoder.decode_data = realdec_decode_data;
this->audio_decoder.reset = realdec_reset;
@@ -499,7 +499,7 @@ void *init_realadec (xine_t *xine, void *data) {
real_class_t *this;
config_values_t *config = xine->config;
- this = (real_class_t *) xine_xmalloc (sizeof (real_class_t));
+ this = (real_class_t *) calloc(1, sizeof(real_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "realadec";
diff --git a/src/libreal/xine_real_video_decoder.c b/src/libreal/xine_real_video_decoder.c
index 2b5eafa16..56e9fad01 100644
--- a/src/libreal/xine_real_video_decoder.c
+++ b/src/libreal/xine_real_video_decoder.c
@@ -278,7 +278,7 @@ static int init_codec (realdec_decoder_t *this, buf_element_t *buf) {
this->frame_size = this->width * this->height;
this->frame_buffer = xine_xmalloc (this->width * this->height * 3 / 2);
- this->chunk_buffer = xine_xmalloc (BUF_SIZE);
+ this->chunk_buffer = calloc(1, BUF_SIZE);
this->chunk_buffer_max = BUF_SIZE;
return 1;
@@ -496,7 +496,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
real_class_t *cls = (real_class_t *) class_gen;
realdec_decoder_t *this ;
- this = (realdec_decoder_t *) xine_xmalloc (sizeof (realdec_decoder_t));
+ this = (realdec_decoder_t *) calloc(1, sizeof(realdec_decoder_t));
this->video_decoder.decode_data = realdec_decode_data;
this->video_decoder.flush = realdec_flush;
@@ -522,7 +522,7 @@ void *init_realvdec (xine_t *xine, void *data) {
real_class_t *this;
config_values_t *config = xine->config;
- this = (real_class_t *) xine_xmalloc (sizeof (real_class_t));
+ this = (real_class_t *) calloc(1, sizeof(real_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "realvdec";
diff --git a/src/libw32dll/qt_decoder.c b/src/libw32dll/qt_decoder.c
index 2ef8ebc66..94ec86e7f 100644
--- a/src/libw32dll/qt_decoder.c
+++ b/src/libw32dll/qt_decoder.c
@@ -553,7 +553,7 @@ static audio_decoder_t *qta_open_plugin (audio_decoder_class_t *class_gen,
qta_decoder_t *this ;
- this = (qta_decoder_t *) xine_xmalloc (sizeof (qta_decoder_t));
+ this = (qta_decoder_t *) calloc(1, sizeof(qta_decoder_t));
this->audio_decoder.decode_data = qta_decode_data;
this->audio_decoder.reset = qta_reset;
@@ -579,7 +579,7 @@ static void *qta_init_class (xine_t *xine, void *data) {
pthread_once (&once_control, init_routine);
- this = (qta_class_t *) xine_xmalloc (sizeof (qta_class_t));
+ this = (qta_class_t *) calloc(1, sizeof(qta_class_t));
this->decoder_class.open_plugin = qta_open_plugin;
this->decoder_class.identifier = "qta";
@@ -1050,7 +1050,7 @@ static video_decoder_t *qtv_open_plugin (video_decoder_class_t *class_gen,
qtv_class_t *cls = (qtv_class_t *) class_gen;
qtv_decoder_t *this ;
- this = (qtv_decoder_t *) xine_xmalloc (sizeof (qtv_decoder_t));
+ this = (qtv_decoder_t *) calloc(1, sizeof(qtv_decoder_t));
this->video_decoder.decode_data = qtv_decode_data;
this->video_decoder.flush = qtv_flush;
@@ -1091,7 +1091,7 @@ static void *qtv_init_class (xine_t *xine, void *data) {
pthread_once (&once_control, init_routine);
- this = (qtv_class_t *) xine_xmalloc (sizeof (qtv_class_t));
+ this = (qtv_class_t *) calloc(1, sizeof(qtv_class_t));
this->decoder_class.open_plugin = qtv_open_plugin;
this->decoder_class.identifier = "qtvdec";
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c
index fb7d3a482..a7c65cb07 100644
--- a/src/libw32dll/w32codec.c
+++ b/src/libw32dll/w32codec.c
@@ -1550,7 +1550,7 @@ static video_decoder_t *open_video_decoder_plugin (video_decoder_class_t *class_
w32v_decoder_t *this ;
- this = (w32v_decoder_t *) xine_xmalloc (sizeof (w32v_decoder_t));
+ this = (w32v_decoder_t *) calloc(1, sizeof(w32v_decoder_t));
this->video_decoder.decode_data = w32v_decode_data;
this->video_decoder.flush = w32v_flush;
@@ -1581,7 +1581,7 @@ static void *init_video_decoder_class (xine_t *xine, void *data) {
cfg = xine->config;
if ((win32_def_path = get_win32_codecs_path(cfg)) == NULL) return NULL;
- this = (w32v_class_t *) xine_xmalloc (sizeof (w32v_class_t));
+ this = (w32v_class_t *) calloc(1, sizeof(w32v_class_t));
this->decoder_class.open_plugin = open_video_decoder_plugin;
this->decoder_class.identifier = "w32v";
@@ -1602,7 +1602,7 @@ static audio_decoder_t *open_audio_decoder_plugin (audio_decoder_class_t *class_
w32a_decoder_t *this ;
- this = (w32a_decoder_t *) xine_xmalloc (sizeof (w32a_decoder_t));
+ this = (w32a_decoder_t *) calloc(1, sizeof(w32a_decoder_t));
this->audio_decoder.decode_data = w32a_decode_data;
this->audio_decoder.reset = w32a_reset;
@@ -1630,7 +1630,7 @@ static void *init_audio_decoder_class (xine_t *xine, void *data) {
cfg = xine->config;
if ((win32_def_path = get_win32_codecs_path(cfg)) == NULL) return NULL;
- this = (w32a_class_t *) xine_xmalloc (sizeof (w32a_class_t));
+ this = (w32a_class_t *) calloc(1, sizeof(w32a_class_t));
this->decoder_class.open_plugin = open_audio_decoder_plugin;
this->decoder_class.identifier = "win32 audio";
diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c
index 14ee178de..2ce05b970 100644
--- a/src/libw32dll/wine/win32.c
+++ b/src/libw32dll/wine/win32.c
@@ -3491,9 +3491,9 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
if(strstr(cs1, ".qtx"))
{
int result;
- char* tmp=(char*)malloc(strlen(win32_def_path)+250);
char* x=strrchr(cs1,'\\');
- sprintf(tmp,"%s/%s",win32_def_path,x?(x+1):cs1);
+ char* tmp;
+ asprintf(&tmp,"%s/%s",win32_def_path,x?(x+1):cs1);
// printf("### Open: %s -> %s\n",cs1,tmp);
result=open(tmp, O_RDONLY);
free(tmp);
diff --git a/src/post/audio/stretch.c b/src/post/audio/stretch.c
index 5a0382895..c082eefa6 100644
--- a/src/post/audio/stretch.c
+++ b/src/post/audio/stretch.c
@@ -152,10 +152,10 @@ static void stretchscr_exit (scr_plugin_t *scr) {
free(this);
}
-static stretchscr_t* stretchscr_init (double *stretch_factor) {
+static stretchscr_t *XINE_MALLOC stretchscr_init (double *stretch_factor) {
stretchscr_t *this;
- this = (stretchscr_t *) xine_xmalloc(sizeof(stretchscr_t));
+ this = calloc(1, sizeof(stretchscr_t));
this->scr.interface_version = 3;
this->scr.get_priority = stretchscr_get_priority;
@@ -620,7 +620,7 @@ static post_plugin_t *stretch_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_stretch_t *this = (post_plugin_stretch_t *)xine_xmalloc(sizeof(post_plugin_stretch_t));
+ post_plugin_stretch_t *this = calloc(1, sizeof(post_plugin_stretch_t));
post_in_t *input;
post_out_t *output;
xine_post_in_t *input_api;
diff --git a/src/post/audio/upmix.c b/src/post/audio/upmix.c
index 573354450..3e5c2e65b 100644
--- a/src/post/audio/upmix.c
+++ b/src/post/audio/upmix.c
@@ -181,7 +181,7 @@ static int upmix_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream,
}
pthread_mutex_lock (&this->lock);
- this->sub = xine_xmalloc(sizeof(af_sub_t));
+ this->sub = calloc(1, sizeof(af_sub_t));
if (!this->sub) {
pthread_mutex_unlock (&this->lock);
return 0;
@@ -379,7 +379,7 @@ static post_plugin_t *upmix_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_upmix_t *this = (post_plugin_upmix_t *)xine_xmalloc(sizeof(post_plugin_upmix_t));
+ post_plugin_upmix_t *this = calloc(1, sizeof(post_plugin_upmix_t));
post_in_t *input;
post_out_t *output;
xine_post_in_t *input_api;
diff --git a/src/post/audio/upmix_mono.c b/src/post/audio/upmix_mono.c
index 82ceb1877..193989586 100644
--- a/src/post/audio/upmix_mono.c
+++ b/src/post/audio/upmix_mono.c
@@ -192,32 +192,32 @@ static void upmix_mono_port_put_buffer(xine_audio_port_t *port_gen,
_x_extra_info_merge(buf1->extra_info, buf->extra_info);
{
- int step = buf->format.bits / 8;
+ const size_t step = buf->format.bits / 8;
uint8_t *src = (uint8_t *)buf->mem;
uint8_t *dst0 = (uint8_t *)buf0->mem;
uint8_t *dst1 = (uint8_t *)buf1->mem;
- int i, k;
+ int i;
for (i = 0; i < buf->num_frames / 2; i++)
{
- for (k = 0; k < step; k++)
- *dst0++ = *src++;
+ memcpy(dst0, src, step);
+ dst0 += step;
- src -= step;
+ memcpy(dst0, src, step);
+ dst0 += step;
- for (k = 0; k < step; k++)
- *dst0++ = *src++;
+ src += step;
}
for (i = buf->num_frames / 2; i < buf->num_frames; i++)
{
- for (k = 0; k < step; k++)
- *dst1++ = *src++;
+ memcpy(dst1, src, step);
+ dst1 += step;
- src -= step;
+ memcpy(dst1, src, step);
+ dst1 += step;
- for (k = 0; k < step; k++)
- *dst1++ = *src++;
+ src += step;
}
}
@@ -244,11 +244,11 @@ static void upmix_mono_port_put_buffer(xine_audio_port_t *port_gen,
_x_extra_info_merge(buf0->extra_info, buf->extra_info);
{
- int step = buf->format.bits / 8;
+ const size_t step = buf->format.bits / 8;
uint8_t *src = (uint8_t *)buf->mem;
uint8_t *dst0 = (uint8_t *)buf0->mem;
int cur_channel = this->params.channel;
- int i, j, k;
+ int i, j;
if( cur_channel >= this->channels )
cur_channel = this->channels-1;
@@ -259,8 +259,8 @@ static void upmix_mono_port_put_buffer(xine_audio_port_t *port_gen,
{
for (j = 0; j < this->channels; j++ )
{
- for (k = 0; k < step; k++)
- *dst0++ = *(src+k);
+ memcpy(dst0, src, step);
+ dst0 += step;
}
src += this->channels * step;
}
@@ -293,7 +293,7 @@ static post_plugin_t *upmix_mono_open_plugin(post_class_t *class_gen, int inputs
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_upmix_mono_t *this = (post_plugin_upmix_mono_t *)xine_xmalloc(sizeof(post_plugin_upmix_mono_t));
+ post_plugin_upmix_mono_t *this = calloc(1, sizeof(post_plugin_upmix_mono_t));
post_in_t *input;
post_out_t *output;
xine_post_in_t *input_api;
diff --git a/src/post/audio/volnorm.c b/src/post/audio/volnorm.c
index de4ebde87..9ea774564 100644
--- a/src/post/audio/volnorm.c
+++ b/src/post/audio/volnorm.c
@@ -407,7 +407,7 @@ static post_plugin_t *volnorm_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_volnorm_t *this = (post_plugin_volnorm_t *)xine_xmalloc(sizeof(post_plugin_volnorm_t));
+ post_plugin_volnorm_t *this = calloc(1, sizeof(post_plugin_volnorm_t));
post_in_t *input;
post_out_t *output;
xine_post_in_t *input_api;
@@ -426,9 +426,8 @@ static post_plugin_t *volnorm_open_plugin(post_class_t *class_gen, int inputs,
this->mul = MUL_INIT;
this->lastavg = MID_S16;
this->idx = 0;
- for (i = 0; i < NSAMPLES; i++)
- this->mem[i].len = this->mem[i].avg = 0;
-
+ memset(this->mem, 0, sizeof(this->mem));
+
port = _x_post_intercept_audio_port(&this->post, audio_target[0], &input, &output);
port->new_port.open = volnorm_port_open;
port->new_port.close = volnorm_port_close;
diff --git a/src/post/deinterlace/xine_plugin.c b/src/post/deinterlace/xine_plugin.c
index 3d14b6325..a51712338 100644
--- a/src/post/deinterlace/xine_plugin.c
+++ b/src/post/deinterlace/xine_plugin.c
@@ -289,7 +289,7 @@ static int deinterlace_draw(vo_frame_t *frame, xine_stream_t *stream)
static void *deinterlace_init_plugin(xine_t *xine, void *data)
{
- post_class_deinterlace_t *class = (post_class_deinterlace_t *)xine_xmalloc(sizeof(post_class_deinterlace_t));
+ post_class_deinterlace_t *class = calloc(1, sizeof(post_class_deinterlace_t));
uint32_t config_flags = xine_mm_accel();
int i;
@@ -362,7 +362,7 @@ static post_plugin_t *deinterlace_open_plugin(post_class_t *class_gen, int input
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_deinterlace_t *this = (post_plugin_deinterlace_t *)xine_xmalloc(sizeof(post_plugin_deinterlace_t));
+ post_plugin_deinterlace_t *this = calloc(1, sizeof(post_plugin_deinterlace_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/goom/goom_core.c b/src/post/goom/goom_core.c
index 274059da4..b69994d8f 100644
--- a/src/post/goom/goom_core.c
+++ b/src/post/goom/goom_core.c
@@ -841,7 +841,7 @@ void update_message (PluginInfo *goomInfo, char *message) {
if (message) {
int i=1,j=0;
- sprintf (goomInfo->update_message.message, "%s", message);
+ strcpy(goomInfo->update_message.message, message);
for (j=0;goomInfo->update_message.message[j];j++)
if (goomInfo->update_message.message[j]=='\n')
i++;
@@ -855,8 +855,8 @@ void update_message (PluginInfo *goomInfo, char *message) {
char *ptr = msg;
int pos;
float ecart;
+ strncpy(msg, goomInfo->update_message.message, goomInfo->update_message.longueur);
message = msg;
- sprintf (msg, "%s", goomInfo->update_message.message);
while (!fin) {
while (1) {
diff --git a/src/post/goom/xine_goom.c b/src/post/goom/xine_goom.c
index 6971a5a1c..dfc4036f1 100644
--- a/src/post/goom/xine_goom.c
+++ b/src/post/goom/xine_goom.c
@@ -185,7 +185,7 @@ static void csc_method_changed_cb(void *data, xine_cfg_entry_t *cfg) {
static void *goom_init_plugin(xine_t *xine, void *data)
{
- post_class_goom_t *this = (post_class_goom_t *)xine_xmalloc(sizeof(post_class_goom_t));
+ post_class_goom_t *this = calloc(1, sizeof(post_class_goom_t));
config_values_t *cfg;
if (!this)
@@ -232,7 +232,7 @@ static post_plugin_t *goom_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_goom_t *this = (post_plugin_goom_t *)xine_xmalloc(sizeof(post_plugin_goom_t));
+ post_plugin_goom_t *this = calloc(1, sizeof(post_plugin_goom_t));
post_class_goom_t *class = (post_class_goom_t*) class_gen;
post_in_t *input;
post_out_t *output;
diff --git a/src/post/mosaico/mosaico.c b/src/post/mosaico/mosaico.c
index 6c01a66e1..0a4031bde 100644
--- a/src/post/mosaico/mosaico.c
+++ b/src/post/mosaico/mosaico.c
@@ -22,6 +22,10 @@
* simple video mosaico plugin
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#define LOG_MODULE "mosaico"
#define LOG_VERBOSE
/*
@@ -119,7 +123,7 @@ static int mosaico_draw(vo_frame_t *frame, xine_stream_t *stream);
static void *mosaico_init_plugin(xine_t *xine, void *data)
{
- post_class_mosaico_t *this = (post_class_mosaico_t *)xine_xmalloc(sizeof(post_class_mosaico_t));
+ post_class_mosaico_t *this = calloc(1, sizeof(post_class_mosaico_t));
if (!this)
return NULL;
@@ -137,7 +141,7 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_mosaico_t *this = (post_mosaico_t *)xine_xmalloc(sizeof(post_mosaico_t));
+ post_mosaico_t *this = calloc(1, sizeof(post_mosaico_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
@@ -155,7 +159,7 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs,
_x_post_init(&this->post, 0, inputs);
- this->pip = (mosaico_pip_t *)xine_xcalloc((inputs - 1), sizeof(mosaico_pip_t));
+ this->pip = (mosaico_pip_t *)calloc((inputs - 1), sizeof(mosaico_pip_t));
this->pip_count = inputs - 1;
pthread_cond_init(&this->vpts_limit_changed, NULL);
@@ -175,8 +179,7 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs,
this->pip[i].y = 50;
this->pip[i].w = 150;
this->pip[i].h = 150;
- this->pip[i].input_name = (char *)xine_xmalloc(sizeof("video in ") + 10);
- snprintf(this->pip[i].input_name, sizeof("video in ") + 10, "video in %d", i+1);
+ asprintf(&(this->pip[i].input_name), "video in %d", i+1);
port = _x_post_intercept_video_port(&this->post, video_target[0], &input, NULL);
port->new_port.close = mosaico_close;
diff --git a/src/post/mosaico/switch.c b/src/post/mosaico/switch.c
index a4de02715..90dbf2690 100644
--- a/src/post/mosaico/switch.c
+++ b/src/post/mosaico/switch.c
@@ -98,7 +98,7 @@ static int switch_draw(vo_frame_t *frame, xine_stream_t *stream);
static void *switch_init_plugin(xine_t *xine, void *data)
{
- post_class_switch_t *this = (post_class_switch_t *)xine_xmalloc(sizeof(post_class_switch_t));
+ post_class_switch_t *this = calloc(1, sizeof(post_class_switch_t));
if (!this)
return NULL;
@@ -116,7 +116,7 @@ static post_plugin_t *switch_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_switch_t *this = (post_switch_t *)xine_xmalloc(sizeof(post_switch_t));
+ post_switch_t *this = calloc(1, sizeof(post_switch_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/planar/boxblur.c b/src/post/planar/boxblur.c
index 988729af0..b27e7e561 100644
--- a/src/post/planar/boxblur.c
+++ b/src/post/planar/boxblur.c
@@ -151,7 +151,7 @@ static post_plugin_t *boxblur_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_boxblur_t *this = (post_plugin_boxblur_t *)xine_xmalloc(sizeof(post_plugin_boxblur_t));
+ post_plugin_boxblur_t *this = calloc(1, sizeof(post_plugin_boxblur_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/planar/denoise3d.c b/src/post/planar/denoise3d.c
index bec59b35f..cadaafae0 100644
--- a/src/post/planar/denoise3d.c
+++ b/src/post/planar/denoise3d.c
@@ -191,7 +191,7 @@ static post_plugin_t *denoise3d_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_denoise3d_t *this = (post_plugin_denoise3d_t *)xine_xmalloc(sizeof(post_plugin_denoise3d_t));
+ post_plugin_denoise3d_t *this = calloc(1, sizeof(post_plugin_denoise3d_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/planar/eq.c b/src/post/planar/eq.c
index e62a808c1..128616e6d 100644
--- a/src/post/planar/eq.c
+++ b/src/post/planar/eq.c
@@ -243,7 +243,7 @@ static post_plugin_t *eq_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_eq_t *this = (post_plugin_eq_t *)xine_xmalloc(sizeof(post_plugin_eq_t));
+ post_plugin_eq_t *this = calloc(1, sizeof(post_plugin_eq_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/planar/eq2.c b/src/post/planar/eq2.c
index 42f4580d9..c47270c2f 100644
--- a/src/post/planar/eq2.c
+++ b/src/post/planar/eq2.c
@@ -424,7 +424,7 @@ static post_plugin_t *eq2_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_eq2_t *this = (post_plugin_eq2_t *)xine_xmalloc(sizeof(post_plugin_eq2_t));
+ post_plugin_eq2_t *this = calloc(1, sizeof(post_plugin_eq2_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
@@ -439,26 +439,15 @@ static post_plugin_t *eq2_open_plugin(post_class_t *class_gen, int inputs,
_x_post_init(&this->post, 0, 1);
- eq2 = &this->eq2;
- for (i = 0; i < 3; i++) {
- eq2->buf[i] = NULL;
- eq2->buf_w[i] = 0;
- eq2->buf_h[i] = 0;
-
- eq2->param[i].adjust = NULL;
- eq2->param[i].c = 1.0;
- eq2->param[i].b = 0.0;
- eq2->param[i].g = 1.0;
- eq2->param[i].lut_clean = 0;
- }
+ memset(&this->eq2, 0, sizeof(this->eq2));
- eq2->gamma = this->params.gamma = 1.0;
- eq2->contrast = this->params.contrast = 1.0;
- eq2->brightness = this->params.brightness = 0.0;
- eq2->saturation = this->params.saturation = 1.0;
- eq2->rgamma = this->params.rgamma = 1.0;
- eq2->ggamma = this->params.ggamma = 1.0;
- eq2->bgamma = this->params.bgamma = 1.0;
+ this->eq2.gamma = this->params.gamma = 1.0;
+ this->eq2.contrast = this->params.contrast = 1.0;
+ this->eq2.brightness = this->params.brightness = 0.0;
+ this->eq2.saturation = this->params.saturation = 1.0;
+ this->eq2.rgamma = this->params.rgamma = 1.0;
+ this->eq2.ggamma = this->params.ggamma = 1.0;
+ this->eq2.bgamma = this->params.bgamma = 1.0;
pthread_mutex_init(&this->lock, NULL);
diff --git a/src/post/planar/expand.c b/src/post/planar/expand.c
index 90547163f..3cecaf47d 100644
--- a/src/post/planar/expand.c
+++ b/src/post/planar/expand.c
@@ -145,7 +145,7 @@ static post_plugin_t *expand_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_expand_t *this = (post_expand_t *)xine_xmalloc(sizeof(post_expand_t));
+ post_expand_t *this = calloc(1, sizeof(post_expand_t));
post_in_t *input;
xine_post_in_t *input_param;
post_out_t *output;
diff --git a/src/post/planar/fill.c b/src/post/planar/fill.c
index 6dd5ce23b..5aacfd679 100644
--- a/src/post/planar/fill.c
+++ b/src/post/planar/fill.c
@@ -63,7 +63,7 @@ static post_plugin_t *fill_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_t *this = (post_plugin_t *)xine_xmalloc(sizeof(post_plugin_t));
+ post_plugin_t *this = calloc(1, sizeof(post_plugin_t));
post_in_t *input;
post_out_t *output;
post_video_port_t *port;
diff --git a/src/post/planar/invert.c b/src/post/planar/invert.c
index 8c1b6103a..17f237fd7 100644
--- a/src/post/planar/invert.c
+++ b/src/post/planar/invert.c
@@ -64,7 +64,7 @@ static post_plugin_t *invert_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_t *this = (post_plugin_t *)xine_xmalloc(sizeof(post_plugin_t));
+ post_plugin_t *this = calloc(1, sizeof(post_plugin_t));
post_in_t *input;
post_out_t *output;
post_video_port_t *port;
diff --git a/src/post/planar/noise.c b/src/post/planar/noise.c
index e7a7c3d32..8bceb2f74 100644
--- a/src/post/planar/noise.c
+++ b/src/post/planar/noise.c
@@ -466,7 +466,7 @@ static post_plugin_t *noise_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_noise_t *this = (post_plugin_noise_t *)xine_xmalloc(sizeof(post_plugin_noise_t));
+ post_plugin_noise_t *this = calloc(1, sizeof(post_plugin_noise_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/planar/pp.c b/src/post/planar/pp.c
index c39db87cd..25447683a 100644
--- a/src/post/planar/pp.c
+++ b/src/post/planar/pp.c
@@ -20,6 +20,10 @@
* plugin for ffmpeg libpostprocess
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <config.h>
#include <xine/xine_internal.h>
@@ -163,7 +167,7 @@ static post_plugin_t *pp_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_pp_t *this = (post_plugin_pp_t *)xine_xmalloc(sizeof(post_plugin_pp_t));
+ post_plugin_pp_t *this = calloc(1, sizeof(post_plugin_pp_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/planar/unsharp.c b/src/post/planar/unsharp.c
index 591f32a7b..2f8b74496 100644
--- a/src/post/planar/unsharp.c
+++ b/src/post/planar/unsharp.c
@@ -26,13 +26,6 @@
#include <xine/xineutils.h>
#include <pthread.h>
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef MAX
-#define MAX(a,b) (((a)>(b))?(a):(b))
-#endif
-
/*===========================================================================*/
#define MIN_MATRIX_SIZE 3
@@ -284,7 +277,7 @@ static post_plugin_t *unsharp_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_unsharp_t *this = (post_plugin_unsharp_t *)xine_xmalloc(sizeof(post_plugin_unsharp_t));
+ post_plugin_unsharp_t *this = calloc(1, sizeof(post_plugin_unsharp_t));
post_in_t *input;
xine_post_in_t *input_api;
post_out_t *output;
diff --git a/src/post/visualizations/fftgraph.c b/src/post/visualizations/fftgraph.c
index 39d17c730..b881b9bec 100644
--- a/src/post/visualizations/fftgraph.c
+++ b/src/post/visualizations/fftgraph.c
@@ -415,7 +415,7 @@ static post_plugin_t *fftgraph_open_plugin(post_class_t *class_gen, int inputs,
xine_video_port_t **video_target)
{
post_class_fftgraph_t *class = (post_class_fftgraph_t *)class_gen;
- post_plugin_fftgraph_t *this = (post_plugin_fftgraph_t *)xine_xmalloc(sizeof(post_plugin_fftgraph_t));
+ post_plugin_fftgraph_t *this = calloc(1, sizeof(post_plugin_fftgraph_t));
post_in_t *input;
post_out_t *output;
post_out_t *outputv;
diff --git a/src/post/visualizations/fftscope.c b/src/post/visualizations/fftscope.c
index 1a9ea905a..eca2e2f93 100644
--- a/src/post/visualizations/fftscope.c
+++ b/src/post/visualizations/fftscope.c
@@ -435,7 +435,7 @@ static post_plugin_t *fftscope_open_plugin(post_class_t *class_gen, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target)
{
- post_plugin_fftscope_t *this = (post_plugin_fftscope_t *)xine_xmalloc(sizeof(post_plugin_fftscope_t));
+ post_plugin_fftscope_t *this = calloc(1, sizeof(post_plugin_fftscope_t));
post_class_fftscope_t *class = (post_class_fftscope_t *)class_gen;
post_in_t *input;
post_out_t *output;
diff --git a/src/post/visualizations/fooviz.c b/src/post/visualizations/fooviz.c
index 3e5702168..722ae9f7c 100644
--- a/src/post/visualizations/fooviz.c
+++ b/src/post/visualizations/fooviz.c
@@ -247,7 +247,7 @@ static post_plugin_t *fooviz_open_plugin(post_class_t *class_gen, int inputs,
xine_video_port_t **video_target)
{
post_class_fooviz_t *class = (post_class_fooviz_t *)class_gen;
- post_plugin_fooviz_t *this = (post_plugin_fooviz_t *)xine_xmalloc(sizeof(post_plugin_fooviz_t));
+ post_plugin_fooviz_t *this = calloc(1, sizeof(post_plugin_fooviz_t));
post_in_t *input;
post_out_t *output;
post_out_t *outputv;
diff --git a/src/post/visualizations/oscope.c b/src/post/visualizations/oscope.c
index 7c9faeeaa..3e783cce7 100644
--- a/src/post/visualizations/oscope.c
+++ b/src/post/visualizations/oscope.c
@@ -318,7 +318,7 @@ static post_plugin_t *oscope_open_plugin(post_class_t *class_gen, int inputs,
xine_video_port_t **video_target)
{
post_class_oscope_t *class = (post_class_oscope_t *)class_gen;
- post_plugin_oscope_t *this = (post_plugin_oscope_t *)xine_xmalloc(sizeof(post_plugin_oscope_t));
+ post_plugin_oscope_t *this = calloc(1, sizeof(post_plugin_oscope_t));
post_in_t *input;
post_out_t *output;
post_out_t *outputv;
diff --git a/src/spu_dec/cc_decoder.c b/src/spu_dec/cc_decoder.c
index c0e0e4930..7c6504f1a 100644
--- a/src/spu_dec/cc_decoder.c
+++ b/src/spu_dec/cc_decoder.c
@@ -216,8 +216,6 @@ static const uint8_t *const cc_alpha_palettes[NUM_CC_PALETTES] = {
#define TRANSP_SPACE 0x19 /* code for transparent space, essentially
arbitrary */
-#define MAX(a, b) ((a) > (b)? (a) : (b))
-
/* mapping from PAC row code to actual CC row */
static const int rowdata[] = {10, -1, 0, 1, 2, 3, 11, 12, 13, 14, 4, 5, 6,
7, 8, 9};
@@ -963,7 +961,7 @@ cc_renderer_t *cc_renderer_open(osd_renderer_t *osd_renderer,
metronom_t *metronom, cc_state_t *cc_state,
int video_width, int video_height)
{
- cc_renderer_t *this = (cc_renderer_t *) xine_xmalloc(sizeof (cc_renderer_t));
+ cc_renderer_t *this = calloc(1, sizeof (cc_renderer_t));
this->osd_renderer = osd_renderer;
this->metronom = metronom;
@@ -1480,7 +1478,7 @@ void decode_cc(cc_decoder_t *this, uint8_t *buffer, uint32_t buf_len,
cc_decoder_t *cc_decoder_open(cc_state_t *cc_state)
{
- cc_decoder_t *this = (cc_decoder_t *) xine_xmalloc(sizeof (cc_decoder_t));
+ cc_decoder_t *this = calloc(1, sizeof (cc_decoder_t));
/* configfile stuff */
this->cc_state = cc_state;
diff --git a/src/spu_dec/cmml_decoder.c b/src/spu_dec/cmml_decoder.c
index e63dc561d..4dea5645f 100644
--- a/src/spu_dec/cmml_decoder.c
+++ b/src/spu_dec/cmml_decoder.c
@@ -268,36 +268,30 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
for (title_node = packet_xml_root->child; title_node != NULL; title_node = title_node->next) {
- if (strcasecmp (title_node->name, "title") == 0) {
+ if (title_node->data &&
+ strcasecmp (title_node->name, "title") == 0) {
/* found a title node */
- xine_event_t uevent;
- char *title;
- int title_len;
-
- title = title_node->data;
-
- if (title)
- {
- xine_ui_data_t data;
- /* found a non-empty title */
- lprintf ("found title: \"%s\"\n", title);
-
- /* set xine meta-info */
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, strdup(title));
-
- /* and push out a new event signifying the title update on the event
- * queue */
- title_len = strlen(title) + 1;
- memcpy(data.str, title, title_len);
- data.str_len = title_len;
-
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);
- xine_event_send(this->stream, &uevent);
- }
+ xine_ui_data_t data = {
+ .str_len = strlen(title_node->data) + 1
+ };
+ xine_event_t uevent = {
+ .type = XINE_EVENT_UI_SET_TITLE,
+ .stream = this->stream,
+ .data = &data,
+ .data_length = sizeof(data),
+ };
+ strncpy(data.str, title_node->data, sizeof(data.str)-1);
+
+ /* found a non-empty title */
+ lprintf ("found title: \"%s\"\n", data.str);
+
+ /* set xine meta-info */
+ _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, strdup(data.str));
+
+ /* and push out a new event signifying the title update on the event
+ * queue */
+ xine_event_send(this->stream, &uevent);
}
}
} else if (strcasecmp(packet_xml_root->name, "clip") == 0) {
@@ -450,7 +444,7 @@ static spu_decoder_t *spucmml_class_open_plugin (spu_decoder_class_t *class_gen,
spucmml_class_t *class = (spucmml_class_t *)class_gen;
spucmml_decoder_t *this ;
- this = (spucmml_decoder_t *) xine_xmalloc (sizeof (spucmml_decoder_t));
+ this = (spucmml_decoder_t *) calloc(1, sizeof(spucmml_decoder_t));
this->spu_decoder.decode_data = spudec_decode_data;
this->spu_decoder.reset = spudec_reset;
@@ -502,7 +496,7 @@ static void *init_spu_decoder_plugin (xine_t *xine, void *data) {
spucmml_class_t *this ;
- this = (spucmml_class_t *) xine_xmalloc (sizeof (spucmml_class_t));
+ this = (spucmml_class_t *) calloc(1, sizeof(spucmml_class_t));
this->class.open_plugin = spucmml_class_open_plugin;
this->class.identifier = "spucmml";
diff --git a/src/spu_dec/spu_decoder.c b/src/spu_dec/spu_decoder.c
index c4cf3ae78..a2c0a8827 100644
--- a/src/spu_dec/spu_decoder.c
+++ b/src/spu_dec/spu_decoder.c
@@ -228,9 +228,9 @@ static void spudec_set_button (spu_decoder_t *this_gen, int32_t button, int32_t
video_overlay_manager_t *ovl_manager;
video_overlay_event_t *overlay_event = NULL;
vo_overlay_t *overlay = NULL;
- overlay_event = xine_xmalloc (sizeof(video_overlay_event_t));
+ overlay_event = calloc(1, sizeof(video_overlay_event_t));
- overlay = xine_xmalloc (sizeof(vo_overlay_t));
+ overlay = calloc(1, sizeof(vo_overlay_t));
/* FIXME: Watch out for threads. We should really put a lock on this
* because events is a different thread than decode_data */
@@ -316,7 +316,7 @@ static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t
spudec_decoder_t *this ;
int i;
- this = (spudec_decoder_t *) xine_xmalloc (sizeof (spudec_decoder_t));
+ this = (spudec_decoder_t *) calloc(1, sizeof (spudec_decoder_t));
this->spu_decoder.decode_data = spudec_decode_data;
this->spu_decoder.reset = spudec_reset;
@@ -329,7 +329,7 @@ static spu_decoder_t *open_plugin (spu_decoder_class_t *class_gen, xine_stream_t
this->menu_handle = -1;
this->buttonN = 1;
- this->event.object.overlay = xine_xmalloc(sizeof(vo_overlay_t));
+ this->event.object.overlay = calloc(1, sizeof(vo_overlay_t));
pthread_mutex_init(&this->nav_pci_lock, NULL);
this->pci_cur.pci.hli.hl_gi.hli_ss = 0;
@@ -355,7 +355,7 @@ static void *init_plugin (xine_t *xine, void *data) {
spudec_class_t *this;
- this = (spudec_class_t *) xine_xmalloc (sizeof (spudec_class_t));
+ this = calloc(1, sizeof (spudec_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "spudec";
diff --git a/src/spu_dec/spudec.c b/src/spu_dec/spudec.c
index 3e8cd8a07..95f969aa7 100644
--- a/src/spu_dec/spudec.c
+++ b/src/spu_dec/spudec.c
@@ -209,7 +209,7 @@ void spudec_decode_nav(spudec_decoder_t *this, buf_element_t *buf) {
#endif
/* append PCI at the end of the list */
while (node->next) node = node->next;
- node->next = (pci_node_t *)xine_xmalloc(sizeof(pci_node_t));
+ node->next = malloc(sizeof(pci_node_t));
node->next->vpts = this->stream->metronom->got_spu_packet(this->stream->metronom, pci.hli.hl_gi.hli_s_ptm);
node->next->next = NULL;
xine_fast_memcpy(&node->next->pci, &pci, sizeof(pci_t));
diff --git a/src/spu_dec/spudvb_decoder.c b/src/spu_dec/spudvb_decoder.c
index 331c9835d..ee4b0142d 100644
--- a/src/spu_dec/spudvb_decoder.c
+++ b/src/spu_dec/spudvb_decoder.c
@@ -921,7 +921,7 @@ static spu_decoder_t *dvb_spu_class_open_plugin (spu_decoder_class_t * class_gen
dvb_spu_decoder_t *this;
dvb_spu_class_t *class = (dvb_spu_class_t *) class_gen;
- this = (dvb_spu_decoder_t *) xine_xmalloc (sizeof (dvb_spu_decoder_t));
+ this = calloc(1, sizeof (dvb_spu_decoder_t));
this->spu_decoder.decode_data = spudec_decode_data;
this->spu_decoder.reset = spudec_reset;
@@ -933,10 +933,10 @@ static spu_decoder_t *dvb_spu_class_open_plugin (spu_decoder_class_t * class_gen
this->class = class;
this->stream = stream;
- this->pes_pkt = xine_xmalloc (1024*65);
- this->spu_descriptor = xine_xmalloc(sizeof(spu_dvb_descriptor_t));
+ this->pes_pkt = calloc(65, 1024);
+ this->spu_descriptor = calloc(1, sizeof(spu_dvb_descriptor_t));
- this->dvbsub = xine_xmalloc (sizeof (dvbsub_func_t));
+ this->dvbsub = calloc(1, sizeof (dvbsub_func_t));
for (i = 0; i < MAX_REGIONS; i++) {
this->dvbsub->page.regions[i].is_visible = 0;
@@ -970,7 +970,7 @@ static void *init_spu_decoder_plugin (xine_t * xine, void *data)
{
dvb_spu_class_t *this;
- this = (dvb_spu_class_t *) xine_xmalloc (sizeof (dvb_spu_class_t));
+ this = calloc(1, sizeof (dvb_spu_class_t));
this->class.open_plugin = dvb_spu_class_open_plugin;
this->class.identifier = "spudvb";
diff --git a/src/spu_dec/sputext_decoder.c b/src/spu_dec/sputext_decoder.c
index 0cc0ee21b..615910275 100644
--- a/src/spu_dec/sputext_decoder.c
+++ b/src/spu_dec/sputext_decoder.c
@@ -644,7 +644,7 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su
buf[0] = 0;
for(line = 0; line < this->lines; line++) {
- int len = strlen(buf);
+ size_t len = strlen(buf);
if (len) {
buf[len] = ' ';
len++;
@@ -1082,7 +1082,7 @@ static spu_decoder_t *sputext_class_open_plugin (spu_decoder_class_t *class_gen,
sputext_class_t *class = (sputext_class_t *)class_gen;
sputext_decoder_t *this ;
- this = (sputext_decoder_t *) xine_xmalloc (sizeof (sputext_decoder_t));
+ this = (sputext_decoder_t *) calloc(1, sizeof(sputext_decoder_t));
this->spu_decoder.decode_data = spudec_decode_data;
this->spu_decoder.reset = spudec_reset;
@@ -1128,7 +1128,7 @@ static void *init_spu_decoder_plugin (xine_t *xine, void *data) {
lprintf("init class\n");
- this = (sputext_class_t *) xine_xmalloc (sizeof (sputext_class_t));
+ this = (sputext_class_t *) calloc(1, sizeof(sputext_class_t));
this->class.open_plugin = sputext_class_open_plugin;
this->class.identifier = "sputext";
diff --git a/src/spu_dec/sputext_demuxer.c b/src/spu_dec/sputext_demuxer.c
index d7d1361b1..fe259381c 100644
--- a/src/spu_dec/sputext_demuxer.c
+++ b/src/spu_dec/sputext_demuxer.c
@@ -129,7 +129,6 @@ static int eol(char p) {
}
static inline void trail_space(char *s) {
- int i;
while (isspace(*s)) {
char *copy = s;
do {
@@ -137,7 +136,7 @@ static inline void trail_space(char *s) {
copy++;
} while(*copy);
}
- i = strlen(s) - 1;
+ size_t i = strlen(s) - 1;
while (i > 0 && isspace(s[i]))
s[i--] = '\0';
}
@@ -262,12 +261,7 @@ static char *sub_readtext(char *source, char **dest) {
p++,len++;
}
- *dest= (char *)xine_xmalloc (len+1);
- if (!dest)
- return ERR;
-
- strncpy(*dest, source, len);
- (*dest)[len]=0;
+ *dest = strndup(source, len);
while (*p=='\r' || *p=='\n' || *p=='|')
p++;
@@ -333,10 +327,8 @@ static subtitle_t *sub_read_line_subviewer(demux_sputext_t *this, subtitle_t *cu
p=q=line;
for (current->lines=1; current->lines <= SUB_MAX_TEXT; current->lines++) {
for (q=p,len=0; *p && *p!='\r' && *p!='\n' && *p!='|' && strncasecmp(p,"[br]",4); p++,len++);
- current->text[current->lines-1]=(char *)xine_xmalloc (len+1);
+ current->text[current->lines-1] = strndup(q, len);
if (!current->text[current->lines-1]) return ERR;
- strncpy (current->text[current->lines-1], q, len);
- current->text[current->lines-1][len]='\0';
if (!*p || *p=='\r' || *p=='\n') break;
if (*p=='[') while (*p++!=']');
if (*p=='|') p++;
@@ -396,10 +388,10 @@ static subtitle_t *sub_read_line_subrip(demux_sputext_t *this,subtitle_t *curren
xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "Too many characters in a subtitle line\n");
if(temp_line[temp_index-1]=='\0' || temp_index==SUB_BUFSIZE) {
if(temp_index>1) { /* more than 1 char (including '\0') -> that is a valid one */
- current->text[i]=(char *)xine_xmalloc(temp_index);
+ /* temp_index<=SUB_BUFSIZE is always true here */
+ current->text[i] = strndup(temp_line, temp_index);
if(!current->text[i])
return ERR;
- strncpy(current->text[i],temp_line,temp_index); /* temp_index<=SUB_BUFSIZE is always true here */
i++;
temp_index=0;
} else
@@ -544,6 +536,8 @@ static subtitle_t *sub_read_line_ssa(demux_sputext_t *this,subtitle_t *current)
line3) < 9 );
line2=strchr(line3, ',');
+ if (!line2)
+ return NULL;
for (comma = 4; comma < max_comma; comma ++)
{
@@ -563,9 +557,7 @@ static subtitle_t *sub_read_line_ssa(demux_sputext_t *this,subtitle_t *current)
current->end = 360000*hour2 + 6000*min2 + 100*sec2 + hunsec2;
while (((tmp=strstr(line2, "\\n")) != NULL) || ((tmp=strstr(line2, "\\N")) != NULL) ){
- current->text[num]=(char *)malloc(tmp-line2+1);
- strncpy (current->text[num], line2, tmp-line2);
- current->text[num][tmp-line2]='\0';
+ current->text[num] = strndup(line2, tmp-line2);
line2=tmp+2;
num++;
current->lines++;
@@ -895,7 +887,10 @@ static subtitle_t *sub_read_line_jacobsub(demux_sputext_t *this, subtitle_t *cur
}
}
*q = '\0';
- current->text[current->lines] = strdup(line1);
+ if (current->lines < SUB_MAX_TEXT)
+ current->text[current->lines] = strdup(line1);
+ else
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "Too many lines in a subtitle\n");
}
current->lines++;
return current;
@@ -920,10 +915,9 @@ static subtitle_t *sub_read_line_subviewer2(demux_sputext_t *this, subtitle_t *c
len=0;
for (p=line; *p!='\n' && *p!='\r' && *p; ++p,++len);
if (len) {
- current->text[i]=(char *)malloc (len+1);
- if (!current->text[i]) return ERR;
- strncpy (current->text[i], line, len); current->text[i][len]='\0';
- ++i;
+ current->text[i] = strndup(line, len);
+ if (!current->text[i]) return ERR;
+ ++i;
} else {
break;
}
@@ -1155,7 +1149,7 @@ static subtitle_t *sub_read_file (demux_sputext_t *this) {
this->buflen = 0;
this->num=0;n_max=32;
- first = (subtitle_t *) xine_xmalloc(n_max*sizeof(subtitle_t));
+ first = calloc(n_max, sizeof(subtitle_t));
if(!first) return NULL;
timeout = ((demux_sputext_class_t *)
(this->demux_plugin.demux_class))->max_timeout;
@@ -1240,9 +1234,8 @@ static int demux_sputext_next (demux_sputext_t *this_gen) {
*val++ = (this->uses_time) ? sub->end * 10 : sub->end;
str = (char *)val;
for (line = 0; line < sub->lines; line++, str+=strlen(str)+1) {
- if( strlen(sub->text[line]) > SUB_BUFSIZE )
- sub->text[line][SUB_BUFSIZE] = '\0';
- strcpy(str, sub->text[line]);
+ strncpy(str, sub->text[line], SUB_BUFSIZE-1);
+ str[SUB_BUFSIZE-1] = '\0';
}
this->stream->video_fifo->put(this->stream->video_fifo, buf);
@@ -1353,7 +1346,7 @@ static demux_plugin_t *open_demux_plugin (demux_class_t *class_gen, xine_stream_
lprintf("open_plugin() called\n");
- this = xine_xmalloc (sizeof (demux_sputext_t));
+ this = calloc(1, sizeof (demux_sputext_t));
this->stream = stream;
this->input = input;
@@ -1430,7 +1423,7 @@ void *init_sputext_demux_class (xine_t *xine, void *data) {
lprintf("initializing\n");
- this = xine_xmalloc (sizeof (demux_sputext_class_t));
+ this = calloc(1, sizeof (demux_sputext_class_t));
this->demux_class.open_plugin = open_demux_plugin;
this->demux_class.description = N_("sputext demuxer plugin");
diff --git a/src/spu_dec/xine_cc_decoder.c b/src/spu_dec/xine_cc_decoder.c
index 9b177deeb..31ca5413b 100644
--- a/src/spu_dec/xine_cc_decoder.c
+++ b/src/spu_dec/xine_cc_decoder.c
@@ -301,7 +301,7 @@ static spu_decoder_t *spudec_open_plugin (spu_decoder_class_t *class, xine_strea
spucc_decoder_t *this ;
- this = (spucc_decoder_t *) xine_xmalloc (sizeof (spucc_decoder_t));
+ this = (spucc_decoder_t *) calloc(1, sizeof(spucc_decoder_t));
this->spu_decoder.decode_data = spudec_decode_data;
this->spu_decoder.reset = spudec_reset;
@@ -323,7 +323,7 @@ static void *init_spu_decoder_plugin (xine_t *xine, void *data) {
spucc_class_t *this ;
- this = (spucc_class_t *) xine_xmalloc (sizeof (spucc_class_t));
+ this = (spucc_class_t *) calloc(1, sizeof(spucc_class_t));
this->spu_class.open_plugin = spudec_open_plugin;
this->spu_class.identifier = "spucc";
diff --git a/src/vdr/input_vdr.c b/src/vdr/input_vdr.c
index ade2ecfa1..6927ed255 100644
--- a/src/vdr/input_vdr.c
+++ b/src/vdr/input_vdr.c
@@ -701,7 +701,6 @@ fprintf(stderr, "--- CLEAR(%d%c)\n", data->n, data->s ? 'b' : 'a');
if (this->trick_speed_mode != data->on)
{
-fprintf(stderr, "ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß\n");
this->trick_speed_mode = data->on;
_x_demux_seek(this->stream, 0, 0, 0);
@@ -964,53 +963,47 @@ fprintf(stderr, "ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß\n");
READ_DATA_OR_FAIL(grab_image, lprintf("got GRABIMAGE\n"));
{
- off_t ret_val = -1;
-
- uint8_t *img = 0;
- int frame_size = 0;
- int width = 0;
- int height = 0;
- int ratio_code = 0;
- int format = 0;
+ off_t ret_val = -1;
+ xine_current_frame_data_t frame;
- if (xine_get_current_frame_alloc(this->stream, &width, &height, &ratio_code, &format, &img, &frame_size))
+ if (xine_get_current_frame_data(this->stream, &frame, XINE_FRAME_DATA_ALLOCATE_IMG))
{
- if (ratio_code == XINE_VO_ASPECT_SQUARE)
- ratio_code = 10000;
- else if (ratio_code == XINE_VO_ASPECT_4_3)
- ratio_code = 13333;
- else if (ratio_code == XINE_VO_ASPECT_ANAMORPHIC)
- ratio_code = 17778;
- else if (ratio_code == XINE_VO_ASPECT_DVB)
- ratio_code = 21100;
+ if (frame.ratio_code == XINE_VO_ASPECT_SQUARE)
+ frame.ratio_code = 10000;
+ else if (frame.ratio_code == XINE_VO_ASPECT_4_3)
+ frame.ratio_code = 13333;
+ else if (frame.ratio_code == XINE_VO_ASPECT_ANAMORPHIC)
+ frame.ratio_code = 17778;
+ else if (frame.ratio_code == XINE_VO_ASPECT_DVB)
+ frame.ratio_code = 21100;
}
- if (!img)
+ if (!frame.img)
{
- frame_size = 0,
- width = 0;
- height = 0;
- ratio_code = 0;
+ frame.img_size = 0,
+ frame.width = 0;
+ frame.height = 0;
+ frame.ratio_code = 0;
}
{
result_grab_image_t result_grab_image;
result_grab_image.header.func = data->header.func;
- result_grab_image.header.len = sizeof (result_grab_image) + frame_size;
+ result_grab_image.header.len = sizeof (result_grab_image) + frame.img_size;
- result_grab_image.width = width;
- result_grab_image.height = height;
- result_grab_image.ratio = ratio_code;
- result_grab_image.format = format;
+ result_grab_image.width = frame.width;
+ result_grab_image.height = frame.height;
+ result_grab_image.ratio = frame.ratio_code;
+ result_grab_image.format = frame.format;
if (sizeof (result_grab_image) == vdr_write(this->fh_result, &result_grab_image, sizeof (result_grab_image)))
{
- if (!frame_size || (frame_size == vdr_write(this->fh_result, img, frame_size)))
+ if (!frame.img_size || (frame.img_size == vdr_write(this->fh_result, frame.img, frame.img_size)))
ret_val = 0;
}
}
- free(img);
+ free(frame.img);
if (ret_val != 0)
return ret_val;
diff --git a/src/video_dec/bitplane.c b/src/video_dec/bitplane.c
index 327e14aee..811fe4dcf 100644
--- a/src/video_dec/bitplane.c
+++ b/src/video_dec/bitplane.c
@@ -252,7 +252,7 @@ static uint8_t *bitplane_decode_byterun1 (uint8_t *compressed,
int i = 0;
int j = 0;
- uint8_t *uncompressed = xine_xmalloc( size_uncompressed );
+ uint8_t *uncompressed = calloc(1, size_uncompressed );
while ( i < size_compressed &&
pixel_ptr < size_uncompressed ) {
@@ -1158,8 +1158,8 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
this->bytes_per_pixel = 1;
/* New Buffer for indexes (palette based formats) */
- this->index_buf = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
- this->index_buf_hist = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
+ this->index_buf = calloc( this->num_pixel, this->bytes_per_pixel );
+ this->index_buf_hist = calloc( this->num_pixel, this->bytes_per_pixel );
this->num_bitplanes = bih->biPlanes;
this->camg_mode = bih->biCompression;
@@ -1188,7 +1188,7 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
free (this->buf);
this->bufsize = VIDEOBUFSIZE;
- this->buf = xine_xmalloc(this->bufsize);
+ this->buf = calloc(1, this->bufsize);
this->size = 0;
this->framenumber = 0;
@@ -1254,7 +1254,7 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
case BUF_VIDEO_BITPLANE:
/* uncompressed Buffer, set decoded_buf pointer direct to input stream */
if( this->buf_uk == NULL )
- this->buf_uk = xine_xmalloc( (this->size) );
+ this->buf_uk = malloc(this->size);
xine_fast_memcpy (this->buf_uk, this->buf, this->size);
break;
case BUF_VIDEO_BITPLANE_BR1:
@@ -1293,7 +1293,7 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
}
}
if( this->buf_uk_hist == NULL ) {
- this->buf_uk_hist = xine_xmalloc( (this->size_uk) );
+ this->buf_uk_hist = malloc(this->size_uk);
xine_fast_memcpy (this->buf_uk_hist, this->buf_uk, this->size_uk);
xine_fast_memcpy (this->index_buf_hist, this->index_buf,
(this->num_pixel * this->bytes_per_pixel));
@@ -1305,20 +1305,12 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
/* when no start-picture is given, create a empty one */
if( this->buf_uk_hist == NULL ) {
this->size_uk = (((this->num_pixel) / 8) * this->num_bitplanes);
- this->buf_uk = xine_xmalloc( (this->size_uk) );
- this->buf_uk_hist = xine_xmalloc( (this->size_uk) );
- for (i = 0; i < this->size_uk; i++) {
- this->buf_uk[i] = 0;
- this->buf_uk_hist[i] = 0;
- }
+ this->buf_uk = calloc(this->num_bitplanes, ((this->num_pixel) / 8));
+ this->buf_uk_hist = calloc(this->num_bitplanes, ((this->num_pixel) / 8));
}
if( this->index_buf == NULL ) {
- this->index_buf = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
- this->index_buf_hist = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
- for (i = 0; i < (this->num_pixel * this->bytes_per_pixel); i++) {
- this->index_buf[i] = 0;
- this->index_buf_hist[i] = 0;
- }
+ this->index_buf = calloc( this->num_pixel, this->bytes_per_pixel );
+ this->index_buf_hist = calloc( this->num_pixel, this->bytes_per_pixel );
}
switch( anhd->operation ) {
@@ -1499,7 +1491,7 @@ static void bitplane_dispose (video_decoder_t *this_gen) {
static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
- bitplane_decoder_t *this = (bitplane_decoder_t *) xine_xmalloc (sizeof (bitplane_decoder_t));
+ bitplane_decoder_t *this = (bitplane_decoder_t *) calloc(1, sizeof(bitplane_decoder_t));
this->video_decoder.decode_data = bitplane_decode_data;
this->video_decoder.flush = bitplane_flush;
@@ -1522,7 +1514,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
static void *init_plugin (xine_t *xine, void *data) {
- bitplane_class_t *this = (bitplane_class_t *) xine_xmalloc (sizeof (bitplane_class_t));
+ bitplane_class_t *this = (bitplane_class_t *) calloc(1, sizeof(bitplane_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "bitplane";
diff --git a/src/video_dec/foovideo.c b/src/video_dec/foovideo.c
index 49c63422c..653f7eb47 100644
--- a/src/video_dec/foovideo.c
+++ b/src/video_dec/foovideo.c
@@ -202,7 +202,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
foovideo_decoder_t *this ;
- this = (foovideo_decoder_t *) xine_xmalloc (sizeof (foovideo_decoder_t));
+ this = (foovideo_decoder_t *) calloc(1, sizeof(foovideo_decoder_t));
this->video_decoder.decode_data = foovideo_decode_data;
this->video_decoder.flush = foovideo_flush;
@@ -236,7 +236,7 @@ static void *init_plugin (xine_t *xine, void *data) {
foovideo_class_t *this;
- this = (foovideo_class_t *) xine_xmalloc (sizeof (foovideo_class_t));
+ this = (foovideo_class_t *) calloc(1, sizeof(foovideo_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "foovideo";
diff --git a/src/video_dec/gdkpixbuf.c b/src/video_dec/gdkpixbuf.c
index 34644241d..01378acbc 100644
--- a/src/video_dec/gdkpixbuf.c
+++ b/src/video_dec/gdkpixbuf.c
@@ -236,7 +236,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
g_type_init ();
- this = (image_decoder_t *) xine_xmalloc (sizeof (image_decoder_t));
+ this = (image_decoder_t *) calloc(1, sizeof(image_decoder_t));
this->video_decoder.decode_data = image_decode_data;
this->video_decoder.flush = image_flush;
@@ -260,7 +260,7 @@ static void *init_class (xine_t *xine, void *data) {
image_class_t *this;
- this = (image_class_t *) xine_xmalloc (sizeof (image_class_t));
+ this = (image_class_t *) calloc(1, sizeof(image_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "gdkpixbuf";
diff --git a/src/video_dec/image.c b/src/video_dec/image.c
index 5c8439a67..f4d39b5dc 100644
--- a/src/video_dec/image.c
+++ b/src/video_dec/image.c
@@ -212,7 +212,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen,
lprintf("opened\n");
- this = (image_decoder_t *) xine_xmalloc (sizeof (image_decoder_t));
+ this = (image_decoder_t *) calloc(1, sizeof(image_decoder_t));
this->video_decoder.decode_data = image_decode_data;
this->video_decoder.flush = image_flush;
@@ -238,7 +238,7 @@ static void *init_class (xine_t *xine, void *data) {
image_class_t *this;
- this = (image_class_t *) xine_xmalloc (sizeof (image_class_t));
+ this = (image_class_t *) calloc(1, sizeof(image_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "imagevdec";
diff --git a/src/video_dec/libmpeg2/xine_mpeg2_decoder.c b/src/video_dec/libmpeg2/xine_mpeg2_decoder.c
index fc8bd4dc2..0419efa61 100644
--- a/src/video_dec/libmpeg2/xine_mpeg2_decoder.c
+++ b/src/video_dec/libmpeg2/xine_mpeg2_decoder.c
@@ -117,7 +117,7 @@ static void mpeg2dec_dispose (video_decoder_t *this_gen) {
static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stream_t *stream) {
mpeg2dec_decoder_t *this ;
- this = (mpeg2dec_decoder_t *) xine_xmalloc (sizeof (mpeg2dec_decoder_t));
+ this = (mpeg2dec_decoder_t *) calloc(1, sizeof(mpeg2dec_decoder_t));
this->video_decoder.decode_data = mpeg2dec_decode_data;
this->video_decoder.flush = mpeg2dec_flush;
@@ -142,7 +142,7 @@ static void *init_plugin (xine_t *xine, void *data) {
mpeg2_class_t *this;
- this = (mpeg2_class_t *) xine_xmalloc (sizeof (mpeg2_class_t));
+ this = (mpeg2_class_t *) calloc(1, sizeof(mpeg2_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "mpeg2dec";
diff --git a/src/video_dec/rgb.c b/src/video_dec/rgb.c
index 9c8409e5f..9f3dd279c 100644
--- a/src/video_dec/rgb.c
+++ b/src/video_dec/rgb.c
@@ -144,7 +144,7 @@ static void rgb_decode_data (video_decoder_t *this_gen,
/* minimal buffer size */
this->bufsize = this->width * this->height * this->bytes_per_pixel;
- this->buf = xine_xmalloc(this->bufsize);
+ this->buf = calloc(1, this->bufsize);
this->size = 0;
init_yuv_planes(&this->yuv_planes, this->width, this->height);
@@ -394,7 +394,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
rgb_decoder_t *this ;
- this = (rgb_decoder_t *) xine_xmalloc (sizeof (rgb_decoder_t));
+ this = (rgb_decoder_t *) calloc(1, sizeof(rgb_decoder_t));
this->video_decoder.decode_data = rgb_decode_data;
this->video_decoder.flush = rgb_flush;
@@ -416,7 +416,7 @@ static void *init_plugin (xine_t *xine, void *data) {
rgb_class_t *this;
- this = (rgb_class_t *) xine_xmalloc (sizeof (rgb_class_t));
+ this = (rgb_class_t *) calloc(1, sizeof(rgb_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "RGB";
diff --git a/src/video_dec/yuv.c b/src/video_dec/yuv.c
index c1e5825c5..323a1648f 100644
--- a/src/video_dec/yuv.c
+++ b/src/video_dec/yuv.c
@@ -316,7 +316,7 @@ static video_decoder_t *open_plugin (video_decoder_class_t *class_gen, xine_stre
yuv_decoder_t *this ;
- this = (yuv_decoder_t *) xine_xmalloc (sizeof (yuv_decoder_t));
+ this = (yuv_decoder_t *) calloc(1, sizeof(yuv_decoder_t));
this->video_decoder.decode_data = yuv_decode_data;
this->video_decoder.flush = yuv_flush;
@@ -338,7 +338,7 @@ static void *init_plugin (xine_t *xine, void *data) {
yuv_class_t *this;
- this = (yuv_class_t *) xine_xmalloc (sizeof (yuv_class_t));
+ this = (yuv_class_t *) calloc(1, sizeof(yuv_class_t));
this->decoder_class.open_plugin = open_plugin;
this->decoder_class.identifier = "YUV";
diff --git a/src/video_out/Makefile.am b/src/video_out/Makefile.am
index 062c7aa68..671e9f0ca 100644
--- a/src/video_out/Makefile.am
+++ b/src/video_out/Makefile.am
@@ -108,6 +108,7 @@ xineplug_LTLIBRARIES = $(xshm_module) $(xv_module) $(xvmc_module) \
$(xxmc_module) \
$(xcbshm_module) \
$(xcbxv_module) \
+ xineplug_vo_out_raw.la \
xineplug_vo_out_none.la
xineplug_vo_out_xcbshm_la_SOURCES = video_out_xcbshm.c $(XCBOSD)
@@ -182,7 +183,7 @@ xineplug_vo_out_sdl_la_SOURCES = video_out_sdl.c
xineplug_vo_out_sdl_la_LIBADD = $(XINE_LIB) $(SDL_LIBS) $(X_LIBS) $(PTHREAD_LIBS) $(LTLIBINTL)
xineplug_vo_out_sdl_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS) $(SDL_CFLAGS)
-xineplug_vo_out_stk_la_SOURCES = video_out_stk.c
+xineplug_vo_out_stk_la_SOURCES = video_out_stk.c
xineplug_vo_out_stk_la_LIBADD = $(XINE_LIB) $(LIBSTK_LIBS) $(PTHREAD_LIBS)
xineplug_vo_out_stk_la_CFLAGS = $(AM_CFLAGS) $(LIBSTK_CFLAGS)
@@ -193,6 +194,10 @@ xineplug_vo_out_directx_la_CPPFLAGS = $(AM_CPPFLAGS) $(DIRECTX_CPPFLAGS)
xineplug_vo_out_none_la_SOURCES = video_out_none.c
xineplug_vo_out_none_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL)
+xineplug_vo_out_raw_la_SOURCES = video_out_raw.c
+xineplug_vo_out_raw_la_LIBADD = libyuv2rgb.la $(XINE_LIB) $(PTHREAD_LIBS) $(LTLIBINTL) $(AVUTIL_LIBS)
+xineplug_vo_out_raw_la_CFLAGS = $(AM_CFLAGS) $(AVUTIL_CFLAGS)
+
xineplug_vo_out_macosx_la_SOURCES = video_out_macosx.m
xineplug_vo_out_macosx_la_LIBADD = $(XINE_LIB) $(PTHREAD_LIBS)
xineplug_vo_out_macosx_la_LDFLAGS = $(AM_LDFLAGS) -framework Cocoa -framework OpenGL
diff --git a/src/video_out/video_out_aa.c b/src/video_out/video_out_aa.c
index 3429e883f..7c021a090 100644
--- a/src/video_out/video_out_aa.c
+++ b/src/video_out/video_out_aa.c
@@ -104,7 +104,7 @@ static vo_frame_t *aa_alloc_frame(vo_driver_t *this_gen) {
/* aa_driver_t *this = (aa_driver_t*) this_gen; */
aa_frame_t *frame;
- frame = (aa_frame_t *) xine_xmalloc (sizeof (aa_frame_t));
+ frame = calloc(1, sizeof (aa_frame_t));
if (!frame)
return NULL;
@@ -264,7 +264,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
aa_class_t *class = (aa_class_t *) class_gen;
aa_driver_t *this;
- this = (aa_driver_t*) xine_xmalloc (sizeof (aa_driver_t));
+ this = (aa_driver_t*) calloc(1, sizeof(aa_driver_t));
this->context = (aa_context*) visual_gen;
@@ -292,7 +292,7 @@ static void *init_class (xine_t *xine, void *visual_gen) {
/* aa_context *context = (aa_context*) visual_gen; */
aa_class_t *this;
- this = (aa_class_t *) xine_xmalloc(sizeof(aa_class_t));
+ this = calloc(1, sizeof(aa_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "AA";
diff --git a/src/video_out/video_out_caca.c b/src/video_out/video_out_caca.c
index 01aad0bc8..60552764f 100644
--- a/src/video_out/video_out_caca.c
+++ b/src/video_out/video_out_caca.c
@@ -117,7 +117,7 @@ static vo_frame_t *caca_alloc_frame(vo_driver_t *this_gen) {
caca_driver_t *this = (caca_driver_t*) this_gen;
caca_frame_t *frame;
- frame = (caca_frame_t *) xine_xmalloc (sizeof (caca_frame_t));
+ frame = calloc(1, sizeof (caca_frame_t));
if (!frame)
return NULL;
@@ -260,7 +260,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
caca_class_t *class = (caca_class_t *) class_gen;
caca_driver_t *this;
- this = (caca_driver_t*) xine_xmalloc (sizeof (caca_driver_t));
+ this = calloc(1, sizeof (caca_driver_t));
this->config = class->config;
this->xine = class->xine;
@@ -292,7 +292,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
static void *init_class (xine_t *xine, void *visual_gen) {
caca_class_t *this;
- this = (caca_class_t *) xine_xmalloc(sizeof(caca_class_t));
+ this = calloc(1, sizeof(caca_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "CACA";
diff --git a/src/video_out/video_out_directfb.c b/src/video_out/video_out_directfb.c
index fecc2c5b0..18df07f76 100644
--- a/src/video_out/video_out_directfb.c
+++ b/src/video_out/video_out_directfb.c
@@ -168,10 +168,6 @@ typedef struct {
"no-deinit-check"
-#ifndef MAX
-# define MAX( a, b ) (((a) > (b)) ? (a) : (b))
-#endif
-
#define YCBCR_TO_RGB( y, cb, cr, r, g, b ) \
do { \
int _y, _cb, _cr, _r, _g, _b; \
@@ -232,7 +228,7 @@ static vo_frame_t *directfb_alloc_frame (vo_driver_t *this_gen) {
directfb_driver_t *this = (directfb_driver_t *) this_gen;
directfb_frame_t *frame;
- frame = (directfb_frame_t *) xine_xmalloc (sizeof (directfb_frame_t));
+ frame = (directfb_frame_t *) calloc(1, sizeof(directfb_frame_t));
if (!frame) {
xprintf (this->xine, XINE_VERBOSITY_DEBUG,
"video_out_directfb: directfb_alloc_frame: out of memory\n");
@@ -1767,7 +1763,7 @@ static vo_driver_t *open_plugin_fb (video_driver_class_t *class_gen, const void
DFBDisplayLayerID id;
DFBResult ret;
- this = xine_xmalloc (sizeof (directfb_driver_t));
+ this = calloc(1, sizeof(directfb_driver_t));
if (!this)
return NULL;
@@ -1909,7 +1905,7 @@ static void *init_class_fb (xine_t *xine, void *visual_gen) {
return NULL;
}
- this = (directfb_class_t *) xine_xmalloc (sizeof (directfb_class_t));
+ this = (directfb_class_t *) calloc(1, sizeof(directfb_class_t));
this->driver_class.open_plugin = open_plugin_fb;
this->driver_class.identifier = "DirectFB";
this->driver_class.description = N_("xine video output plugin using DirectFB.");
@@ -1940,7 +1936,7 @@ static vo_driver_t *open_plugin_x11 (video_driver_class_t *class_gen, const void
DFBDisplayLayerID id = DLID_PRIMARY;
DFBResult ret;
- this = xine_xmalloc (sizeof (directfb_driver_t));
+ this = calloc(1, sizeof(directfb_driver_t));
if (!this)
return NULL;
@@ -2114,7 +2110,7 @@ static void *init_class_x11 (xine_t *xine, void *visual_gen) {
if (strcmp (XServerVendor (visual->display), "Denis Oliver Kropp"))
return NULL;
- this = (directfb_class_t *) xine_xmalloc (sizeof (directfb_class_t));
+ this = (directfb_class_t *) calloc(1, sizeof(directfb_class_t));
this->driver_class.open_plugin = open_plugin_x11;
this->driver_class.identifier = "XDirectFB";
this->driver_class.description = N_("xine video output plugin using DirectFB under XDirectFB.");
diff --git a/src/video_out/video_out_directx.c b/src/video_out/video_out_directx.c
index c2b3aa101..7c63f93e9 100644
--- a/src/video_out/video_out_directx.c
+++ b/src/video_out/video_out_directx.c
@@ -863,7 +863,7 @@ static vo_frame_t * win32_alloc_frame( vo_driver_t * vo_driver )
{
win32_frame_t *win32_frame;
- win32_frame = ( win32_frame_t * ) xine_xmalloc( sizeof( win32_frame_t ) );
+ win32_frame = calloc(1, sizeof(win32_frame_t));
if (!win32_frame)
return NULL;
@@ -1183,7 +1183,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *wi
/*vo_driver_t *init_video_out_plugin( config_values_t * config, void * win32_visual )*/
{
directx_class_t *class = (directx_class_t *)class_gen;
- win32_driver_t *win32_driver = ( win32_driver_t * ) xine_xmalloc ( sizeof( win32_driver_t ) );
+ win32_driver_t *win32_driver = calloc(1, sizeof(win32_driver_t));
_x_alphablend_init(&win32_driver->alphablend_extra_data, class->xine);
@@ -1234,7 +1234,7 @@ static void *init_class (xine_t *xine, void *visual_gen) {
/*
* from this point on, nothing should go wrong anymore
*/
- directx = (directx_class_t *) xine_xmalloc (sizeof (directx_class_t));
+ directx = calloc(1, sizeof (directx_class_t));
directx->driver_class.open_plugin = open_plugin;
directx->driver_class.identifier = "DirectX";
diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c
index 1efc39459..107d2a133 100644
--- a/src/video_out/video_out_fb.c
+++ b/src/video_out/video_out_fb.c
@@ -221,7 +221,7 @@ static vo_frame_t *fb_alloc_frame(vo_driver_t *this_gen)
this->total_num_native_buffers <= this->used_num_buffers)
return 0;
- frame = (fb_frame_t *)xine_xmalloc(sizeof(fb_frame_t));
+ frame = calloc(1, sizeof(fb_frame_t));
if(!frame)
return NULL;
@@ -337,7 +337,7 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame,
else
{
free(frame->data);
- frame->data = xine_xcalloc(frame->sc.output_width *
+ frame->data = calloc(frame->sc.output_width *
frame->sc.output_height,
this->bytes_per_pixel);
}
@@ -971,7 +971,7 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen,
config = class->config;
/* allocate plugin struct */
- this = (fb_driver_t *) xine_xmalloc(sizeof(fb_driver_t));
+ this = calloc(1, sizeof(fb_driver_t));
if(!this)
return NULL;
@@ -1039,7 +1039,7 @@ error:
static void *fb_init_class(xine_t *xine, void *visual_gen)
{
- fb_class_t *this = (fb_class_t *)xine_xmalloc(sizeof(fb_class_t));
+ fb_class_t *this = calloc(1, sizeof(fb_class_t));
this->driver_class.open_plugin = fb_open_plugin;
this->driver_class.identifier = "fb";
diff --git a/src/video_out/video_out_macosx.m b/src/video_out/video_out_macosx.m
index 085387a44..3a87908df 100644
--- a/src/video_out/video_out_macosx.m
+++ b/src/video_out/video_out_macosx.m
@@ -97,7 +97,7 @@ static vo_frame_t *macosx_alloc_frame(vo_driver_t *vo_driver) {
/* macosx_driver_t *this = (macosx_driver_t *) vo_driver; */
macosx_frame_t *frame;
- frame = (macosx_frame_t *) xine_xmalloc(sizeof(macosx_frame_t));
+ frame = calloc(1, sizeof(macosx_frame_t));
if(!frame)
return NULL;
@@ -320,7 +320,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *driver_class, const void *
macosx_driver_t *driver;
XineOpenGLView *view = (XineOpenGLView *) visual;
- driver = (macosx_driver_t *) xine_xmalloc(sizeof(macosx_driver_t));
+ driver = calloc(1, sizeof(macosx_driver_t));
driver->config = class->config;
driver->xine = class->xine;
@@ -353,7 +353,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *driver_class, const void *
static void *init_class (xine_t *xine, void *visual) {
macosx_class_t *this;
- this = (macosx_class_t *) xine_xmalloc(sizeof(macosx_class_t));
+ this = calloc(1, sizeof(macosx_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "MacOSX";
diff --git a/src/video_out/video_out_none.c b/src/video_out/video_out_none.c
index c23c828a6..fc5d5d56e 100644
--- a/src/video_out/video_out_none.c
+++ b/src/video_out/video_out_none.c
@@ -88,7 +88,7 @@ static vo_frame_t *none_alloc_frame(vo_driver_t *vo_driver) {
/* none_driver_t *this = (none_driver_t *) vo_driver; */
none_frame_t *frame;
- frame = (none_frame_t *) xine_xmalloc(sizeof(none_frame_t));
+ frame = calloc(1, sizeof(none_frame_t));
if(!frame)
return NULL;
@@ -243,7 +243,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *driver_class, const void *
none_class_t *class = (none_class_t *) driver_class;
none_driver_t *driver;
- driver = (none_driver_t *) xine_xmalloc(sizeof(none_driver_t));
+ driver = calloc(1, sizeof(none_driver_t));
driver->config = class->config;
driver->xine = class->xine;
@@ -272,7 +272,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *driver_class, const void *
static void *init_class (xine_t *xine, void *visual) {
none_class_t *this;
- this = (none_class_t *) xine_xmalloc(sizeof(none_class_t));
+ this = calloc(1, sizeof(none_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "none";
diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c
index 533b26a22..9656f9551 100644
--- a/src/video_out/video_out_opengl.c
+++ b/src/video_out/video_out_opengl.c
@@ -670,8 +670,8 @@ static int render_image_envtex (opengl_driver_t *this, opengl_frame_t *frame) {
* Render setup functions
*/
static int render_help_verify_ext (opengl_driver_t *this, char *ext) {
- int ret = 0;
- int l = strlen (ext);
+ int ret = 0;
+ const size_t l = strlen (ext);
const char *e;
for (e = (char *) this->gl_exts; e && *e; e = strchr (e, ' ')) {
while (isspace (*e))
@@ -695,10 +695,9 @@ static void *getdladdr (const GLubyte *_funcName) {
return NULL;
#elif defined(__APPLE__)
- char *temp = xine_xmalloc (strlen (funcName) + 2);
+ char *temp;
+ asprintf(&temp, "_%s", funcName);
void *res = NULL;
- temp[0] = '_'; /* Mac OS X prepends an underscore on function names */
- strcpy (temp+1, funcName);
if (NSIsSymbolNameDefined (temp)) {
NSSymbol symbol = NSLookupAndBindSymbol (temp);
res = NSAddressOfSymbol (symbol);
@@ -1282,7 +1281,7 @@ static vo_frame_t *opengl_alloc_frame (vo_driver_t *this_gen) {
opengl_frame_t *frame;
opengl_driver_t *this = (opengl_driver_t *) this_gen;
- frame = (opengl_frame_t *) xine_xmalloc (sizeof (opengl_frame_t));
+ frame = (opengl_frame_t *) calloc(1, sizeof(opengl_frame_t));
if (!frame)
return NULL;
@@ -1818,7 +1817,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
char **render_fun_names;
int i;
- this = (opengl_driver_t *) xine_xmalloc (sizeof (opengl_driver_t));
+ this = (opengl_driver_t *) calloc(1, sizeof(opengl_driver_t));
if (!this)
return NULL;
@@ -1874,8 +1873,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
this->drawable, X11OSD_SHAPED);
XUnlockDisplay (this->display);
- render_fun_names = xine_xmalloc ((sizeof(opengl_rb)/sizeof(opengl_render_t)+1)
- * sizeof (const char *));
+ render_fun_names = calloc((sizeof(opengl_rb)/sizeof(opengl_render_t)+1), sizeof(const char*));
for (i = 0; i < sizeof (opengl_rb) / sizeof (opengl_render_t); i++)
render_fun_names[i] = opengl_rb[i].name;
render_fun_names[i] = NULL;
@@ -1953,7 +1951,7 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v
* class functions
*/
static void *opengl_init_class (xine_t *xine, void *visual_gen) {
- opengl_class_t *this = (opengl_class_t *) xine_xmalloc (sizeof (opengl_class_t));
+ opengl_class_t *this = (opengl_class_t *) calloc(1, sizeof(opengl_class_t));
this->driver_class.open_plugin = opengl_open_plugin;
this->driver_class.identifier = "opengl";
diff --git a/src/video_out/video_out_pgx32.c b/src/video_out/video_out_pgx32.c
index 884f9939f..a69c26ee1 100644
--- a/src/video_out/video_out_pgx32.c
+++ b/src/video_out/video_out_pgx32.c
@@ -386,7 +386,7 @@ static vo_frame_t *pgx32_alloc_frame(vo_driver_t *this_gen)
/*pgx32_driver_t *this = (pgx32_driver_t *)(void *)this_gen;*/
pgx32_frame_t *frame;
- frame = (pgx32_frame_t *) xine_xmalloc(sizeof(pgx32_frame_t));
+ frame = calloc(1, sizeof(pgx32_frame_t));
if (!frame) {
return NULL;
}
@@ -793,7 +793,7 @@ static vo_driver_t *pgx32_init_driver(video_driver_class_t *class_gen, const voi
pgx32_driver_class_t *class = (pgx32_driver_class_t *)(void *)class_gen;
pgx32_driver_t *this;
- this = (pgx32_driver_t *)xine_xmalloc(sizeof(pgx32_driver_t));
+ this = calloc(1, sizeof(pgx32_driver_t));
if (!this) {
return NULL;
}
@@ -852,7 +852,7 @@ static void *pgx32_init_class(xine_t *xine, void *visual_gen)
{
pgx32_driver_class_t *class;
- class = (pgx32_driver_class_t *)xine_xmalloc(sizeof(pgx32_driver_class_t));
+ class = calloc(1, sizeof(pgx32_driver_class_t));
if (!class) {
return NULL;
}
diff --git a/src/video_out/video_out_pgx64.c b/src/video_out/video_out_pgx64.c
index 0bdcc35fe..8482de06a 100644
--- a/src/video_out/video_out_pgx64.c
+++ b/src/video_out/video_out_pgx64.c
@@ -560,7 +560,7 @@ static vo_frame_t *pgx64_alloc_frame(vo_driver_t *this_gen)
/*pgx64_driver_t *this = (pgx64_driver_t *)(void *)this_gen;*/
pgx64_frame_t *frame;
- frame = (pgx64_frame_t *) xine_xmalloc(sizeof(pgx64_frame_t));
+ frame = calloc(1, sizeof(pgx64_frame_t));
if (!frame) {
return NULL;
}
@@ -1343,7 +1343,7 @@ static vo_driver_t *pgx64_init_driver(video_driver_class_t *class_gen, const voi
struct fbgattr attr;
long page_size;
- this = (pgx64_driver_t *)xine_xmalloc(sizeof(pgx64_driver_t));
+ this = calloc(1, sizeof(pgx64_driver_t));
if (!this) {
return NULL;
}
@@ -1474,7 +1474,7 @@ static void *pgx64_init_class(xine_t *xine, void *visual_gen)
{
pgx64_driver_class_t *class;
- class = (pgx64_driver_class_t *)xine_xmalloc(sizeof(pgx64_driver_class_t));
+ class = calloc(1, sizeof(pgx64_driver_class_t));
if (!class) {
return NULL;
}
diff --git a/src/video_out/video_out_raw.c b/src/video_out/video_out_raw.c
new file mode 100644
index 000000000..227331f2f
--- /dev/null
+++ b/src/video_out/video_out_raw.c
@@ -0,0 +1,586 @@
+/*
+ * Copyright (C) 2007 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ *
+ * video_out_raw.c, a video output plugin to pass raw data to frontend
+ *
+ * Written by Christophe Thommeret <hftom@free.fr>,
+ * based on others' video output plugins.
+ *
+ */
+
+/* #define LOG */
+#define LOG_MODULE "video_out_raw"
+
+/* Allow frontend some time to render frames
+* However, frontends are strongly advised to render synchronously */
+#define NUM_FRAMES_BACKLOG 4
+#define BYTES_PER_PIXEL 3
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h>
+#include <errno.h>
+#include <ctype.h>
+#include <pthread.h>
+
+#include <xine.h>
+#include <xine/video_out.h>
+
+#include <xine/xine_internal.h>
+#include "yuv2rgb.h"
+#include <xine/xineutils.h>
+
+#include <mem.h>
+
+typedef struct {
+ vo_frame_t vo_frame;
+
+ int width, height, format, flags;
+ double ratio;
+ uint8_t *rgb, *rgb_dst;
+ yuv2rgb_t *yuv2rgb; /* yuv2rgb converter set up for this frame */
+
+} raw_frame_t;
+
+typedef struct {
+ vo_driver_t vo_driver;
+
+ void *user_data;
+
+ void (*raw_output_cb) (void *user_data, int format,
+ int frame_width, int frame_height, double frame_aspect,
+ void *data0, void *data1, void *data2);
+
+ void (*raw_overlay_cb) (void *user_data, int num_ovl,
+ raw_overlay_t *overlays_p);
+
+ int ovl_changed;
+ raw_overlay_t overlays[XINE_VORAW_MAX_OVL];
+ yuv2rgb_t *ovl_yuv2rgb;
+
+ int doYV12;
+ int doYUY2;
+ yuv2rgb_factory_t *yuv2rgb_factory;
+ /* Frame state */
+ raw_frame_t *frame[NUM_FRAMES_BACKLOG];
+ xine_t *xine;
+} raw_driver_t;
+
+
+typedef struct {
+ video_driver_class_t driver_class;
+ xine_t *xine;
+} raw_class_t;
+
+
+
+static void raw_overlay_clut_yuv2rgb(raw_driver_t *this, vo_overlay_t *overlay, raw_frame_t *frame)
+{
+ int i;
+ clut_t* clut = (clut_t*) overlay->color;
+
+ if (!overlay->rgb_clut) {
+ for ( i=0; i<sizeof(overlay->color)/sizeof(overlay->color[0]); i++ ) {
+ *((uint32_t *)&clut[i]) = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, clut[i].y, clut[i].cb, clut[i].cr);
+ }
+ overlay->rgb_clut++;
+ }
+ if (!overlay->hili_rgb_clut) {
+ clut = (clut_t*) overlay->hili_color;
+ for ( i=0; i<sizeof(overlay->color)/sizeof(overlay->color[0]); i++) {
+ *((uint32_t *)&clut[i]) = this->ovl_yuv2rgb->yuv2rgb_single_pixel_fun(frame->yuv2rgb, clut[i].y, clut[i].cb, clut[i].cr);
+ }
+ overlay->hili_rgb_clut++;
+ }
+}
+
+
+static int raw_process_ovl( raw_driver_t *this_gen, vo_overlay_t *overlay )
+{
+ raw_overlay_t *ovl = &this_gen->overlays[this_gen->ovl_changed-1];
+
+ if ( overlay->width<=0 || overlay->height<=0 )
+ return 0;
+
+ if ( (overlay->width*overlay->height)!=(ovl->ovl_w*ovl->ovl_h) )
+ ovl->ovl_rgba = (uint8_t*)realloc( ovl->ovl_rgba, overlay->width*overlay->height*4 );
+ ovl->ovl_w = overlay->width;
+ ovl->ovl_h = overlay->height;
+ ovl->ovl_x = overlay->x;
+ ovl->ovl_y = overlay->y;
+
+ int num_rle = overlay->num_rle;
+ rle_elem_t *rle = overlay->rle;
+ uint8_t *rgba = ovl->ovl_rgba;
+ clut_t *low_colors = (clut_t*)overlay->color;
+ clut_t *hili_colors = (clut_t*)overlay->hili_color;
+ uint8_t *low_trans = overlay->trans;
+ uint8_t *hili_trans = overlay->hili_trans;
+ clut_t *colors;
+ uint8_t *trans;
+ uint8_t alpha;
+ int rlelen = 0;
+ uint8_t clr = 0;
+ int i, pos=0, x, y;
+
+ while ( num_rle>0 ) {
+ x = pos%ovl->ovl_w;
+ y = pos/ovl->ovl_w;
+ if ( (x>=overlay->hili_left && x<=overlay->hili_right) && (y>=overlay->hili_top && y<=overlay->hili_bottom) ) {
+ colors = hili_colors;
+ trans = hili_trans;
+ }
+ else {
+ colors = low_colors;
+ trans = low_trans;
+ }
+ rlelen = rle->len;
+ clr = rle->color;
+ alpha = trans[clr];
+ for ( i=0; i<rlelen; ++i ) {
+ rgba[0] = colors[clr].y;
+ rgba[1] = colors[clr].cr;
+ rgba[2] = colors[clr].cb;
+ rgba[3] = alpha*255/15;
+ rgba+= 4;
+ ++pos;
+ }
+ ++rle;
+ --num_rle;
+ }
+ return 1;
+}
+
+
+static void raw_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed)
+{
+ raw_driver_t *this = (raw_driver_t *) this_gen;
+
+ if ( !changed )
+ return;
+
+ ++this->ovl_changed;
+}
+
+
+static void raw_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
+{
+ raw_driver_t *this = (raw_driver_t *) this_gen;
+ raw_frame_t *frame = (raw_frame_t *) frame_gen;
+
+ if ( !this->ovl_changed || this->ovl_changed>XINE_VORAW_MAX_OVL )
+ return;
+
+ if (overlay->rle) {
+ if (!overlay->rgb_clut || !overlay->hili_rgb_clut)
+ raw_overlay_clut_yuv2rgb (this, overlay, frame);
+ if ( raw_process_ovl( this, overlay ) )
+ ++this->ovl_changed;
+ }
+}
+
+
+static void raw_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img)
+{
+ raw_driver_t *this = (raw_driver_t *) this_gen;
+
+ if ( !this->ovl_changed )
+ return;
+
+ this->raw_overlay_cb( this->user_data, this->ovl_changed-1, &this->overlays );
+
+ this->ovl_changed = 0;
+}
+
+
+static void raw_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src)
+{
+ raw_frame_t *frame = (raw_frame_t *) vo_img ;
+
+ vo_img->proc_called = 1;
+ if (! frame->rgb_dst)
+ return;
+
+ if( frame->vo_frame.crop_left || frame->vo_frame.crop_top ||
+ frame->vo_frame.crop_right || frame->vo_frame.crop_bottom )
+ {
+ /* TODO: ?!? */
+ return;
+ }
+
+ if (frame->format == XINE_IMGFMT_YV12)
+ frame->yuv2rgb->yuv2rgb_fun (frame->yuv2rgb, frame->rgb_dst, src[0], src[1], src[2]);
+ else
+ frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, src[0]);
+}
+
+
+
+static void raw_frame_field (vo_frame_t *vo_img, int which_field)
+{
+ raw_frame_t *frame = (raw_frame_t *) vo_img ;
+ raw_driver_t *this = (raw_driver_t *) vo_img->driver;
+
+ if ( frame->format==XINE_IMGFMT_YV12 && this->doYV12 ) {
+ frame->rgb_dst = 0;
+ return;
+ }
+ else if ( frame->format==XINE_IMGFMT_YUY2 && this->doYUY2 ) {
+ frame->rgb_dst = 0;
+ return;
+ }
+
+ switch (which_field) {
+ case VO_TOP_FIELD:
+ frame->rgb_dst = (uint8_t *)frame->rgb;
+ break;
+ case VO_BOTTOM_FIELD:
+ frame->rgb_dst = (uint8_t *)frame->rgb + frame->width * BYTES_PER_PIXEL;
+ break;
+ case VO_BOTH_FIELDS:
+ frame->rgb_dst = (uint8_t *)frame->rgb;
+ break;
+ }
+
+ frame->yuv2rgb->next_slice (frame->yuv2rgb, NULL);
+}
+
+
+
+static void raw_frame_dispose (vo_frame_t *vo_img)
+{
+ raw_frame_t *frame = (raw_frame_t *) vo_img ;
+
+ frame->yuv2rgb->dispose (frame->yuv2rgb);
+
+ av_free (frame->vo_frame.base[0]);
+ av_free (frame->vo_frame.base[1]);
+ av_free (frame->vo_frame.base[2]);
+ av_free (frame->rgb);
+ free (frame);
+}
+
+
+
+static vo_frame_t *raw_alloc_frame (vo_driver_t *this_gen)
+{
+ raw_frame_t *frame;
+ raw_driver_t *this = (raw_driver_t *) this_gen;
+
+ frame = (raw_frame_t *) calloc(1, sizeof(raw_frame_t));
+
+ if (!frame)
+ return NULL;
+
+ pthread_mutex_init (&frame->vo_frame.mutex, NULL);
+
+ /*
+ * supply required functions/fields
+ */
+ frame->vo_frame.proc_slice = raw_frame_proc_slice;
+ frame->vo_frame.proc_frame = NULL;
+ frame->vo_frame.field = raw_frame_field;
+ frame->vo_frame.dispose = raw_frame_dispose;
+ frame->vo_frame.driver = this_gen;
+
+ /*
+ * colorspace converter for this frame
+ */
+ frame->yuv2rgb = this->yuv2rgb_factory->create_converter (this->yuv2rgb_factory);
+
+ return (vo_frame_t *) frame;
+}
+
+
+
+static void raw_update_frame_format (vo_driver_t *this_gen, vo_frame_t *frame_gen,
+ uint32_t width, uint32_t height, double ratio, int format, int flags)
+{
+ raw_frame_t *frame = (raw_frame_t *) frame_gen;
+
+ /* Check frame size and format and reallocate if necessary */
+ if ((frame->width != width)
+ || (frame->height != height)
+ || (frame->format != format)
+ || (frame->flags != flags)) {
+/* lprintf ("updating frame to %d x %d (ratio=%g, format=%08x)\n", width, height, ratio, format); */
+
+ flags &= VO_BOTH_FIELDS;
+
+ /* (re-) allocate render space */
+ av_free (frame->vo_frame.base[0]);
+ av_free (frame->vo_frame.base[1]);
+ av_free (frame->vo_frame.base[2]);
+ av_free (frame->rgb);
+
+ if (format == XINE_IMGFMT_YV12) {
+ frame->vo_frame.pitches[0] = 8*((width + 7) / 8);
+ frame->vo_frame.pitches[1] = 8*((width + 15) / 16);
+ frame->vo_frame.pitches[2] = 8*((width + 15) / 16);
+ frame->vo_frame.base[0] = av_mallocz (frame->vo_frame.pitches[0] * height);
+ frame->vo_frame.base[1] = av_mallocz (frame->vo_frame.pitches[1] * ((height+1)/2));
+ frame->vo_frame.base[2] = av_mallocz (frame->vo_frame.pitches[2] * ((height+1)/2));
+ } else {
+ frame->vo_frame.pitches[0] = 8*((width + 3) / 4);
+ frame->vo_frame.base[0] = av_mallocz (frame->vo_frame.pitches[0] * height);
+ frame->vo_frame.base[1] = NULL;
+ frame->vo_frame.base[2] = NULL;
+ }
+ frame->rgb = av_mallocz (BYTES_PER_PIXEL*width*height);
+
+ /* set up colorspace converter */
+ switch (flags) {
+ case VO_TOP_FIELD:
+ case VO_BOTTOM_FIELD:
+ frame->yuv2rgb->configure (frame->yuv2rgb,
+ width,
+ height,
+ 2*frame->vo_frame.pitches[0],
+ 2*frame->vo_frame.pitches[1],
+ width,
+ height,
+ BYTES_PER_PIXEL*width * 2);
+ break;
+ case VO_BOTH_FIELDS:
+ frame->yuv2rgb->configure (frame->yuv2rgb,
+ width,
+ height,
+ frame->vo_frame.pitches[0],
+ frame->vo_frame.pitches[1],
+ width,
+ height,
+ BYTES_PER_PIXEL*width);
+ break;
+ }
+
+ frame->width = width;
+ frame->height = height;
+ frame->format = format;
+
+ raw_frame_field ((vo_frame_t *)frame, flags);
+ }
+
+ frame->ratio = ratio;
+}
+
+
+
+static int raw_redraw_needed (vo_driver_t *this_gen)
+{
+ return 0;
+}
+
+
+
+static void raw_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen)
+{
+ raw_driver_t *this = (raw_driver_t *) this_gen;
+ raw_frame_t *frame = (raw_frame_t *) frame_gen;
+ int i;
+
+ if (this->frame[NUM_FRAMES_BACKLOG-1]) {
+ this->frame[NUM_FRAMES_BACKLOG-1]->vo_frame.free (&this->frame[NUM_FRAMES_BACKLOG-1]->vo_frame);
+ }
+ for (i = NUM_FRAMES_BACKLOG-1; i > 0; i--)
+ this->frame[i] = this->frame[i-1];
+ this->frame[0] = frame;
+
+ if ( frame->rgb_dst ) {
+ this->raw_output_cb( this->user_data, XINE_VORAW_RGB, frame->width, frame->height, frame->ratio, frame->rgb, 0, 0 );
+ }
+ else if ( frame->format==XINE_IMGFMT_YV12 ) {
+ this->raw_output_cb( this->user_data, XINE_VORAW_YV12, frame->width, frame->height, frame->ratio, frame->vo_frame.base[0],
+ frame->vo_frame.base[1], frame->vo_frame.base[2] );
+ }
+ else {
+ this->raw_output_cb( this->user_data, XINE_VORAW_YUY2, frame->width, frame->height, frame->ratio, frame->vo_frame.base[0], 0, 0 );
+ }
+}
+
+
+
+static int raw_get_property (vo_driver_t *this_gen, int property)
+{
+ switch (property) {
+ case VO_PROP_ASPECT_RATIO:
+ return XINE_VO_ASPECT_AUTO;
+ case VO_PROP_MAX_NUM_FRAMES:
+ return 15;
+ case VO_PROP_BRIGHTNESS:
+ return 0;
+ case VO_PROP_CONTRAST:
+ return 128;
+ case VO_PROP_SATURATION:
+ return 128;
+ case VO_PROP_WINDOW_WIDTH:
+ return 0;
+ case VO_PROP_WINDOW_HEIGHT:
+ return 0;
+ default:
+ return 0;
+ }
+}
+
+
+
+static int raw_set_property (vo_driver_t *this_gen, int property, int value)
+{
+ return value;
+}
+
+
+
+static void raw_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max)
+{
+ *min = 0;
+ *max = 0;
+}
+
+
+
+static int raw_gui_data_exchange (vo_driver_t *this_gen, int data_type, void *data)
+{
+ return 0;
+}
+
+
+
+static uint32_t raw_get_capabilities (vo_driver_t *this_gen)
+{
+ uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2;
+ return capabilities;
+}
+
+
+
+static void raw_dispose (vo_driver_t *this_gen)
+{
+ raw_driver_t *this = (raw_driver_t *) this_gen;
+ int i;
+
+ for (i = 0; i < NUM_FRAMES_BACKLOG; i++)
+ if (this->frame[i])
+ this->frame[i]->vo_frame.dispose (&this->frame[i]->vo_frame);
+
+ this->yuv2rgb_factory->dispose (this->yuv2rgb_factory);
+
+ for ( i=0; i<XINE_VORAW_MAX_OVL; ++i )
+ free( this->overlays[i].ovl_rgba );
+
+ free (this);
+}
+
+
+
+static vo_driver_t *raw_open_plugin (video_driver_class_t *class_gen, const void *visual_gen)
+{
+ raw_class_t *class = (raw_class_t *) class_gen;
+ raw_visual_t *visual = (raw_visual_t *) visual_gen;
+ raw_driver_t *this;
+ int i;
+
+ this = (raw_driver_t *) calloc(1, sizeof(raw_driver_t));
+
+ if (!this)
+ return NULL;
+
+ this->raw_output_cb = visual->raw_output_cb;
+ this->user_data = visual->user_data;
+ this->xine = class->xine;
+ this->raw_overlay_cb = visual->raw_overlay_cb;
+ this->doYV12 = visual->supported_formats&XINE_VORAW_YV12;
+ this->doYUY2 = visual->supported_formats&XINE_VORAW_YUY2;
+
+ this->vo_driver.get_capabilities = raw_get_capabilities;
+ this->vo_driver.alloc_frame = raw_alloc_frame;
+ this->vo_driver.update_frame_format = raw_update_frame_format;
+ this->vo_driver.overlay_begin = raw_overlay_begin;
+ this->vo_driver.overlay_blend = raw_overlay_blend;
+ this->vo_driver.overlay_end = raw_overlay_end;
+ this->vo_driver.display_frame = raw_display_frame;
+ this->vo_driver.get_property = raw_get_property;
+ this->vo_driver.set_property = raw_set_property;
+ this->vo_driver.get_property_min_max = raw_get_property_min_max;
+ this->vo_driver.gui_data_exchange = raw_gui_data_exchange;
+ this->vo_driver.dispose = raw_dispose;
+ this->vo_driver.redraw_needed = raw_redraw_needed;
+
+ this->yuv2rgb_factory = yuv2rgb_factory_init (MODE_24_BGR, 1, NULL); /* converts to rgb */
+
+ for (i = 0; i < NUM_FRAMES_BACKLOG; i++)
+ this->frame[i] = 0;
+
+ for ( i=0; i<XINE_VORAW_MAX_OVL; ++i ) {
+ this->overlays[i].ovl_w = this->overlays[i].ovl_h = 2;
+ this->overlays[i].ovl_rgba = (uint8_t*)malloc(2*2*4);
+ this->overlays[i].ovl_x = this->overlays[i].ovl_y = 0;
+ }
+ this->ovl_changed = 0;
+
+ /* we have to use a second converter for overlays
+ * because "MODE_24_BGR, 1 (swap)" breaks overlays conversion */
+ yuv2rgb_factory_t *factory = yuv2rgb_factory_init (MODE_24_BGR, 0, NULL);
+ this->ovl_yuv2rgb = factory->create_converter( factory );
+ factory->dispose( factory );
+
+ return &this->vo_driver;
+}
+
+/*
+ * class functions
+ */
+
+static void *raw_init_class (xine_t *xine, void *visual_gen)
+{
+ raw_class_t *this = (raw_class_t *) calloc(1, sizeof(raw_class_t));
+
+ this->driver_class.open_plugin = raw_open_plugin;
+ this->driver_class.identifier = "raw";
+ this->driver_class.description = _("xine video output plugin passing raw data to supplied callback");
+ this->driver_class.dispose = default_video_driver_class_dispose;
+ this->xine = xine;
+
+ return this;
+}
+
+
+
+static const vo_info_t vo_info_raw = {
+ 7, /* priority */
+ XINE_VISUAL_TYPE_RAW /* visual type */
+};
+
+
+/*
+ * exported plugin catalog entry
+ */
+
+const plugin_info_t xine_plugin_info[] EXPORTED = {
+ /* type, API, "name", version, special_info, init_function */
+ { PLUGIN_VIDEO_OUT, 22, "raw", XINE_VERSION_CODE, &vo_info_raw, raw_init_class },
+ { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+};
diff --git a/src/video_out/video_out_sdl.c b/src/video_out/video_out_sdl.c
index 13a84475d..b96a4ba23 100644
--- a/src/video_out/video_out_sdl.c
+++ b/src/video_out/video_out_sdl.c
@@ -138,7 +138,7 @@ static vo_frame_t *sdl_alloc_frame (vo_driver_t *this_gen) {
/* sdl_driver_t *this = (sdl_driver_t *) this_gen; */
sdl_frame_t *frame ;
- frame = (sdl_frame_t *) xine_xmalloc (sizeof (sdl_frame_t));
+ frame = (sdl_frame_t *) calloc(1, sizeof(sdl_frame_t));
if (!frame)
return NULL;
@@ -475,7 +475,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
XWindowAttributes window_attributes;
#endif
- this = (sdl_driver_t *) xine_xmalloc (sizeof (sdl_driver_t));
+ this = (sdl_driver_t *) calloc(1, sizeof(sdl_driver_t));
if (!this)
return NULL;
@@ -583,7 +583,7 @@ static void *init_class (xine_t *xine, void *visual_gen) {
}
SDL_QuitSubSystem (SDL_INIT_VIDEO);
- this = (sdl_class_t*) xine_xmalloc (sizeof (sdl_class_t));
+ this = (sdl_class_t*) calloc(1, sizeof(sdl_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "SDL";
diff --git a/src/video_out/video_out_stk.c b/src/video_out/video_out_stk.c
index e68efb30b..9e3a4ae30 100644
--- a/src/video_out/video_out_stk.c
+++ b/src/video_out/video_out_stk.c
@@ -133,7 +133,7 @@ static vo_frame_t *stk_alloc_frame(vo_driver_t *this_gen) {
stk_frame_t* frame;
//printf("video_out_stk: alloc_frame()\n");
- frame = (stk_frame_t *) xine_xmalloc(sizeof(stk_frame_t));
+ frame = calloc(1, sizeof(stk_frame_t));
if (!frame)
return NULL;
@@ -389,7 +389,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis
//printf("video_out_stk: open_plugin()\n");
- this = (stk_driver_t *) xine_xmalloc (sizeof (stk_driver_t));
+ this = calloc(1, sizeof (stk_driver_t));
if (!this)
return NULL;
@@ -447,7 +447,7 @@ static void *init_class (xine_t *xine, void *visual_gen) {
//printf("video_out_stk: init_class()\n");
- this = (stk_class_t *) xine_xmalloc(sizeof(stk_class_t));
+ this = calloc(1, sizeof(stk_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "stk";
diff --git a/src/video_out/video_out_vidix.c b/src/video_out/video_out_vidix.c
index 586268513..957d6ce1a 100644
--- a/src/video_out/video_out_vidix.c
+++ b/src/video_out/video_out_vidix.c
@@ -370,7 +370,7 @@ static vo_frame_t *vidix_alloc_frame (vo_driver_t *this_gen) {
/* vidix_driver_t *this = (vidix_driver_t *) this_gen; */
vidix_frame_t *frame ;
- frame = (vidix_frame_t *) xine_xmalloc (sizeof (vidix_frame_t));
+ frame = (vidix_frame_t *) calloc(1, sizeof(vidix_frame_t));
if (!frame)
return NULL;
@@ -947,7 +947,7 @@ static vidix_driver_t *open_plugin (video_driver_class_t *class_gen) {
vidix_driver_t *this;
int err;
- this = (vidix_driver_t *) xine_xmalloc (sizeof (vidix_driver_t));
+ this = (vidix_driver_t *) calloc(1, sizeof(vidix_driver_t));
if (!this)
return NULL;
@@ -1093,7 +1093,7 @@ static void *init_class (xine_t *xine, void *visual_gen) {
vidix_class_t *this;
int err;
- this = (vidix_class_t *) xine_xmalloc (sizeof (vidix_class_t));
+ this = (vidix_class_t *) calloc(1, sizeof(vidix_class_t));
if (!this)
return NULL;
diff --git a/src/video_out/video_out_xcbshm.c b/src/video_out/video_out_xcbshm.c
index 1b2e90be8..509412eb6 100644
--- a/src/video_out/video_out_xcbshm.c
+++ b/src/video_out/video_out_xcbshm.c
@@ -298,7 +298,7 @@ static vo_frame_t *xshm_alloc_frame (vo_driver_t *this_gen) {
xshm_frame_t *frame;
xshm_driver_t *this = (xshm_driver_t *) this_gen;
- frame = (xshm_frame_t *) xine_xmalloc (sizeof (xshm_frame_t));
+ frame = (xshm_frame_t *) calloc(1, sizeof(xshm_frame_t));
if (!frame)
return NULL;
@@ -1005,7 +1005,7 @@ static vo_driver_t *xshm_open_plugin(video_driver_class_t *class_gen, const void
const xcb_query_extension_reply_t *query_extension_reply;
- this = (xshm_driver_t *) xine_xmalloc (sizeof (xshm_driver_t));
+ this = (xshm_driver_t *) calloc(1, sizeof(xshm_driver_t));
if (!this)
return NULL;
@@ -1225,7 +1225,7 @@ static vo_driver_t *xshm_open_plugin(video_driver_class_t *class_gen, const void
* class functions
*/
static void *xshm_init_class (xine_t *xine, void *visual_gen) {
- xshm_class_t *this = (xshm_class_t *) xine_xmalloc (sizeof (xshm_class_t));
+ xshm_class_t *this = (xshm_class_t *) calloc(1, sizeof(xshm_class_t));
this->driver_class.open_plugin = xshm_open_plugin;
this->driver_class.identifier = "XShm";
diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c
index e267f98fb..7b6ab6677 100644
--- a/src/video_out/video_out_xcbxv.c
+++ b/src/video_out/video_out_xcbxv.c
@@ -184,7 +184,7 @@ static vo_frame_t *xv_alloc_frame (vo_driver_t *this_gen) {
/* xv_driver_t *this = (xv_driver_t *) this_gen; */
xv_frame_t *frame ;
- frame = (xv_frame_t *) xine_xmalloc (sizeof (xv_frame_t));
+ frame = (xv_frame_t *) calloc(1, sizeof(xv_frame_t));
if (!frame)
return NULL;
@@ -1189,7 +1189,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis
xcb_xv_adaptor_info_iterator_t adaptor_it;
xcb_xv_image_format_info_iterator_t format_it;
- this = (xv_driver_t *) xine_xmalloc (sizeof (xv_driver_t));
+ this = (xv_driver_t *) calloc(1, sizeof(xv_driver_t));
if (!this)
return NULL;
@@ -1460,7 +1460,7 @@ static vo_driver_t *open_plugin(video_driver_class_t *class_gen, const void *vis
* class functions
*/
static void *init_class (xine_t *xine, void *visual_gen) {
- xv_class_t *this = (xv_class_t *) xine_xmalloc (sizeof (xv_class_t));
+ xv_class_t *this = (xv_class_t *) calloc(1, sizeof(xv_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "Xv";
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c
index fba253b87..54cac9d46 100644
--- a/src/video_out/video_out_xshm.c
+++ b/src/video_out/video_out_xshm.c
@@ -280,7 +280,7 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo,
this->bytes_per_pixel = this->bpp / 8;
this->image_byte_order = myimage->byte_order;
- myimage->data = xine_xcalloc (width * height, this->bytes_per_pixel);
+ myimage->data = calloc (width * height, this->bytes_per_pixel);
}
return myimage;
@@ -391,7 +391,7 @@ static vo_frame_t *xshm_alloc_frame (vo_driver_t *this_gen) {
xshm_frame_t *frame;
xshm_driver_t *this = (xshm_driver_t *) this_gen;
- frame = (xshm_frame_t *) xine_xmalloc (sizeof (xshm_frame_t));
+ frame = (xshm_frame_t *) calloc(1, sizeof(xshm_frame_t));
if (!frame)
return NULL;
@@ -1074,7 +1074,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v
int cpu_byte_order;
XColor dummy;
- this = (xshm_driver_t *) xine_xmalloc (sizeof (xshm_driver_t));
+ this = (xshm_driver_t *) calloc(1, sizeof(xshm_driver_t));
if (!this)
return NULL;
@@ -1286,7 +1286,7 @@ static vo_driver_t *xshm_open_plugin_old (video_driver_class_t *class_gen, const
* class functions
*/
static void *xshm_init_class (xine_t *xine, void *visual_gen) {
- xshm_class_t *this = (xshm_class_t *) xine_xmalloc (sizeof (xshm_class_t));
+ xshm_class_t *this = (xshm_class_t *) calloc(1, sizeof(xshm_class_t));
this->driver_class.open_plugin = xshm_open_plugin_old;
this->driver_class.identifier = "XShm";
diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c
index 0026bd8af..c78200077 100644
--- a/src/video_out/video_out_xv.c
+++ b/src/video_out/video_out_xv.c
@@ -206,7 +206,7 @@ static vo_frame_t *xv_alloc_frame (vo_driver_t *this_gen) {
/* xv_driver_t *this = (xv_driver_t *) this_gen; */
xv_frame_t *frame ;
- frame = (xv_frame_t *) xine_xmalloc (sizeof (xv_frame_t));
+ frame = (xv_frame_t *) calloc(1, sizeof(xv_frame_t));
if (!frame)
return NULL;
@@ -720,8 +720,8 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {
if( factor > 1 )
{
- lprintf( "%s PutImage %dX interval (%fs)\n",
- log_line_prefix(), factor, elapse_time );
+ lprintf( "%s PutImage %dX interval (%fs)\n",
+ LOG_MODULE, factor, elapse_time );
}
}
@@ -1220,7 +1220,7 @@ static vo_driver_t *open_plugin_2 (video_driver_class_t *class_gen, const void *
unsigned int adaptor_num;
xv_prefertype prefer_type;
- this = (xv_driver_t *) xine_xmalloc (sizeof (xv_driver_t));
+ this = (xv_driver_t *) calloc(1, sizeof(xv_driver_t));
if (!this)
return NULL;
@@ -1532,7 +1532,7 @@ static vo_driver_t *open_plugin_old (video_driver_class_t *class_gen, const void
* class functions
*/
static void *init_class (xine_t *xine, void *visual_gen) {
- xv_class_t *this = (xv_class_t *) xine_xmalloc (sizeof (xv_class_t));
+ xv_class_t *this = (xv_class_t *) calloc(1, sizeof(xv_class_t));
this->driver_class.open_plugin = open_plugin_old;
this->driver_class.identifier = "Xv";
diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c
index 7f282ee53..5caf58fae 100644
--- a/src/video_out/video_out_xvmc.c
+++ b/src/video_out/video_out_xvmc.c
@@ -547,7 +547,7 @@ static vo_frame_t *xvmc_alloc_frame (vo_driver_t *this_gen) {
lprintf ("xvmc_alloc_frame\n");
- frame = (xvmc_frame_t *) xine_xmalloc (sizeof (xvmc_frame_t));
+ frame = calloc(1, sizeof (xvmc_frame_t));
if (!frame)
return NULL;
@@ -587,8 +587,8 @@ static cxid_t *xvmc_set_context (xvmc_driver_t *this,
/* initialize block & macro block pointers first time */
if(macroblocks->blocks == NULL || macroblocks->macro_blocks == NULL) {
- macroblocks->blocks = xine_xmalloc(sizeof(XvMCBlockArray));
- macroblocks->macro_blocks = xine_xmalloc(sizeof(XvMCMacroBlockArray));
+ macroblocks->blocks = calloc(1, sizeof(XvMCBlockArray));
+ macroblocks->macro_blocks = calloc(1, sizeof(XvMCMacroBlockArray));
lprintf("macroblocks->blocks %lx ->macro_blocks %lx\n",
macroblocks->blocks,macroblocks->macro_blocks);
@@ -1309,7 +1309,8 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
lprintf ("open_plugin\n");
- this = (xvmc_driver_t *) xine_xmalloc (sizeof (xvmc_driver_t));
+ /* TODO ??? */
+ this = calloc(1, sizeof (xvmc_driver_t));
if (!this)
return NULL;
diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c
index bd8a76046..297d4ad49 100644
--- a/src/video_out/video_out_xxmc.c
+++ b/src/video_out/video_out_xxmc.c
@@ -548,7 +548,7 @@ static vo_frame_t *xxmc_alloc_frame (vo_driver_t *this_gen) {
xxmc_driver_t *this = (xxmc_driver_t *) this_gen;
xxmc_frame_t *frame ;
- frame = (xxmc_frame_t *) xine_xmalloc (sizeof (xxmc_frame_t));
+ frame = calloc(1, sizeof (xxmc_frame_t));
if (!frame)
return NULL;
@@ -2453,7 +2453,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
int use_more_frames;
int use_unscaled;
- this = (xxmc_driver_t *) xine_xmalloc (sizeof (xxmc_driver_t));
+ this = calloc(1, sizeof (xxmc_driver_t));
if (!this)
return NULL;
@@ -2800,7 +2800,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi
* class functions
*/
static void *init_class (xine_t *xine, void *visual_gen) {
- xxmc_class_t *this = (xxmc_class_t *) xine_xmalloc (sizeof (xxmc_class_t));
+ xxmc_class_t *this = calloc(1, sizeof (xxmc_class_t));
this->driver_class.open_plugin = open_plugin;
this->driver_class.identifier = "XxMC";
diff --git a/src/video_out/x11osd.c b/src/video_out/x11osd.c
index 450812f90..702fabda9 100644
--- a/src/video_out/x11osd.c
+++ b/src/video_out/x11osd.c
@@ -245,7 +245,7 @@ x11osd_create (xine_t *xine, Display *display, int screen, Window window, enum x
XSetWindowAttributes attr;
XWindowAttributes getattr;
- osd = xine_xmalloc (sizeof (x11osd));
+ osd = calloc(1, sizeof(x11osd));
if (!osd)
return NULL;
diff --git a/src/video_out/xcbosd.c b/src/video_out/xcbosd.c
index 8bb96be1e..2da723011 100644
--- a/src/video_out/xcbosd.c
+++ b/src/video_out/xcbosd.c
@@ -238,7 +238,7 @@ xcbosd *xcbosd_create(xine_t *xine, xcb_connection_t *connection, xcb_screen_t *
xcb_void_cookie_t generic_cookie;
xcb_generic_error_t *generic_error;
- osd = xine_xmalloc (sizeof (xcbosd));
+ osd = calloc(1, sizeof(xcbosd));
if (!osd)
return NULL;
diff --git a/src/video_out/yuv2rgb.c b/src/video_out/yuv2rgb.c
index 127338ee5..7def639a4 100644
--- a/src/video_out/yuv2rgb.c
+++ b/src/video_out/yuv2rgb.c
@@ -3146,7 +3146,7 @@ static void yuy22rgb_c_init (yuv2rgb_factory_t *this)
static yuv2rgb_t *yuv2rgb_create_converter (yuv2rgb_factory_t *factory) {
- yuv2rgb_t *this = xine_xmalloc (sizeof (yuv2rgb_t));
+ yuv2rgb_t *this = calloc(1, sizeof(yuv2rgb_t));
this->swapped = factory->swapped;
this->cmap = factory->cmap;
diff --git a/src/video_out/yuv2rgb_mlib.c b/src/video_out/yuv2rgb_mlib.c
index 794ce437e..b32817a90 100644
--- a/src/video_out/yuv2rgb_mlib.c
+++ b/src/video_out/yuv2rgb_mlib.c
@@ -38,8 +38,6 @@
#include <xine/xineutils.h>
#include "yuv2rgb.h"
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
static void mlib_yuv420_rgb24(yuv2rgb_t *this,
uint8_t * image, uint8_t * py,
uint8_t * pu, uint8_t * pv)
diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
index dcecbfcab..e32f2d2f4 100644
--- a/src/xine-engine/Makefile.am
+++ b/src/xine-engine/Makefile.am
@@ -26,7 +26,7 @@ libxine_la_SOURCES = xine.c metronom.c configfile.c buffer.c \
xine_interface.c post.c broadcaster.c io_helper.c \
input_rip.c input_cache.c info_helper.c refcounter.c \
alphablend.c \
- load_plugins.h
+ xine_private.h
libxine_la_DEPENDENCIES = $(XINEUTILS_LIB) $(XDG_BASEDIR_DEPS) \
$(pthread_dep) $(LIBXINEPOSIX)
diff --git a/src/xine-engine/alphablend.c b/src/xine-engine/alphablend.c
index 41715decb..8eff8da8e 100644
--- a/src/xine-engine/alphablend.c
+++ b/src/xine-engine/alphablend.c
@@ -1110,12 +1110,12 @@ static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_wi
uint8_t *data[ 3 ][ 2 ];
} *header = (struct header_s *)extra_data->buffer;
- int needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ][ 2 ]);
+ size_t needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ][ 2 ]);
if (extra_data->buffer_size < needed_buffer_size) {
free(extra_data->buffer);
- header = xine_xmalloc(needed_buffer_size);
+ header = calloc(1, needed_buffer_size);
if (!header) {
extra_data->buffer_size = 0;
return 0;
@@ -1552,12 +1552,12 @@ static uint8_t *(*blend_yuy2_grow_extra_data(alphablend_t *extra_data, int osd_w
uint8_t *data[ 3 ];
} *header = (struct header_s *)extra_data->buffer;
- int needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ]);
+ size_t needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ]);
if (extra_data->buffer_size < needed_buffer_size) {
free(extra_data->buffer);
- header = xine_xmalloc(needed_buffer_size);
+ header = calloc(1, needed_buffer_size);
if (!header) {
extra_data->buffer_size = 0;
return 0;
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 855051582..f16f482aa 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -294,11 +294,11 @@ struct audio_fifo_s {
static int ao_get_property (xine_audio_port_t *this_gen, int property);
static int ao_set_property (xine_audio_port_t *this_gen, int property, int value);
-static audio_fifo_t *fifo_new (xine_t *xine) {
+static audio_fifo_t *XINE_MALLOC fifo_new (xine_t *xine) {
audio_fifo_t *fifo;
- fifo = (audio_fifo_t *) xine_xmalloc (sizeof (audio_fifo_t));
+ fifo = (audio_fifo_t *) calloc(1, sizeof(audio_fifo_t));
if (!fifo)
return NULL;
@@ -2053,7 +2053,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
static const char *const resample_modes[] = {"auto", "off", "on", NULL};
static const char *const av_sync_methods[] = {"metronom feedback", "resample", NULL};
- this = xine_xmalloc (sizeof (aos_t)) ;
+ this = calloc(1, sizeof(aos_t)) ;
this->driver = driver;
this->xine = xine;
@@ -2087,7 +2087,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
this->grab_only = grab_only;
this->flush_audio_driver = 0;
this->discard_buffers = 0;
- this->zero_space = xine_xmalloc (ZERO_BUF_SIZE * 4 * 6); /* MAX as 32bit, 6 channels. */
+ this->zero_space = calloc (1, ZERO_BUF_SIZE * 4 * 6); /* MAX as 32bit, 6 channels. */
pthread_mutex_init( &this->flush_audio_driver_lock, NULL );
pthread_cond_init( &this->flush_audio_driver_reached, NULL );
@@ -2198,8 +2198,8 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
audio_buffer_t *buf;
- buf = (audio_buffer_t *) xine_xmalloc (sizeof (audio_buffer_t));
- buf->mem = xine_xmalloc (AUDIO_BUF_SIZE);
+ buf = (audio_buffer_t *) calloc(1, sizeof(audio_buffer_t));
+ buf->mem = calloc (1, AUDIO_BUF_SIZE);
buf->mem_size = AUDIO_BUF_SIZE;
buf->extra_info = malloc(sizeof(extra_info_t));
@@ -2213,8 +2213,8 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
audio_buffer_t *buf;
- buf = (audio_buffer_t *) xine_xmalloc (sizeof (audio_buffer_t));
- buf->mem = xine_xmalloc (4*AUDIO_BUF_SIZE);
+ buf = (audio_buffer_t *) calloc(1, sizeof(audio_buffer_t));
+ buf->mem = calloc(4, AUDIO_BUF_SIZE);
buf->mem_size = 4*AUDIO_BUF_SIZE;
buf->extra_info = malloc(sizeof(extra_info_t));
diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c
index 2157f0550..5fcc2ca29 100644
--- a/src/xine-engine/broadcaster.c
+++ b/src/xine-engine/broadcaster.c
@@ -324,7 +324,7 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port)
signal( SIGPIPE, SIG_IGN );
- this = xine_xmalloc(sizeof(broadcaster_t));
+ this = calloc(1, sizeof(broadcaster_t));
this->port = port;
this->stream = stream;
this->msock = msock;
diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c
index 6b6d48a11..563999bbf 100644
--- a/src/xine-engine/buffer.c
+++ b/src/xine-engine/buffer.c
@@ -501,7 +501,7 @@ fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) {
int i;
unsigned char *multi_buffer = NULL;
- this = xine_xmalloc (sizeof (fifo_buffer_t));
+ this = calloc(1, sizeof(fifo_buffer_t));
this->first = NULL;
this->last = NULL;
@@ -548,7 +548,7 @@ fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) {
for (i = 0; i<num_buffers; i++) {
buf_element_t *buf;
- buf = xine_xmalloc (sizeof (buf_element_t));
+ buf = calloc(1, sizeof(buf_element_t));
buf->mem = multi_buffer;
multi_buffer += buf_size;
diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c
index c3b698be7..91113cdfc 100644
--- a/src/xine-engine/configfile.c
+++ b/src/xine-engine/configfile.c
@@ -319,11 +319,11 @@ static void config_insert(config_values_t *this, cfg_entry_t *new_entry) {
this->first = new_entry;
}
-static cfg_entry_t *config_add (config_values_t *this, const char *key, int exp_level) {
+static cfg_entry_t *XINE_MALLOC config_add (config_values_t *this, const char *key, int exp_level) {
cfg_entry_t *entry;
- entry = (cfg_entry_t *) xine_xmalloc (sizeof (cfg_entry_t));
+ entry = calloc (1, sizeof (cfg_entry_t));
entry->config = this;
entry->key = strdup(key);
entry->type = XINE_CONFIG_TYPE_UNKNOWN;
@@ -369,8 +369,7 @@ static const char *config_translate_key (const char *key) {
*/
if (!strncmp (key, "decoder.", 8) &&
!strcmp (key + (trans = strlen (key)) - 9, "_priority")) {
- newkey = realloc (newkey, trans + 27 - 17); /* diff. in string lengths */
- sprintf (newkey, "engine.decoder_priorities.%.*s", trans - 17, key + 8);
+ asprintf (&newkey, "engine.decoder_priorities.%.*s", trans - 17, key + 8);
return newkey;
}
@@ -1015,7 +1014,7 @@ void xine_config_save (xine_t *xine, const char *filename) {
char *buf = NULL;
size_t rlen;
- buf = (char *) xine_xmalloc(config_stat.st_size + 1);
+ buf = (char *) malloc(config_stat.st_size + 1);
if((rlen = fread(buf, 1, config_stat.st_size, f_config)) && ((off_t)rlen == config_stat.st_size)) {
(void) fwrite(buf, 1, rlen, f_backup);
}
@@ -1537,7 +1536,7 @@ config_values_t *_x_config_init (void) {
config_values_t *this;
pthread_mutexattr_t attr;
- if (!(this = xine_xmalloc(sizeof(config_values_t)))) {
+ if (!(this = calloc(1, sizeof(config_values_t)))) {
printf ("configfile: could not allocate config object\n");
_x_abort();
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index e641bbf77..5e1bb0ff0 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -47,11 +47,6 @@
#include <winsock.h>
#endif
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a,b) ( (a) < (b) ) ? (a) : (b)
-
/*
* Flush audio and video buffers. It is called from demuxers on
* seek/stop, and may be useful when user input changes a stream and
@@ -440,7 +435,7 @@ int _x_demux_read_header( input_plugin_t *input, void *buffer, off_t size){
read_size = input->read(input, buffer, size);
input->seek(input, 0, SEEK_SET);
} else if (input->get_capabilities(input) & INPUT_CAP_PREVIEW) {
- buf = xine_xmalloc(MAX_PREVIEW_SIZE);
+ buf = malloc(MAX_PREVIEW_SIZE);
read_size = input->get_optional_data(input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
read_size = MIN (read_size, size);
memcpy(buffer, buf, read_size);
@@ -670,7 +665,7 @@ void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative,
xine_mrl_reference_data_ext_t *e;
xine_mrl_reference_data_t *b;
} data;
- int mrl_len = strlen (mrl);
+ const size_t mrl_len = strlen (mrl);
if (!title)
title = "";
diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c
index bc66ba24e..2665502f2 100644
--- a/src/xine-engine/info_helper.c
+++ b/src/xine-engine/info_helper.c
@@ -131,7 +131,7 @@ uint32_t _x_stream_info_get_public(xine_stream_t *stream, int info) {
* at the end of the string
*/
static void meta_info_chomp(char *str) {
- int i, len;
+ size_t i, len;
len = strlen(str);
if (!len)
@@ -340,11 +340,10 @@ void _x_meta_info_set_utf8(xine_stream_t *stream, int info, const char *str) {
void _x_meta_info_n_set(xine_stream_t *stream, int info, const char *buf, int len) {
pthread_mutex_lock(&stream->meta_mutex);
if(meta_valid(info) && len) {
- char *str = xine_xmalloc(len + 1);
+ char *str = strndup(buf, len);
- snprintf(str, len + 1 , "%s", buf);
- meta_info_set_unlocked(stream, info, (const char *) &str[0]);
- free(str);
+ meta_info_set_unlocked(stream, info, str);
+ free(str);
}
pthread_mutex_unlock(&stream->meta_mutex);
}
@@ -359,7 +358,7 @@ void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) {
va_list ap;
char *args[1025];
char *buf;
- int n, len;
+ size_t n, len;
len = n = 0;
@@ -376,7 +375,7 @@ void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) {
if(len) {
char *p, *meta;
- p = meta = (char *) xine_xmalloc(len + 1);
+ p = meta = (char *) malloc(len + 1);
n = 0;
while(args[n]) {
diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c
index 2989d8718..eafd397d7 100644
--- a/src/xine-engine/input_cache.c
+++ b/src/xine-engine/input_cache.c
@@ -34,6 +34,7 @@
*/
#include <xine/xine_internal.h>
+#include "xine_private.h"
#include <assert.h>
#define DEFAULT_BUFFER_SIZE 1024
@@ -345,7 +346,7 @@ static void cache_plugin_dispose(input_plugin_t *this_gen) {
/*
* create self instance,
*/
-input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahead_size) {
+input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream) {
cache_input_plugin_t *this;
input_plugin_t *main_plugin = stream->input_plugin;
@@ -357,7 +358,7 @@ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahe
lprintf("mrl: %s\n", main_plugin->get_mrl(main_plugin));
- this = (cache_input_plugin_t *)xine_xmalloc(sizeof(cache_input_plugin_t));
+ this = calloc(1, sizeof(cache_input_plugin_t));
if (!this)
return NULL;
@@ -387,7 +388,7 @@ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahe
this->buf_size = DEFAULT_BUFFER_SIZE;
}
- this->buf = (char *)xine_xmalloc(this->buf_size);
+ this->buf = calloc(1, this->buf_size);
if (!this->buf) {
free (this);
return NULL;
diff --git a/src/xine-engine/input_rip.c b/src/xine-engine/input_rip.c
index e7ef356b3..bfa68786d 100644
--- a/src/xine-engine/input_rip.c
+++ b/src/xine-engine/input_rip.c
@@ -65,6 +65,7 @@
#endif
#include <xine/xine_internal.h>
+#include "xine_private.h"
#ifndef HAVE_FSEEKO
# define fseeko fseek
@@ -518,10 +519,9 @@ static void rip_plugin_dispose(input_plugin_t *this_gen) {
* returns non-zero, if there was enough space
*/
static int dir_file_concat(char *target, size_t maxlen, const char *dir, const char *name) {
- size_t len_dir, len_name, pos_name = 0;
-
- len_name = strlen(name);
- len_dir = strlen(dir);
+ size_t len_name = strlen(name);
+ size_t len_dir = strlen(dir);
+ size_t pos_name = 0;
/* remove slashes */
if (dir[len_dir - 1] == '/') len_dir--;
@@ -586,7 +586,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f
return NULL;
}
- this = (rip_input_plugin_t *)xine_xmalloc(sizeof(rip_input_plugin_t));
+ this = calloc(1, sizeof(rip_input_plugin_t));
this->main_input_plugin = main_plugin;
this->stream = stream;
this->curpos = 0;
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index 710e6dfbf..2ff9f494f 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -42,8 +42,6 @@
#include <basedir.h>
-#include "load_plugins.h"
-
#define LOG_MODULE "load_plugins"
#define LOG_VERBOSE
@@ -66,6 +64,8 @@
#include <xine/xineutils.h>
#include <xine/compat.h>
+#include "xine_private.h"
+
#define LINE_MAX_LENGTH (1024 * 32) /* 32 KiB */
#if 0
@@ -99,7 +99,7 @@ static void remove_segv_handler(void){
#endif
#endif /* 0 */
-#define CACHE_CATALOG_VERSION 3
+#define CACHE_CATALOG_VERSION 4
static const int plugin_iface_versions[] = {
INPUT_PLUGIN_IFACE_VERSION,
@@ -333,8 +333,8 @@ static void _insert_node (xine_t *this,
return;
}
- entry = xine_xmalloc(sizeof(plugin_node_t));
- entry->info = xine_xmalloc(sizeof(plugin_info_t));
+ entry = calloc(1, sizeof(plugin_node_t));
+ entry->info = calloc(1, sizeof(plugin_info_t));
*(entry->info) = *info;
entry->info->id = strdup(info->id);
entry->info->init = info->init;
@@ -348,7 +348,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_VIDEO_OUT:
vo_old = info->special_info;
- vo_new = xine_xmalloc(sizeof(vo_info_t));
+ vo_new = calloc(1, sizeof(vo_info_t));
entry->priority = vo_new->priority = vo_old->priority;
vo_new->visual_type = vo_old->visual_type;
entry->info->special_info = vo_new;
@@ -356,7 +356,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_AUDIO_OUT:
ao_old = info->special_info;
- ao_new = xine_xmalloc(sizeof(ao_info_t));
+ ao_new = calloc(1, sizeof(ao_info_t));
entry->priority = ao_new->priority = ao_old->priority;
entry->info->special_info = ao_new;
break;
@@ -365,7 +365,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_VIDEO_DECODER:
case PLUGIN_SPU_DECODER:
decoder_old = info->special_info;
- decoder_new = xine_xmalloc(sizeof(decoder_info_t));
+ decoder_new = calloc(1, sizeof(decoder_info_t));
if (decoder_old == NULL) {
if (file)
xprintf (this, XINE_VERBOSITY_DEBUG,
@@ -377,12 +377,13 @@ static void _insert_node (xine_t *this,
info->id);
_x_abort();
}
- for (i=0; decoder_old->supported_types[i] != 0; ++i);
- types = xine_xmalloc((i+1)*sizeof(uint32_t));
- for (i=0; decoder_old->supported_types[i] != 0; ++i){
- types[i] = decoder_old->supported_types[i];
+ {
+ size_t supported_types_size;
+ for (supported_types_size=0; decoder_old->supported_types[supported_types_size] != 0; ++supported_types_size);
+ types = calloc((supported_types_size+1), sizeof(uint32_t));
+ memcpy(types, decoder_old->supported_types, supported_types_size*sizeof(uint32_t));
+ decoder_new->supported_types = types;
}
- decoder_new->supported_types = types;
entry->priority = decoder_new->priority = decoder_old->priority;
snprintf(key, sizeof(key), "engine.decoder_priorities.%s", info->id);
@@ -406,14 +407,14 @@ static void _insert_node (xine_t *this,
case PLUGIN_POST:
post_old = info->special_info;
- post_new = xine_xmalloc(sizeof(post_info_t));
+ post_new = calloc(1, sizeof(post_info_t));
post_new->type = post_old->type;
entry->info->special_info = post_new;
break;
case PLUGIN_DEMUX:
demux_old = info->special_info;
- demux_new = xine_xmalloc(sizeof(demuxer_info_t));
+ demux_new = calloc(1, sizeof(demuxer_info_t));
if (demux_old) {
entry->priority = demux_new->priority = demux_old->priority;
@@ -430,7 +431,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_INPUT:
input_old = info->special_info;
- input_new = xine_xmalloc(sizeof(input_info_t));
+ input_new = calloc(1, sizeof(input_info_t));
if (input_old) {
entry->priority = input_new->priority = input_old->priority;
@@ -467,12 +468,12 @@ static int _plugin_node_comparator(void *a, void *b) {
}
}
-static plugin_catalog_t *_new_catalog(void){
+static plugin_catalog_t *XINE_MALLOC _new_catalog(void){
plugin_catalog_t *catalog;
int i;
- catalog = xine_xmalloc(sizeof(plugin_catalog_t));
+ catalog = calloc(1, sizeof(plugin_catalog_t));
for (i = 0; i < PLUGIN_TYPE_MAX; i++) {
catalog->plugin_lists[i] = xine_sarray_new(0, _plugin_node_comparator);
@@ -562,26 +563,21 @@ static void collect_plugins(xine_t *this, char *path){
dir = opendir(path);
if (dir) {
struct dirent *pEntry;
- size_t path_len, str_size;
- char *str = NULL;
- path_len = strlen(path);
- str_size = path_len * 2 + 2; /* +2 for '/' and '\0' */
- str = malloc(str_size);
- xine_fast_memcpy(str, path, path_len);
- str[path_len] = '/';
- str[path_len + 1] = '\0';
+ size_t path_len = strlen(path);
+ size_t str_size = path_len * 2 + 2; /* +2 for '/' and '\0' */
+ char *str = malloc(str_size);
+ sprintf(str, "%s/", path);
while ((pEntry = readdir (dir)) != NULL) {
- size_t new_str_size, d_len;
void *lib = NULL;
plugin_info_t *info = NULL;
plugin_node_t *node = NULL;
struct stat statbuffer;
- d_len = strlen(pEntry->d_name);
- new_str_size = path_len + d_len + 2;
+ size_t d_len = strlen(pEntry->d_name);
+ size_t new_str_size = path_len + d_len + 2;
if (str_size < new_str_size) {
str_size = new_str_size + new_str_size / 2;
str = realloc(str, str_size);
@@ -1005,11 +1001,11 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) {
if( node ) {
xine_sarray_add (plugins, node);
}
- node = xine_xmalloc(sizeof(plugin_node_t));
- file = xine_xmalloc(sizeof(plugin_file_t));
+ node = calloc(1, sizeof(plugin_node_t));
+ file = calloc(1, sizeof(plugin_file_t));
node->file = file;
file->filename = strdup(line+1);
- node->info = xine_xcalloc(2, sizeof(plugin_info_t));
+ node->info = calloc(2, sizeof(plugin_info_t));
node->info[1].type = PLUGIN_NONE;
decoder_info = NULL;
vo_info = NULL;
@@ -1045,36 +1041,36 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) {
case PLUGIN_VIDEO_OUT:
node->info->special_info = vo_info =
- xine_xmalloc(sizeof(vo_info_t));
+ calloc(1, sizeof(vo_info_t));
break;
case PLUGIN_AUDIO_OUT:
node->info->special_info = ao_info =
- xine_xmalloc(sizeof(ao_info_t));
+ calloc(1, sizeof(ao_info_t));
break;
case PLUGIN_DEMUX:
node->info->special_info = demuxer_info =
- xine_xmalloc(sizeof(demuxer_info_t));
+ calloc(1, sizeof(demuxer_info_t));
break;
case PLUGIN_INPUT:
node->info->special_info = input_info =
- xine_xmalloc(sizeof(input_info_t));
+ calloc(1, sizeof(input_info_t));
break;
case PLUGIN_AUDIO_DECODER:
case PLUGIN_VIDEO_DECODER:
case PLUGIN_SPU_DECODER:
node->info->special_info = decoder_info =
- xine_xmalloc(sizeof(decoder_info_t));
+ calloc(1, sizeof(decoder_info_t));
break;
- case PLUGIN_POST:
- node->info->special_info = post_info =
- xine_xmalloc(sizeof(post_info_t));
- break;
- }
+ case PLUGIN_POST:
+ node->info->special_info = post_info =
+ calloc(1, sizeof(post_info_t));
+ break;
+ }
} else if( !strcmp("api",line) ) {
sscanf(value," %d",&i);
@@ -1094,7 +1090,7 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) {
for( s = value, i = 0; s && sscanf(s," %lu",&lu) > 0; i++ ) {
s = strchr(s+1, ' ');
}
- supported_types = xine_xcalloc((i+1), sizeof(uint32_t));
+ supported_types = calloc((i+1), sizeof(uint32_t));
for( s = value, i = 0; s && sscanf(s," %"SCNu32,&supported_types[i]) > 0; i++ ) {
s = strchr(s+1, ' ');
}
@@ -1350,6 +1346,26 @@ void _x_free_input_plugin (xine_stream_t *stream, input_plugin_t *input) {
}
}
+static int probe_mime_type (xine_t *self, plugin_node_t *node, const char *mime_type)
+{
+ /* catalog->lock is expected to be locked */
+ if (node->plugin_class || _load_plugin_class(self, node, NULL))
+ {
+ const unsigned int mime_type_len = strlen (mime_type);
+ demux_class_t *cls = (demux_class_t *)node->plugin_class;
+ const char *mime = cls->mimetypes;
+ while (mime)
+ {
+ while (*mime == ';' || isspace (*mime))
+ ++mime;
+ if (!strncasecmp (mime, mime_type, mime_type_len) &&
+ (!mime[mime_type_len] || mime[mime_type_len] == ':' || mime[mime_type_len] == ';'))
+ return 1;
+ mime = strchr (mime, ';');
+ }
+ }
+ return 0;
+}
static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int method2,
input_plugin_t *input) {
@@ -1372,8 +1388,6 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth
while (methods[i] != -1 && !plugin) {
int list_id, list_size;
- stream->content_detection_method = methods[i];
-
pthread_mutex_lock (&catalog->lock);
list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]);
@@ -1385,6 +1399,25 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth
xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: probing demux '%s'\n", node->info->id);
if (node->plugin_class || _load_plugin_class(stream->xine, node, NULL)) {
+ const char *mime_type;
+
+ /* If detecting by MRL, try the MIME type first (but not text/plain)... */
+ stream->content_detection_method = METHOD_EXPLICIT;
+ if (methods[i] == METHOD_BY_MRL &&
+ stream->input_plugin->get_optional_data &&
+ stream->input_plugin->get_optional_data (stream->input_plugin, NULL, INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED &&
+ stream->input_plugin->get_optional_data (stream->input_plugin, &mime_type, INPUT_OPTIONAL_DATA_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED &&
+ mime_type && strcasecmp (mime_type, "text/plain") &&
+ probe_mime_type (stream->xine, node, mime_type) &&
+ (plugin = ((demux_class_t *)node->plugin_class)->open_plugin (node->plugin_class, stream, input)))
+ {
+ inc_node_ref(node);
+ plugin->node = node;
+ break;
+ }
+
+ /* ... then try the extension */
+ stream->content_detection_method = methods[i];
if ( stream->content_detection_method == METHOD_BY_MRL &&
! _x_demux_check_extension(input->get_mrl(input),
((demux_class_t *)node->plugin_class)->extensions)
@@ -1802,6 +1835,36 @@ const char *const *xine_list_video_output_plugins (xine_t *xine) {
return catalog->ids;
}
+const char *const *xine_list_video_output_plugins_typed(xine_t *xine, uint64_t typemask)
+{
+ plugin_catalog_t *catalog = xine->plugin_catalog;
+ plugin_node_t *node;
+ int list_id, list_size, i;
+
+ pthread_mutex_lock (&catalog->lock);
+
+ list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]);
+
+ for (list_id = i = 0; list_id < list_size; list_id++)
+ {
+ node = xine_sarray_get (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1], list_id);
+ if (typemask & (1ULL << ((vo_info_t *)node->info->special_info)->visual_type))
+ {
+ const char *id = node->info->id;
+ int j = i;
+ while (--j >= 0)
+ if (!strcmp (catalog->ids[j], id))
+ goto ignore; /* already listed */
+ catalog->ids[i++] = id;
+ }
+ ignore: ;
+ }
+ catalog->ids[i] = NULL;
+
+ pthread_mutex_unlock (&catalog->lock);
+ return catalog->ids;
+}
+
static ao_driver_t *_load_audio_driver (xine_t *this, plugin_node_t *node,
void *data) {
@@ -2527,6 +2590,32 @@ void xine_post_dispose(xine_t *xine, xine_post_t *post_gen) {
* their disposal if they are still in use => post.c handles the counting for us */
}
+/**
+ * @brief Concantenates an array of strings into a single
+ * string separated with a given string.
+ *
+ * @param strings Array of strings to concatenate.
+ * @param count Number of elements in the @p strings array.
+ * @param joining String to use to join the various strings together.
+ * @param final_length The pre-calculated final length of the string.
+ */
+static char *_x_concatenate_with_string(char **strings, size_t count, char *joining, size_t final_length) {
+ size_t i;
+ char *const result = malloc(final_length+1); /* Better be safe */
+ char *str = result;
+
+ size_t pos = 0;
+ for(i = 0; i < count; i++, strings++) {
+ if ( *strings ) {
+ int offset = snprintf(str, final_length, "%s%s", *strings, joining);
+ str += offset;
+ final_length -= offset;
+ }
+ }
+
+ return result;
+}
+
/* get a list of file extensions for file types supported by xine
* the list is separated by spaces
*
@@ -2534,65 +2623,35 @@ void xine_post_dispose(xine_t *xine, xine_post_t *post_gen) {
char *xine_get_file_extensions (xine_t *self) {
plugin_catalog_t *catalog = self->plugin_catalog;
- int len, pos;
- plugin_node_t *node;
- char *str;
- int list_id, list_size;
- const char *exts;
+ int list_id;
pthread_mutex_lock (&catalog->lock);
- /* calc length of output */
+ /* calc length of output string and create an array of strings to
+ concatenate */
+ size_t len = 0;
+ const int list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
+ const char **extensions = calloc(list_size, sizeof(char*));
- len = 0;
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
+ plugin_node_t *const node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- if( (exts = cls->extensions) && *exts )
- len += strlen(exts) + 1;
+ demux_class_t *const cls = (demux_class_t *)node->plugin_class;
+ if( (extensions[list_id] = cls->extensions) != NULL )
+ len += strlen(extensions[list_id]) +1;
}
}
- /* create output */
- str = malloc (len); /* '\0' space is already counted in the previous loop */
- pos = 0;
-
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
- for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
- int l;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
- if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- if((exts = cls->extensions) && *exts) {
- l = strlen(exts);
- memcpy (&str[pos], exts, l);
-
- pos += l;
-
- /* Don't add ' ' char at the end of str */
- if((pos + 1) < len) {
- str[pos] = ' ';
- pos++;
- }
- }
- }
- }
-
- str[pos] = 0;
+ /* create output string */
+ char *const result = _x_concatenate_with_string(extensions, list_size, " ", len);
+ free(extensions);
+ /* Drop the last whitespace */
+ result[len-1] = '\0';
+
pthread_mutex_unlock (&catalog->lock);
- return str;
+ return result;
}
/* get a list of mime types supported by xine
@@ -2601,60 +2660,34 @@ char *xine_get_file_extensions (xine_t *self) {
char *xine_get_mime_types (xine_t *self) {
plugin_catalog_t *catalog = self->plugin_catalog;
- int len, pos;
- plugin_node_t *node;
- char *str;
- int list_id, list_size;
+ int list_id;
pthread_mutex_lock (&catalog->lock);
/* calc length of output */
- len = 0;
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
+ /* calc length of output string and create an array of strings to
+ concatenate */
+ size_t len = 0;
+ const int list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
+ const char **mimetypes = calloc(list_size, sizeof(char*));
for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
+ plugin_node_t *const node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- if ( cls->mimetypes )
- len += strlen(cls->mimetypes);
+ demux_class_t *const cls = (demux_class_t *)node->plugin_class;
+ if( (mimetypes[list_id] = cls->mimetypes) != NULL )
+ len += strlen(mimetypes[list_id]);
}
}
- /* create output */
-
- str = malloc (len+1);
- pos = 0;
-
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
-
- for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
- if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
+ /* create output string */
+ char *const result = _x_concatenate_with_string(mimetypes, list_size, "", len);
+ free(mimetypes);
- cls = (demux_class_t *)node->plugin_class;
-
- if (cls->mimetypes) {
- const size_t l = strlen(cls->mimetypes);
- memcpy (&str[pos], cls->mimetypes, l);
-
- pos += l;
- }
- }
- }
-
- str[pos] = 0;
-
pthread_mutex_unlock (&catalog->lock);
- return str;
+ return result;
}
@@ -2674,15 +2707,12 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) {
list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
for (list_id = 0; (list_id < list_size) && !id; list_id++) {
- demux_class_t *cls;
node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
- if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- if (cls->mimetypes && strcasestr(cls->mimetypes, mime_type) )
- id = strdup(node->info->id);
+ if (probe_mime_type (self, node, mime_type))
+ {
+ free (id);
+ id = strdup(node->info->id);
}
}
diff --git a/src/xine-engine/load_plugins.h b/src/xine-engine/load_plugins.h
deleted file mode 100644
index 7e7d3cc93..000000000
--- a/src/xine-engine/load_plugins.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2007 the xine project
- *
- * This file is part of xine, a free video player.
- *
- * xine is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * xine is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- */
-
-/**
- * @file
- * @brief Internal functions related to the plugin catalog.
- *
- * @internal This code should not be used by plugins or frontends, it's only
- * used by the xine-engine.
- */
-
-#ifndef __LOAD_PLUGINS_H__
-#define __LOAD_PLUGINS_H__
-
-#include <xine.h>
-
-/*
- * load plugins into catalog
- *
- * all input+demux plugins will be fully loaded+initialized
- * decoder plugins are loaded on demand
- * video/audio output plugins have special load/probe functions
- */
-void _x_scan_plugins (xine_t *this);
-
-
-/*
- * dispose all currently loaded plugins (shutdown)
- */
-
-void _x_dispose_plugins (xine_t *this);
-
-#endif
diff --git a/src/xine-engine/lrb.c b/src/xine-engine/lrb.c
index a2fc5d1da..6c624143c 100644
--- a/src/xine-engine/lrb.c
+++ b/src/xine-engine/lrb.c
@@ -30,7 +30,7 @@ lrb_t *lrb_new (int max_num_entries,
lrb_t *this;
- this = xine_xmalloc (sizeof (lrb_t));
+ this = calloc(1, sizeof(lrb_t));
this->max_num_entries = max_num_entries;
this->cur_num_entries = 0;
diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c
index 42aed4e76..b120181b4 100644
--- a/src/xine-engine/metronom.c
+++ b/src/xine-engine/metronom.c
@@ -172,10 +172,10 @@ static void unixscr_exit (scr_plugin_t *scr) {
free(this);
}
-static scr_plugin_t* unixscr_init () {
+static scr_plugin_t *XINE_MALLOC unixscr_init () {
unixscr_t *this;
- this = (unixscr_t *) xine_xmalloc(sizeof(unixscr_t));
+ this = calloc(1, sizeof(unixscr_t));
this->scr.interface_version = 3;
this->scr.get_priority = unixscr_get_priority;
@@ -909,7 +909,7 @@ static void metronom_clock_exit (metronom_clock_t *this) {
metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) {
- metronom_t *this = xine_xmalloc (sizeof (metronom_t));
+ metronom_t *this = calloc(1, sizeof (metronom_t));
this->set_audio_rate = metronom_set_audio_rate;
this->got_video_frame = metronom_got_video_frame;
@@ -962,7 +962,7 @@ metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) {
metronom_clock_t *_x_metronom_clock_init(xine_t *xine)
{
- metronom_clock_t *this = (metronom_clock_t *) xine_xmalloc(sizeof(metronom_clock_t));
+ metronom_clock_t *this = calloc(1, sizeof(metronom_clock_t));
int err;
this->set_option = metronom_clock_set_option;
diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c
index 907b20c8e..f0fe25e29 100644
--- a/src/xine-engine/osd.c
+++ b/src/xine-engine/osd.c
@@ -83,17 +83,6 @@
# define UCS2_ENCODING "UCS-2LE"
#endif
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a,b) ( (a) > (b) ) ? (a) : (b)
-
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a,b) ( (a) < (b) ) ? (a) : (b)
-
-
#if (FREETYPE_MAJOR > 2) || \
(FREETYPE_MAJOR == 2 && FREETYPE_MINOR > 1) || \
(FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 3)
@@ -237,13 +226,13 @@ struct osd_ft2context_s {
* for the sake of simplicity)
*/
-static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height) {
+static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width, int height) {
osd_object_t *osd;
pthread_mutex_lock (&this->osd_mutex);
- osd = xine_xmalloc( sizeof(osd_object_t) );
+ osd = calloc(1, sizeof(osd_object_t));
osd->renderer = this;
osd->next = this->osds;
this->osds = osd;
@@ -764,7 +753,7 @@ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) {
/* fixme: check for all read errors... */
if( (fp = gzopen(filename,"rb")) != NULL ) {
- font = xine_xmalloc( sizeof(osd_font_t) );
+ font = calloc(1, sizeof(osd_font_t));
gzread(fp, font->name, sizeof(font->name) );
font->version = gzread_i16(fp);
@@ -999,7 +988,7 @@ static int osd_lookup_xdg( osd_object_t *osd, const char *const fontname ) {
static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int size ) {
if (!osd->ft2) {
- osd->ft2 = xine_xmalloc(sizeof(osd_ft2context_t));
+ osd->ft2 = calloc(1, sizeof(osd_ft2context_t));
if(FT_Init_FreeType( &osd->ft2->library )) {
xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG,
_("osd: cannot initialize ft2 library\n"));
@@ -1542,10 +1531,9 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) {
if( p ) {
osd_font_t *font;
- char *pathname;
*p++ = '\0';
- font = xine_xmalloc( sizeof(osd_font_t) );
+ font = calloc(1, sizeof(osd_font_t) );
strncpy(font->name, s, sizeof(font->name));
font->size = atoi(p);
@@ -1553,9 +1541,7 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) {
lprintf("font '%s' size %d is preloaded\n",
font->name, font->size);
- pathname = (char *) xine_xmalloc(strlen(path) + strlen(entry->d_name) + 2);
- sprintf (pathname, "%s/%s", path, entry->d_name);
- font->filename = pathname;
+ asprintf (&font->filename, "%s/%s", path, entry->d_name);
font->next = this->fonts;
this->fonts = font;
@@ -1710,9 +1696,9 @@ osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) {
osd_renderer_t *this;
- this = xine_xmalloc(sizeof(osd_renderer_t));
+ this = calloc(1, sizeof(osd_renderer_t));
this->stream = stream;
- this->event.object.overlay = xine_xmalloc( sizeof(vo_overlay_t) );
+ this->event.object.overlay = calloc(1, sizeof(vo_overlay_t));
pthread_mutex_init (&this->osd_mutex, NULL);
diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c
index 651bb10f3..3315e2aa3 100644
--- a/src/xine-engine/post.c
+++ b/src/xine-engine/post.c
@@ -217,7 +217,7 @@ static int post_video_rewire(xine_post_out_t *output_gen, void *data) {
post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_port_t *original,
post_in_t **input, post_out_t **output) {
- post_video_port_t *port = (post_video_port_t *)xine_xmalloc(sizeof(post_video_port_t));
+ post_video_port_t *port = calloc(1, sizeof(post_video_port_t));
if (!port)
return NULL;
@@ -246,7 +246,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_
pthread_mutex_init(&port->free_frames_lock, NULL);
if (input) {
- *input = (post_in_t *)xine_xmalloc(sizeof(post_in_t));
+ *input = calloc(1, sizeof(post_in_t));
if (!*input) return port;
(*input)->xine_in.name = "video in";
(*input)->xine_in.type = XINE_POST_DATA_VIDEO;
@@ -256,7 +256,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_
}
if (output) {
- *output = (post_out_t *)xine_xmalloc(sizeof(post_out_t));
+ *output = calloc(1, sizeof(post_out_t));
if (!*output) return port;
(*output)->xine_out.name = "video out";
(*output)->xine_out.type = XINE_POST_DATA_VIDEO;
@@ -364,7 +364,7 @@ vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *
new_frame = port->free_frame_slots;
port->free_frame_slots = new_frame->next;
} else {
- new_frame = (vo_frame_t *)xine_xmalloc(sizeof(vo_frame_t));
+ new_frame = calloc(1, sizeof(vo_frame_t));
}
pthread_mutex_unlock(&port->free_frames_lock);
@@ -730,7 +730,7 @@ static int post_audio_rewire(xine_post_out_t *output_gen, void *data) {
post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_port_t *original,
post_in_t **input, post_out_t **output) {
- post_audio_port_t *port = (post_audio_port_t *)xine_xmalloc(sizeof(post_audio_port_t));
+ post_audio_port_t *port = calloc(1, sizeof(post_audio_port_t));
if (!port)
return NULL;
@@ -753,7 +753,7 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_
pthread_mutex_init(&port->usage_lock, NULL);
if (input) {
- *input = (post_in_t *)xine_xmalloc(sizeof(post_in_t));
+ *input = calloc(1, sizeof(post_in_t));
if (!*input) return port;
(*input)->xine_in.name = "audio in";
(*input)->xine_in.type = XINE_POST_DATA_AUDIO;
@@ -763,7 +763,7 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_
}
if (output) {
- *output = (post_out_t *)xine_xmalloc(sizeof(post_out_t));
+ *output = calloc(1, sizeof(post_out_t));
if (!*output) return port;
(*output)->xine_out.name = "audio out";
(*output)->xine_out.type = XINE_POST_DATA_AUDIO;
diff --git a/src/xine-engine/refcounter.c b/src/xine-engine/refcounter.c
index 4bb6a0351..8bf04d2a7 100644
--- a/src/xine-engine/refcounter.c
+++ b/src/xine-engine/refcounter.c
@@ -30,7 +30,7 @@ refcounter_t* _x_new_refcounter(void *object, void (*destructor)(void *))
{
refcounter_t *new_refcounter;
- new_refcounter = (refcounter_t *) xine_xmalloc (sizeof (refcounter_t));
+ new_refcounter = (refcounter_t *) calloc(1, sizeof(refcounter_t));
new_refcounter->count = 1;
new_refcounter->object = object;
new_refcounter->destructor = destructor;
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
index 7376a3f9e..f01ea9c7d 100644
--- a/src/xine-engine/scratch.c
+++ b/src/xine-engine/scratch.c
@@ -49,12 +49,11 @@ static void __attribute__((__format__(__printf__, 2, 0)))
localtime_r (&t, &tm);
if ( ! this->lines[this->cur] )
- this->lines[this->cur] = xine_xmalloc(SCRATCH_LINE_LEN_MAX+1);
+ this->lines[this->cur] = malloc(SCRATCH_LINE_LEN_MAX+1);
if ( ! this->lines[this->cur] )
return;
- strftime (this->lines[this->cur], SCRATCH_LINE_LEN_MAX, "%X: ", &tm);
- l = strlen (this->lines[this->cur]);
+ l = strftime (this->lines[this->cur], SCRATCH_LINE_LEN_MAX, "%X: ", &tm);
vsnprintf (this->lines[this->cur] + l, SCRATCH_LINE_LEN_MAX - l, format, argp);
lprintf ("printing format %s to line %d\n", format, this->cur);
@@ -105,10 +104,10 @@ static void scratch_dispose (scratch_buffer_t *this) {
scratch_buffer_t *_x_new_scratch_buffer (int num_lines) {
scratch_buffer_t *this;
- this = xine_xmalloc (sizeof (scratch_buffer_t));
+ this = calloc(1, sizeof(scratch_buffer_t));
- this->lines = xine_xcalloc ((num_lines + 1), sizeof(char*));
- this->ordered = xine_xcalloc ((num_lines + 1), sizeof(char*));
+ this->lines = calloc ((num_lines + 1), sizeof(char*));
+ this->ordered = calloc ((num_lines + 1), sizeof(char*));
this->scratch_printf = scratch_printf;
this->get_content = scratch_get_content;
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index ca6e7aa23..3cc4e37f7 100644
--- a/src/xine-engine/video_decoder.c
+++ b/src/xine-engine/video_decoder.c
@@ -37,6 +37,7 @@
#include <xine/xine_internal.h>
#include <xine/xineutils.h>
+#include "xine_private.h"
#include <sched.h>
#define SPU_SLEEP_INTERVAL (90000/2)
diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c
index 0bab612ce..6a2d751bd 100644
--- a/src/xine-engine/video_out.c
+++ b/src/xine-engine/video_out.c
@@ -142,11 +142,11 @@ typedef struct {
* frame queue (fifo) util functions
*/
-static img_buf_fifo_t *vo_new_img_buf_queue () {
+static img_buf_fifo_t *XINE_MALLOC vo_new_img_buf_queue () {
img_buf_fifo_t *queue;
- queue = (img_buf_fifo_t *) xine_xmalloc (sizeof (img_buf_fifo_t));
+ queue = (img_buf_fifo_t *) calloc(1, sizeof(img_buf_fifo_t));
if( queue ) {
queue->first = NULL;
queue->last = NULL;
@@ -1815,7 +1815,7 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon
int num_frame_buffers;
- this = xine_xmalloc (sizeof (vos_t)) ;
+ this = calloc(1, sizeof(vos_t)) ;
this->xine = xine;
this->clock = xine->clock;
diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c
index 44080c469..b551ac53c 100644
--- a/src/xine-engine/video_overlay.c
+++ b/src/xine-engine/video_overlay.c
@@ -199,7 +199,7 @@ static void video_overlay_reset (video_overlay_t *this) {
pthread_mutex_lock (&this->events_mutex);
for (i=0; i < MAX_EVENTS; i++) {
if (this->events[i].event == NULL) {
- this->events[i].event = xine_xmalloc (sizeof(video_overlay_event_t));
+ this->events[i].event = calloc(1, sizeof(video_overlay_event_t));
#ifdef LOG_DEBUG
printf ("video_overlay: MALLOC2: this->events[%d].event %p, len=%d\n",
i,
@@ -293,7 +293,7 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void
event->object.overlay->hili_trans[i] = OVL_MAX_OPACITY;
}
- this->events[new_event].event->object.overlay = xine_xmalloc (sizeof(vo_overlay_t));
+ this->events[new_event].event->object.overlay = calloc(1, sizeof(vo_overlay_t));
xine_fast_memcpy(this->events[new_event].event->object.overlay,
event->object.overlay, sizeof(vo_overlay_t));
@@ -587,7 +587,7 @@ video_overlay_manager_t *_x_video_overlay_new_manager (xine_t *xine) {
video_overlay_t *this;
- this = (video_overlay_t *) xine_xmalloc (sizeof (video_overlay_t));
+ this = (video_overlay_t *) calloc(1, sizeof(video_overlay_t));
this->xine = xine;
this->video_overlay.init = video_overlay_init;
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 5c8d0be9d..1e7c5c2c7 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -81,8 +81,7 @@
# include <winsock.h>
#endif /* WIN32 */
-#include "load_plugins.h"
-
+#include "xine_private.h"
static void mutex_cleanup (void *mutex) {
pthread_mutex_unlock ((pthread_mutex_t *) mutex);
@@ -339,10 +338,10 @@ static void ticket_dispose(xine_ticket_t *this) {
free(this);
}
-static xine_ticket_t *ticket_init(void) {
+static xine_ticket_t *XINE_MALLOC ticket_init(void) {
xine_ticket_t *port_ticket;
- port_ticket = (xine_ticket_t *) xine_xmalloc(sizeof(xine_ticket_t));
+ port_ticket = calloc(1, sizeof(xine_ticket_t));
port_ticket->acquire_nonblocking = ticket_acquire_nonblocking;
port_ticket->acquire = ticket_acquire;
@@ -612,7 +611,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
pthread_mutex_lock (&this->streams_lock);
- stream = (xine_stream_t *) xine_xmalloc (sizeof (xine_stream_t)) ;
+ stream = (xine_stream_t *) calloc (1, sizeof (xine_stream_t)) ;
stream->current_extra_info = malloc( sizeof( extra_info_t ) );
stream->audio_decoder_extra_info = malloc( sizeof( extra_info_t ) );
stream->video_decoder_extra_info = malloc( sizeof( extra_info_t ) );
@@ -778,7 +777,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
}
void _x_mrl_unescape(char *mrl) {
- int i, len = strlen(mrl);
+ size_t i, len = strlen(mrl);
for (i = 0; i < len; i++) {
if ((mrl[i]=='%') && (i<(len-2))) {
@@ -1227,7 +1226,28 @@ static int open_internal (xine_stream_t *stream, const char *mrl) {
if( !no_cache )
/* enable buffered input plugin (request optimizer) */
- stream->input_plugin = _x_cache_plugin_get_instance(stream, 0);
+ stream->input_plugin = _x_cache_plugin_get_instance(stream);
+
+ /* Let the plugin request a specific demuxer (if the user hasn't).
+ * This overrides find-by-content & find-by-extension.
+ */
+ if (!stream->demux_plugin)
+ {
+ char *default_demux = NULL;
+ stream->input_plugin->get_optional_data (stream->input_plugin, &default_demux, INPUT_OPTIONAL_DATA_DEMUXER);
+ if (default_demux)
+ {
+ stream->demux_plugin = _x_find_demux_plugin_by_name (stream, default_demux, stream->input_plugin);
+ if (stream->demux_plugin)
+ {
+ lprintf ("demux and input plugin found\n");
+ _x_meta_info_set_utf8 (stream, XINE_META_INFO_SYSTEMLAYER,
+ stream->demux_plugin->demux_class->identifier);
+ }
+ else
+ xine_log (stream->xine, XINE_LOG_MSG, _("xine: couldn't load plugin-specified demux %s for >%s<\n"), default_demux, mrl);
+ }
+ }
if (!stream->demux_plugin) {
@@ -1592,7 +1612,7 @@ xine_t *xine_new (void) {
int i_err;
#endif
- this = xine_xmalloc (sizeof (xine_t));
+ this = calloc(1, sizeof (xine_t));
if (!this)
_x_abort();
@@ -1982,53 +2002,60 @@ int xine_get_pos_length (xine_stream_t *stream, int *pos_stream,
return 1;
}
-static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *height,
- int *ratio_code, int *format,
- uint8_t **img, int *size, int alloc_img) {
+static int _x_get_current_frame_data (xine_stream_t *stream,
+ xine_current_frame_data_t *data,
+ int flags, int img_size_unknown) {
vo_frame_t *frame;
- int required_size;
+ size_t required_size;
stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0);
frame = stream->video_out->get_last_frame (stream->video_out);
stream->xine->port_ticket->release(stream->xine->port_ticket, 0);
- if (!frame)
+ if (!frame) {
+ data->img_size = 0;
return 0;
+ }
- *width = frame->width;
- *height = frame->height;
+ data->width = frame->width;
+ data->height = frame->height;
+ data->crop_left = frame->crop_left;
+ data->crop_right = frame->crop_right;
+ data->crop_top = frame->crop_top;
+ data->crop_bottom = frame->crop_bottom;
- *ratio_code = 10000.0 * frame->ratio;
+ data->ratio_code = 10000.0 * frame->ratio;
/* make ratio_code backward compatible */
#define RATIO_LIKE(a, b) ((b) - 1 <= (a) && (a) <= 1 + (b))
- if (RATIO_LIKE(*ratio_code, 10000))
- *ratio_code = XINE_VO_ASPECT_SQUARE;
- else if (RATIO_LIKE(*ratio_code, 13333))
- *ratio_code = XINE_VO_ASPECT_4_3;
- else if (RATIO_LIKE(*ratio_code, 17778))
- *ratio_code = XINE_VO_ASPECT_ANAMORPHIC;
- else if (RATIO_LIKE(*ratio_code, 21100))
- *ratio_code = XINE_VO_ASPECT_DVB;
+ if (RATIO_LIKE(data->ratio_code, 10000))
+ data->ratio_code = XINE_VO_ASPECT_SQUARE;
+ else if (RATIO_LIKE(data->ratio_code, 13333))
+ data->ratio_code = XINE_VO_ASPECT_4_3;
+ else if (RATIO_LIKE(data->ratio_code, 17778))
+ data->ratio_code = XINE_VO_ASPECT_ANAMORPHIC;
+ else if (RATIO_LIKE(data->ratio_code, 21100))
+ data->ratio_code = XINE_VO_ASPECT_DVB;
- *format = frame->format;
+ data->format = frame->format;
+ data->interlaced = frame->progressive_frame ? 0 : (2 - frame->top_field_first);
- switch (*format) {
+ switch (frame->format) {
case XINE_IMGFMT_YV12:
- required_size = *width * *height
- + ((*width + 1) / 2) * ((*height + 1) / 2)
- + ((*width + 1) / 2) * ((*height + 1) / 2);
+ required_size = frame->width * frame->height
+ + ((frame->width + 1) / 2) * ((frame->height + 1) / 2)
+ + ((frame->width + 1) / 2) * ((frame->height + 1) / 2);
break;
case XINE_IMGFMT_YUY2:
- required_size = *width * *height
- + ((*width + 1) / 2) * *height
- + ((*width + 1) / 2) * *height;
+ required_size = frame->width * frame->height
+ + ((frame->width + 1) / 2) * frame->height
+ + ((frame->width + 1) / 2) * frame->height;
break;
default:
- if (*img || alloc_img) {
+ if (data->img || (flags & XINE_FRAME_DATA_ALLOCATE_IMG)) {
xprintf (stream->xine, XINE_VERBOSITY_DEBUG,
"xine: error, snapshot function not implemented for format 0x%x\n", frame->format);
_x_abort ();
@@ -2037,38 +2064,36 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
required_size = 0;
}
- if (alloc_img) {
- /* return size if requested */
- if (size)
- *size = required_size;
+ if (flags & XINE_FRAME_DATA_ALLOCATE_IMG) {
+ /* return allocated buffer size */
+ data->img_size = required_size;
/* allocate img or fail */
- if (!(*img = xine_xmalloc (required_size)))
+ if (!(data->img = calloc(1, required_size)))
return 0;
} else {
/* fail if supplied buffer is to small */
- if (*img && size && *size < required_size) {
- *size = required_size;
+ if (data->img && !img_size_unknown && data->img_size < required_size) {
+ data->img_size = required_size;
return 0;
}
- /* return size if requested */
- if (size)
- *size = required_size;
+ /* return used buffer size */
+ data->img_size = required_size;
}
- if (*img) {
+ if (data->img) {
switch (frame->format) {
case XINE_IMGFMT_YV12:
yv12_to_yv12(
/* Y */
frame->base[0], frame->pitches[0],
- *img, frame->width,
+ data->img, frame->width,
/* U */
frame->base[1], frame->pitches[1],
- *img+frame->width*frame->height, frame->width/2,
+ data->img+frame->width*frame->height, frame->width/2,
/* V */
frame->base[2], frame->pitches[2],
- *img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2,
+ data->img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2,
/* width x height */
frame->width, frame->height);
break;
@@ -2078,7 +2103,7 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
/* src */
frame->base[0], frame->pitches[0],
/* dst */
- *img, frame->width*2,
+ data->img, frame->width*2,
/* width x height */
frame->width, frame->height);
break;
@@ -2092,23 +2117,67 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
return 1;
}
+int xine_get_current_frame_data (xine_stream_t *stream,
+ xine_current_frame_data_t *data,
+ int flags) {
+
+ return _x_get_current_frame_data(stream, data, flags, 0);
+}
+
int xine_get_current_frame_alloc (xine_stream_t *stream, int *width, int *height,
int *ratio_code, int *format,
- uint8_t **img, int *size) {
- uint8_t *no_img = NULL;
- return _x_get_current_frame_impl(stream, width, height, ratio_code, format, img ? img : &no_img, size, img != NULL);
+ uint8_t **img, int *img_size) {
+
+ int result;
+ xine_current_frame_data_t data;
+
+ memset(&data, 0, sizeof (data));
+
+ result = _x_get_current_frame_data(stream, &data, img ? XINE_FRAME_DATA_ALLOCATE_IMG : 0, 0);
+ if (width) *width = data.width;
+ if (height) *height = data.height;
+ if (ratio_code) *ratio_code = data.ratio_code;
+ if (format) *format = data.format;
+ if (img_size) *img_size = data.img_size;
+ if (img) *img = data.img;
+ return result;
}
int xine_get_current_frame_s (xine_stream_t *stream, int *width, int *height,
int *ratio_code, int *format,
- uint8_t *img, int *size) {
- return (!img || size) && _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, size, 0);
+ uint8_t *img, int *img_size) {
+ int result;
+ xine_current_frame_data_t data;
+
+ memset(&data, 0, sizeof (data));
+ data.img = img;
+ if (img_size)
+ data.img_size = *img_size;
+
+ result = _x_get_current_frame_data(stream, &data, 0, 0);
+ if (width) *width = data.width;
+ if (height) *height = data.height;
+ if (ratio_code) *ratio_code = data.ratio_code;
+ if (format) *format = data.format;
+ if (img_size) *img_size = data.img_size;
+ return result;
}
int xine_get_current_frame (xine_stream_t *stream, int *width, int *height,
int *ratio_code, int *format,
uint8_t *img) {
- return _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, NULL, 0);
+ int result;
+ xine_current_frame_data_t data;
+
+ memset(&data, 0, sizeof (data));
+ data.img = img;
+
+ result = _x_get_current_frame_data(stream, &data, 0, 1);
+ if (width) *width = data.width;
+ if (height) *height = data.height;
+ if (ratio_code) *ratio_code = data.ratio_code;
+ if (format) *format = data.format;
+ return result;
}
int xine_get_video_frame (xine_stream_t *stream,
@@ -2230,6 +2299,9 @@ void xine_log (xine_t *this, int buf, const char *format, ...) {
printf("%s", buffer);
va_end (argp);
}
+
+ if (this->log_cb)
+ this->log_cb (this->log_cb_user_data, buf);
}
void xine_vlog(xine_t *this, int buf, const char *format,
@@ -2238,6 +2310,9 @@ void xine_vlog(xine_t *this, int buf, const char *format,
check_log_alloc (this, buf);
this->log_buffers[buf]->scratch_printf(this->log_buffers[buf], format, args);
+
+ if (this->log_cb)
+ this->log_cb (this->log_cb_user_data, buf);
}
char *const *xine_get_log (xine_t *this, int buf) {
@@ -2252,21 +2327,14 @@ char *const *xine_get_log (xine_t *this, int buf) {
}
void xine_register_log_cb (xine_t *this, xine_log_cb_t cb, void *user_data) {
-
- printf ("xine: xine_register_log_cb: not implemented yet.\n");
- _x_abort();
+ this->log_cb = cb;
+ this->log_cb_user_data = user_data;
}
-
int xine_get_error (xine_stream_t *stream) {
return stream->err;
}
-int xine_trick_mode (xine_stream_t *stream, int mode, int value) {
- printf ("xine: xine_trick_mode not implemented yet.\n");
- _x_abort ();
-}
-
int xine_stream_master_slave(xine_stream_t *master, xine_stream_t *slave,
int affection) {
master->slave = slave;
diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c
index c731a936f..07da930fb 100644
--- a/src/xine-engine/xine_interface.c
+++ b/src/xine-engine/xine_interface.c
@@ -936,7 +936,7 @@ int _x_message(xine_stream_t *stream, int type, ...) {
xine_ui_message_data_t *data;
xine_event_t event;
const char *explanation;
- int size;
+ size_t size;
int n;
va_list ap;
char *s, *params;
@@ -981,7 +981,7 @@ int _x_message(xine_stream_t *stream, int type, ...) {
args[n] = NULL;
size += sizeof(xine_ui_message_data_t) + 1;
- data = xine_xmalloc( size );
+ data = calloc(1, size );
strcpy(data->compatibility.str, "Upgrade your frontend to see the error messages");
data->type = type;
diff --git a/src/xine-engine/xine_private.h b/src/xine-engine/xine_private.h
new file mode 100644
index 000000000..6fb215bab
--- /dev/null
+++ b/src/xine-engine/xine_private.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2000-2008 the xine project
+ *
+ * This file is part of xine, a free video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+/**
+ * @file
+ * @brief Declaration of internal, private functions for xine-lib.
+ *
+ * @internal These functions should not be used by neither plugins nor
+ * frontends.
+ */
+
+#ifndef XINE_PRIVATE_H__
+#define XINE_PRIVATE_H__
+
+#include <config.h>
+#include <xine/xine_internal.h>
+
+#if SUPPORT_ATTRIBUTE_VISIBILITY_INTERNAL
+# define INTERNAL __attribute__((visibility("internal")))
+#else
+# define INTERNAL
+#endif
+
+/**
+ * @defgroup load_plugins Plugins loading
+ * @brief Functions related with plugins loading.
+ */
+
+/**
+ * @ingroup load_plugins
+ * @brief Load plugins into catalog
+ * @param this xine instance
+ *
+ * All input and demux plugins will be fully loaded and initialized.
+ * Decoder plugins are loaded on demand. Video/audio output plugins
+ * have special load/probe functions
+ */
+void _x_scan_plugins (xine_t *this) INTERNAL;
+
+/**
+ * @ingroup load_plugins
+ * @brief Dispose (shutdown) all currently loaded plugins
+ * @param this xine instance
+ */
+void _x_dispose_plugins (xine_t *this) INTERNAL;
+
+///@{
+/**
+ * @defgroup
+ * @brief find and instantiate input and demux plugins
+ */
+input_plugin_t *_x_find_input_plugin (xine_stream_t *stream, const char *mrl) INTERNAL;
+demux_plugin_t *_x_find_demux_plugin (xine_stream_t *stream, input_plugin_t *input) INTERNAL;
+demux_plugin_t *_x_find_demux_plugin_by_name (xine_stream_t *stream, const char *name, input_plugin_t *input) INTERNAL;
+demux_plugin_t *_x_find_demux_plugin_last_probe(xine_stream_t *stream, const char *last_demux_name, input_plugin_t *input) INTERNAL;
+input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *filename) INTERNAL;
+input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream) INTERNAL;
+void _x_free_input_plugin (xine_stream_t *stream, input_plugin_t *input) INTERNAL;
+void _x_free_demux_plugin (xine_stream_t *stream, demux_plugin_t *demux) INTERNAL;
+///@}
+
+///@{
+/**
+ * @defgroup
+ * @brief create decoder fifos and threads
+*/
+
+int _x_video_decoder_init (xine_stream_t *stream) INTERNAL;
+void _x_video_decoder_shutdown (xine_stream_t *stream) INTERNAL;
+
+int _x_audio_decoder_init (xine_stream_t *stream) INTERNAL;
+void _x_audio_decoder_shutdown (xine_stream_t *stream) INTERNAL;
+///@}
+
+/**
+ * @brief Benchmark available memcpy methods
+ */
+void xine_probe_fast_memcpy(xine_t *xine) INTERNAL;
+
+#endif
diff --git a/src/xine-utils/Makefile.am b/src/xine-utils/Makefile.am
index 0c664b0be..9dd7f64d6 100644
--- a/src/xine-utils/Makefile.am
+++ b/src/xine-utils/Makefile.am
@@ -5,7 +5,7 @@ AM_CPPFLAGS = -DXINE_LIBRARY_COMPILE
EXTRA_DIST = ppcasm_string.S ppc_asm.tmpl
-noinst_HEADERS = ppcasm_string.h xine_check.h mangle.h
+noinst_HEADERS = ppcasm_string.h mangle.h
noinst_LTLIBRARIES = libxineutils.la
diff --git a/src/xine-utils/list.c b/src/xine-utils/list.c
index 7a2b521bd..e57a6e604 100644
--- a/src/xine-utils/list.c
+++ b/src/xine-utils/list.c
@@ -67,9 +67,9 @@ struct xine_list_s {
/* Allocates a new chunk of n elements
* One malloc call is used to allocate the struct and the elements.
*/
-static xine_list_chunk_t *xine_list_alloc_chunk(size_t size) {
+static xine_list_chunk_t *XINE_MALLOC xine_list_alloc_chunk(size_t size) {
xine_list_chunk_t *new_chunk;
- size_t chunk_mem_size;;
+ size_t chunk_mem_size;
chunk_mem_size = sizeof(xine_list_chunk_t);
chunk_mem_size += sizeof(xine_list_elem_t) * size;
diff --git a/src/xine-utils/pool.c b/src/xine-utils/pool.c
index 60330ef53..9dbe4c736 100644
--- a/src/xine-utils/pool.c
+++ b/src/xine-utils/pool.c
@@ -55,7 +55,7 @@ struct xine_pool_s {
/* Allocates a new chunk of n elements
* One malloc call is used to allocate the struct and the elements.
*/
-static xine_pool_chunk_t *xine_pool_alloc_chunk(size_t object_size, size_t object_count) {
+static xine_pool_chunk_t *XINE_MALLOC xine_pool_alloc_chunk(size_t object_size, size_t object_count) {
xine_pool_chunk_t *new_chunk;
size_t chunk_mem_size;;
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index d2105c5a2..8b01bd52b 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -236,7 +236,25 @@ static const lang_locale_t lang_locales[] = {
{ "" }
};
-
+/**
+ * @brief Allocate and clean memory size_t 'size', then return the
+ * pointer to the allocated memory.
+ * @param size Size of the memory area to allocate.
+ *
+ * @return A pointer to the allocated memory area, or NULL in case of
+ * error.
+ *
+ * The behaviour of this function differs from standard malloc() as
+ * xine_xmalloc(0) will not return a NULL pointer, but rather a
+ * pointer to a memory area of size 1 byte.
+ *
+ * The NULL value is only ever returned in case of an error in
+ * malloc(), and is reported to stderr stream.
+ *
+ * @deprecated This function has been deprecated, as the behaviour of
+ * allocating a 1 byte memory area on zero size is almost
+ * never desired, and the function is thus mostly misused.
+ */
void *xine_xmalloc(size_t size) {
void *ptr;
@@ -393,6 +411,20 @@ static void xine_get_rootdir(char *rootdir, size_t maxlen) {
if ((s = strrchr(rootdir, XINE_DIRECTORY_SEPARATOR_CHAR))) *s = '\0';
}
+const char *xine_get_pluginroot(void) {
+ static char pluginroot[1024] = {0, };
+
+ if (!pluginroot[0]) {
+ char *sep, *sep2;
+ strcpy (pluginroot, xine_get_plugindir ());
+ sep = strrchr (pluginroot, '/');
+ sep2 = strrchr (pluginroot, '\\');
+ *(sep < sep2 ? sep : sep2) = 0;
+ }
+
+ return pluginroot;
+}
+
const char *xine_get_plugindir(void) {
static char plugindir[1024] = {0, };
@@ -481,7 +513,7 @@ void xine_usec_sleep(unsigned usec) {
void xine_hexdump (const void *buf_gen, int length) {
static const char separator[70] = "---------------------------------------------------------------------";
- const uint8_t *const buf = (const uint8_t*)buf;
+ const uint8_t *const buf = (const uint8_t*)buf_gen;
int j = 0;
/* printf ("Hexdump: %i Bytes\n", length);*/
@@ -500,11 +532,7 @@ void xine_hexdump (const void *buf_gen, int length) {
}
for (i=j; i < imax; i++) {
- uint8_t c = buf[i];
- if ((c>=32) && (c<127))
- c = '.';
-
- fputc(c, stdout);
+ fputc ((buf[i] >= 32 && buf[i] <= 126) ? buf[i] : '.', stdout);
}
j=i;
@@ -517,7 +545,7 @@ void xine_hexdump (const void *buf_gen, int length) {
static const lang_locale_t *_get_first_lang_locale(const char *lcal) {
const lang_locale_t *llocale;
- int lang_len;
+ size_t lang_len;
char *mod;
if(lcal && *lcal) {
@@ -684,3 +712,11 @@ int xine_monotonic_clock(struct timeval *tv, struct timezone *tz)
#endif
}
+
+char *xine_strcat_realloc (char **dest, char *append)
+{
+ char *newstr = realloc (*dest, (*dest ? strlen (*dest) : 0) + strlen (append) + 1);
+ if (newstr)
+ strcat (*dest = newstr, append);
+ return newstr;
+}
diff --git a/src/xine-utils/xine_buffer.c b/src/xine-utils/xine_buffer.c
index 3891aec11..8dea081ec 100644
--- a/src/xine-utils/xine_buffer.c
+++ b/src/xine-utils/xine_buffer.c
@@ -117,7 +117,7 @@ typedef struct {
*/
void *xine_buffer_init(int chunk_size) {
- uint8_t *data=xine_xmalloc(chunk_size+XINE_BUFFER_HEADER_SIZE);
+ uint8_t *data=calloc(1, chunk_size+XINE_BUFFER_HEADER_SIZE);
xine_buffer_header_t *header=(xine_buffer_header_t*)data;
header->size=chunk_size;
@@ -162,7 +162,7 @@ void *xine_buffer_dup(const void *buf) {
CHECK_MAGIC(buf);
#endif
-new=xine_xmalloc(GET_HEADER(buf)->size+XINE_BUFFER_HEADER_SIZE);
+ new = malloc(GET_HEADER(buf)->size+XINE_BUFFER_HEADER_SIZE);
xine_fast_memcpy(new, ((uint8_t*)buf)-XINE_BUFFER_HEADER_SIZE,
GET_HEADER(buf)->size+XINE_BUFFER_HEADER_SIZE);
diff --git a/src/xine-utils/xine_check.c b/src/xine-utils/xine_check.c
index e850f9f48..9887915de 100644
--- a/src/xine-utils/xine_check.c
+++ b/src/xine-utils/xine_check.c
@@ -44,7 +44,6 @@
#include <fcntl.h>
#include <unistd.h>
-#include "xine_check.h"
#include <xine/xineutils.h>
#if defined(__linux__)
@@ -102,38 +101,7 @@ set_hc_result(xine_health_check_t* hc, int state, const char *format, ...)
#if defined(__linux__)
-xine_health_check_t* xine_health_check (xine_health_check_t* hc, int check_num) {
-
- switch(check_num) {
- case CHECK_KERNEL:
- hc = _x_health_check_kernel (hc);
- break;
- case CHECK_MTRR:
- hc = _x_health_check_mtrr (hc);
- break;
- case CHECK_CDROM:
- hc = _x_health_check_cdrom (hc);
- break;
- case CHECK_DVDROM:
- hc = _x_health_check_dvdrom (hc);
- break;
- case CHECK_DMA:
- hc = _x_health_check_dma (hc);
- break;
- case CHECK_X:
- hc = _x_health_check_x (hc);
- break;
- case CHECK_XV:
- hc = _x_health_check_xv (hc);
- break;
- default:
- hc->status = XINE_HEALTH_CHECK_NO_SUCH_CHECK;
- }
-
- return hc;
-}
-
-xine_health_check_t* _x_health_check_kernel (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_kernel (xine_health_check_t* hc) {
struct utsname kernel;
hc->title = "Check for kernel version";
@@ -153,7 +121,7 @@ xine_health_check_t* _x_health_check_kernel (xine_health_check_t* hc) {
}
#if defined(ARCH_X86) || defined(ARCH_X86_64)
-xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) {
FILE *fd;
hc->title = "Check for MTRR support";
@@ -170,7 +138,7 @@ xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) {
return hc;
}
#else
-xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) {
hc->title = "Check for MTRR support";
hc->explanation = "Don't worry about this one";
@@ -181,7 +149,7 @@ xine_health_check_t* _x_health_check_mtrr (xine_health_check_t* hc) {
}
#endif
-xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) {
struct stat cdrom_st;
int fd;
@@ -217,7 +185,7 @@ xine_health_check_t* _x_health_check_cdrom (xine_health_check_t* hc) {
return hc;
}
-xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) {
struct stat dvdrom_st;
int fd;
@@ -253,7 +221,7 @@ xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t* hc) {
return hc;
}
-xine_health_check_t* _x_health_check_dma (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_dma (xine_health_check_t* hc) {
int is_scsi_dev = 0;
int fd = 0;
@@ -307,7 +275,7 @@ xine_health_check_t* _x_health_check_dma (xine_health_check_t* hc) {
}
-xine_health_check_t* _x_health_check_x (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_x (xine_health_check_t* hc) {
char* env_display = getenv("DISPLAY");
hc->title = "Check for X11 environment";
@@ -323,7 +291,7 @@ xine_health_check_t* _x_health_check_x (xine_health_check_t* hc) {
return hc;
}
-xine_health_check_t* _x_health_check_xv (xine_health_check_t* hc) {
+static xine_health_check_t* _x_health_check_xv (xine_health_check_t* hc) {
#ifdef HAVE_X11
#ifdef HAVE_XV
@@ -497,6 +465,37 @@ xine_health_check_t* _x_health_check_xv (xine_health_check_t* hc) {
#endif /* ! HAVE_X11 */
}
+xine_health_check_t* xine_health_check (xine_health_check_t* hc, int check_num) {
+
+ switch(check_num) {
+ case CHECK_KERNEL:
+ hc = _x_health_check_kernel (hc);
+ break;
+ case CHECK_MTRR:
+ hc = _x_health_check_mtrr (hc);
+ break;
+ case CHECK_CDROM:
+ hc = _x_health_check_cdrom (hc);
+ break;
+ case CHECK_DVDROM:
+ hc = _x_health_check_dvdrom (hc);
+ break;
+ case CHECK_DMA:
+ hc = _x_health_check_dma (hc);
+ break;
+ case CHECK_X:
+ hc = _x_health_check_x (hc);
+ break;
+ case CHECK_XV:
+ hc = _x_health_check_xv (hc);
+ break;
+ default:
+ hc->status = XINE_HEALTH_CHECK_NO_SUCH_CHECK;
+ }
+
+ return hc;
+}
+
#else /* !__linux__ */
xine_health_check_t* xine_health_check (xine_health_check_t* hc, int check_num) {
hc->title = "xine health check not supported on this platform";
diff --git a/src/xine-utils/xine_check.h b/src/xine-utils/xine_check.h
deleted file mode 100644
index 75eda102d..000000000
--- a/src/xine-utils/xine_check.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef XINE_CHECK_H
-#define XINE_CHECK_H
-#include <stdio.h>
-
-#include <xine.h>
-
-/*
- * Start checking xine setup here
- *
- * cdrom_dev = Name of the device link for the cdrom drive (e.g. /dev/cdrom)
- * dvd_dev = Name of the device link for the dvd drive (e.g. /dev/dvd)
- */
-
-/* Get Kernel information */
-xine_health_check_t* _x_health_check_kernel(xine_health_check_t*);
-
-/* health_check MTRR */
-xine_health_check_t* _x_health_check_mtrr(xine_health_check_t*);
-
-/* health_check CDROM */
-xine_health_check_t* _x_health_check_cdrom(xine_health_check_t*);
-
-/* health_check DVDROM */
-xine_health_check_t* _x_health_check_dvdrom(xine_health_check_t*);
-
-/* health_check DMA settings of DVD drive*/
-xine_health_check_t* _x_health_check_dma(xine_health_check_t*);
-
-/* health_check X */
-xine_health_check_t* _x_health_check_x(xine_health_check_t*);
-
-/* health_check Xv extension */
-xine_health_check_t* _x_health_check_xv(xine_health_check_t*);
-
-#endif
diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c
index 394ca397f..b2be2a5e5 100644
--- a/src/xine-utils/xmllexer.c
+++ b/src/xine-utils/xmllexer.c
@@ -29,7 +29,6 @@
#include <xine/xineutils.h>
#else
#define lprintf(...)
-#define xine_xmalloc malloc
#endif
#include <xine/xmllexer.h>
#include <stdio.h>
@@ -592,7 +591,7 @@ static struct {
char *lexer_decode_entities (const char *tok)
{
- char *buf = xine_xmalloc (strlen (tok) + 1);
+ char *buf = calloc (strlen (tok) + 1, sizeof(char));
char *bp = buf;
char c;
diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c
index 0c3d12f59..d8ecb251c 100644
--- a/src/xine-utils/xmlparser.c
+++ b/src/xine-utils/xmlparser.c
@@ -40,7 +40,7 @@
#include <xine/xineutils.h>
#else
#define lprintf(...)
-#define xine_xmalloc malloc
+#define XINE_MALLOC
#endif
#include <xine/xmllexer.h>
#include <xine/xmlparser.h>
@@ -86,7 +86,7 @@ static void free_xml_node(xml_node_t * node) {
free(node);
}
-static xml_property_t * new_xml_property(void) {
+static xml_property_t *XINE_MALLOC new_xml_property(void) {
xml_property_t * new_property;
new_property = (xml_property_t*) malloc(sizeof(xml_property_t));
@@ -645,11 +645,12 @@ static int xml_parser_get_node (xml_node_t *current_node, int flags)
int token_buffer_size = TOKEN_SIZE;
int pname_buffer_size = TOKEN_SIZE;
int nname_buffer_size = TOKEN_SIZE;
- char *token_buffer = xine_xmalloc (token_buffer_size);
- char *pname_buffer = xine_xmalloc (pname_buffer_size);
- char *nname_buffer = xine_xmalloc (nname_buffer_size);
+ char *token_buffer = calloc(1, token_buffer_size);
+ char *pname_buffer = calloc(1, pname_buffer_size);
+ char *nname_buffer = calloc(1, nname_buffer_size);
char *root_names[MAX_RECURSION + 1];
root_names[0] = "";
+
res = xml_parser_get_node_internal (&token_buffer, &token_buffer_size,
&pname_buffer, &pname_buffer_size,
&nname_buffer, &nname_buffer_size,
@@ -794,7 +795,7 @@ static int xml_escape_string_internal (char *buf, const char *s,
char *xml_escape_string (const char *s, xml_escape_quote_t quote_type)
{
- char *buf = xine_xmalloc (xml_escape_string_internal (NULL, s, quote_type));
+ char *buf = calloc (1, xml_escape_string_internal (NULL, s, quote_type));
return buf ? (xml_escape_string_internal (buf, s, quote_type), buf) : NULL;
}
@@ -802,11 +803,10 @@ static void xml_parser_dump_node (const xml_node_t *node, int indent) {
xml_property_t *p;
xml_node_t *n;
- int l;
printf ("%*s<%s ", indent, "", node->name);
- l = strlen (node->name);
+ size_t l = strlen (node->name);
p = node->props;
while (p) {