# HG changeset patch # User reimar # Date 1126035619 0 # Node ID 719f5f7094c9cda8b950dd61bf0dce1c5bbf0b25 # Parent ab358dda8a514ad2884edc01774e73687fca3a2a Changes forgotten during demuxer API change, introduce a check function. diff -r ab358dda8a51 -r 719f5f7094c9 libmpdemux/demux_mpc.c --- a/libmpdemux/demux_mpc.c Tue Sep 06 19:05:30 2005 +0000 +++ b/libmpdemux/demux_mpc.c Tue Sep 06 19:40:19 2005 +0000 @@ -46,11 +46,9 @@ return out & mask; } -static int demux_mpc_open(demuxer_t* demuxer) { +static int demux_mpc_check(demuxer_t* demuxer) { stream_t *s = demuxer->stream; - sh_audio_t* sh_audio; uint8_t hdr[HDR_SIZE]; - da_priv_t* priv; int i; if (stream_read(s, hdr, HDR_SIZE) != HDR_SIZE) @@ -64,6 +62,15 @@ if (hdr[0] != 'M' || hdr[1] != 'P' || hdr[2] != '+') return 0; + demuxer->priv = malloc(HDR_SIZE); + memcpy(demuxer->priv, hdr, HDR_SIZE); + return DEMUXER_TYPE_MPC; +} + +static demuxer_t *demux_mpc_open(demuxer_t* demuxer) { + stream_t *s = demuxer->stream; + sh_audio_t* sh_audio; + da_priv_t* priv = demuxer->priv; sh_audio = new_sh_audio(demuxer,0); @@ -72,7 +79,8 @@ char *header = &wf[sizeof(WAVEFORMATEX)]; const int freqs[4] = {44100, 48000, 37800, 32000}; sh_audio->format = mmioFOURCC('M', 'P', 'C', ' '); - memcpy(header, hdr, HDR_SIZE); + memcpy(header, priv, HDR_SIZE); + free(priv); sh_audio->wf = (WAVEFORMATEX *)wf; sh_audio->wf->wFormatTag = sh_audio->format; sh_audio->wf->nChannels = 2; @@ -101,15 +109,14 @@ sh_audio->audio.dwScale = 32 * 36; sh_audio->audio.dwRate = sh_audio->samplerate; - return DEMUXER_TYPE_MPC; + return demuxer; } -static int demux_mpc_fill_buffer(demux_stream_t *ds, demux_stream_t *dsds) { +static int demux_mpc_fill_buffer(demuxer_t *demux, demux_stream_t *ds) { int l; int bit_len; demux_packet_t* dp; sh_audio_t* sh_audio = ds->sh; - demuxer_t* demux = ds->demuxer; da_priv_t* priv = demux->priv; stream_t* s = demux->stream; sh_audio = ds->sh; @@ -159,9 +166,9 @@ "supports v7 bitstream only", DEMUXER_TYPE_MPC, 0, // unsafe autodetect - demux_mpc_open, + demux_mpc_check, demux_mpc_fill_buffer, - NULL, + demux_mpc_open, demux_close_mpc, demux_mpc_seek, demux_mpc_control