8 char *edl_filename
; // file to extract EDL entries from (-edl)
9 char *edl_output_filename
; // file to put EDL entries in (-edlout)
12 * Allocates a new EDL record and makes sure allocation was successful.
14 * \return New allocated EDL record.
15 * \brief Allocate new EDL record
18 static edl_record_ptr
edl_alloc_new(edl_record_ptr next_edl_record
)
20 edl_record_ptr new_record
= calloc(1, sizeof(struct edl_record
));
22 mp_msg(MSGT_CPLAYER
, MSGL_FATAL
, MSGTR_EdlOutOfMem
);
26 if (next_edl_record
) // if this isn't the first record, tell the previous one what the new one is.
27 next_edl_record
->next
= new_record
;
28 new_record
->prev
= next_edl_record
;
29 new_record
->next
= NULL
;
35 * Goes through entire EDL records and frees all memory.
36 * Assumes next_edl_record is valid or NULL.
38 * \brief Free EDL memory
41 void free_edl(edl_record_ptr next_edl_record
)
44 while (next_edl_record
) {
45 tmp
= next_edl_record
->next
;
46 free(next_edl_record
);
47 next_edl_record
= tmp
;
51 /** Parses edl_filename to fill EDL operations queue.
52 * Prints out how many EDL operations recorded total.
53 * \brief Fills EDL operations queue.
56 edl_record_ptr
edl_parse_file(void)
64 edl_record_ptr edl_records
= NULL
;
65 edl_record_ptr next_edl_record
= NULL
;
69 if ((fd
= fopen(edl_filename
, "r")) == NULL
)
74 while (fgets(line
, 99, fd
) != NULL
)
77 if ((sscanf(line
, "%f %f %d", &start
, &stop
, &action
))
80 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadlyFormattedLine
,
85 if (next_edl_record
&& start
<= next_edl_record
->stop_sec
)
87 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlNOValidLine
, line
);
88 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadLineOverlap
,
89 next_edl_record
->prev
->stop_sec
, start
);
94 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlNOValidLine
,
96 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_EdlBadLineBadStop
);
99 next_edl_record
= edl_alloc_new(next_edl_record
);
100 if (!edl_records
) edl_records
= next_edl_record
;
102 next_edl_record
->action
= action
;
103 if (action
== EDL_MUTE
)
105 next_edl_record
->length_sec
= 0;
106 next_edl_record
->start_sec
= start
;
107 next_edl_record
->stop_sec
= start
;
109 next_edl_record
= edl_alloc_new(next_edl_record
);
111 next_edl_record
->action
= action
;
112 next_edl_record
->length_sec
= 0;
113 next_edl_record
->start_sec
= stop
;
114 next_edl_record
->stop_sec
= stop
;
117 next_edl_record
->length_sec
= stop
- start
;
118 next_edl_record
->start_sec
= start
;
119 next_edl_record
->stop_sec
= stop
;
127 if (edl_records
) mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdlRecordsNo
, record_count
);
128 else mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdlQueueEmpty
);