Skip to content

Commit

Permalink
MPEG play needs to trigger a stop event when a "program end" (0xB9) i…
Browse files Browse the repository at this point in the history
…s found at the demux level.

for issue #96
  • Loading branch information
jrdennisoss committed Apr 18, 2022
1 parent d3a5a04 commit b57907c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dosbox-0.74-3/src/hardware/reelmagic_pl_mpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ static const int PLM_DEMUX_PACKET_AUDIO_2 = 0xC1;
static const int PLM_DEMUX_PACKET_AUDIO_3 = 0xC2;
static const int PLM_DEMUX_PACKET_AUDIO_4 = 0xC2;
static const int PLM_DEMUX_PACKET_VIDEO_1 = 0xE0;
static const int PLM_DEMUX_PROGRAM_END = 0xB9;


// Create a demuxer with a plm_buffer as source. This will also attempt to read
Expand Down Expand Up @@ -647,6 +648,14 @@ double plm_demux_get_duration(plm_demux_t *self, int type);

plm_packet_t *plm_demux_decode(plm_demux_t *self);

// Get whether the demux "stop on program end" flag is set

int plm_demux_get_stop_on_program_end(plm_demux_t *self);

// Sets demux "stop on program end" flag

void plm_demux_set_stop_on_program_end(plm_demux_t *self, int stop_on_program_end);



// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -1703,6 +1712,7 @@ static const int PLM_START_SYSTEM = 0xBB;
typedef struct plm_demux_t {
plm_buffer_t *buffer;
int destroy_buffer_when_done;
int stop_on_program_end;
double system_clock_ref;

size_t last_file_size;
Expand Down Expand Up @@ -2087,11 +2097,22 @@ plm_packet_t *plm_demux_decode(plm_demux_t *self) {
) {
return plm_demux_decode_packet(self, self->start_code);
}
else if (self->start_code == PLM_DEMUX_PROGRAM_END) {
if (self->stop_on_program_end) return NULL;
}
} while (self->start_code != -1);

return NULL;
}

int plm_demux_get_stop_on_program_end(plm_demux_t *self) {
return self->stop_on_program_end;
}

void plm_demux_set_stop_on_program_end(plm_demux_t *self, int stop_on_program_end) {
self->stop_on_program_end = stop_on_program_end;
}

double plm_demux_decode_time(plm_demux_t *self) {
int64_t clock = plm_buffer_read(self->buffer, 3) << 30;
plm_buffer_skip(self->buffer, 1);
Expand Down
1 change: 1 addition & 0 deletions dosbox-0.74-3/src/hardware/reelmagic_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ namespace { class ReelMagic_MediaPlayerImplementation : public ReelMagic_MediaPl
_file->GetFileSize()
);
_plm = plm_create_with_buffer(plmBuf, TRUE); //TRUE = destroy buffer when done
plm_demux_set_stop_on_program_end(_plm->demux, TRUE);

if (!plm_has_headers(_plm)) {
//failed to detect an MPEG-1 PS (muxed) stream... try MPEG-ES assuming video-only...
Expand Down

0 comments on commit b57907c

Please sign in to comment.