mirror of https://github.com/mpv-player/mpv
remove edl.c pre-alloc, more readble and safe code
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17803 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
8895e7c64c
commit
37a1bc43fe
23
edl.c
23
edl.c
|
@ -28,6 +28,7 @@ static edl_record_ptr edl_alloc_new(edl_record_ptr next_edl_record)
|
||||||
if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is.
|
if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is.
|
||||||
next_edl_record->next = new_record;
|
next_edl_record->next = new_record;
|
||||||
new_record->prev = next_edl_record;
|
new_record->prev = next_edl_record;
|
||||||
|
new_record->next = NULL;
|
||||||
|
|
||||||
return new_record;
|
return new_record;
|
||||||
}
|
}
|
||||||
|
@ -62,8 +63,8 @@ edl_record_ptr edl_parse_file(void)
|
||||||
int action;
|
int action;
|
||||||
int record_count = 0;
|
int record_count = 0;
|
||||||
int lineCount = 0;
|
int lineCount = 0;
|
||||||
edl_record_ptr edl_records = edl_alloc_new(NULL);
|
edl_record_ptr edl_records = NULL;
|
||||||
edl_record_ptr next_edl_record = edl_records;
|
edl_record_ptr next_edl_record = NULL;
|
||||||
|
|
||||||
if (edl_filename)
|
if (edl_filename)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +84,7 @@ edl_record_ptr edl_parse_file(void)
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if (next_edl_record->prev && start <= next_edl_record->prev->stop_sec)
|
if (next_edl_record && start <= next_edl_record->stop_sec)
|
||||||
{
|
{
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
|
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineOverlap,
|
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineOverlap,
|
||||||
|
@ -97,6 +98,9 @@ edl_record_ptr edl_parse_file(void)
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
|
mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
next_edl_record = edl_alloc_new(next_edl_record);
|
||||||
|
if (!edl_records) edl_records = next_edl_record;
|
||||||
|
|
||||||
next_edl_record->action = action;
|
next_edl_record->action = action;
|
||||||
if (action == EDL_MUTE)
|
if (action == EDL_MUTE)
|
||||||
{
|
{
|
||||||
|
@ -116,22 +120,15 @@ edl_record_ptr edl_parse_file(void)
|
||||||
next_edl_record->start_sec = start;
|
next_edl_record->start_sec = start;
|
||||||
next_edl_record->stop_sec = stop;
|
next_edl_record->stop_sec = stop;
|
||||||
}
|
}
|
||||||
next_edl_record = edl_alloc_new(next_edl_record);
|
|
||||||
record_count++;
|
record_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
if (next_edl_record->prev) {
|
if (edl_records) mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count);
|
||||||
next_edl_record->prev->next = NULL; // a record was before me, i don't want them thinking i'm a real record.
|
else mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty);
|
|
||||||
edl_records = NULL; // there was no previous record, we only had one record, the empty one.
|
|
||||||
}
|
|
||||||
free(next_edl_record);
|
|
||||||
return edl_records;
|
return edl_records;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue