2020#include <config.h>
2121#endif
2222
23+ #include <stdbool.h>
2324#include <stdint.h>
2425#include <stdio.h>
2526#include <stdlib.h>
@@ -134,7 +135,7 @@ typedef struct ebml_st {
134135
135136 ssize_t cluster_start ;
136137 ebml_keyframe_status cluster_starts_with_keyframe ;
137- int flush_cluster ;
138+ bool flush_cluster ;
138139
139140 size_t position ;
140141 unsigned char * buffer ;
@@ -149,14 +150,14 @@ typedef struct ebml_st {
149150
150151 uint_least64_t keyframe_track_number ;
151152 uint_least64_t parsing_track_number ;
152- int parsing_track_is_video ;
153+ bool parsing_track_is_video ;
153154} ebml_t ;
154155
155156typedef struct ebml_source_state_st {
156157
157158 ebml_t * ebml ;
158159 refbuf_t * header ;
159- int file_headers_written ;
160+ bool file_headers_written ;
160161
161162} ebml_source_state_t ;
162163
@@ -189,7 +190,7 @@ static ssize_t ebml_parse_var_int(unsigned char *buffer,
189190static ssize_t ebml_parse_sized_int (unsigned char * buffer ,
190191 unsigned char * buffer_end ,
191192 size_t len ,
192- int is_signed ,
193+ bool is_signed ,
193194 uint_least64_t * out_value );
194195static inline void ebml_check_track (ebml_t * ebml );
195196
@@ -383,14 +384,14 @@ static void ebml_write_buf_to_file (source_t *source, refbuf_t *refbuf)
383384
384385 ebml_source_state_t * ebml_source_state = source -> format -> _state ;
385386
386- if (ebml_source_state -> file_headers_written == 0 )
387+ if ( ! ebml_source_state -> file_headers_written )
387388 {
388389 if (fwrite (ebml_source_state -> header -> data , 1 ,
389390 ebml_source_state -> header -> len ,
390391 source -> dumpfile ) != ebml_source_state -> header -> len )
391392 ebml_write_buf_to_file_fail (source );
392393 else
393- ebml_source_state -> file_headers_written = 1 ;
394+ ebml_source_state -> file_headers_written = true ;
394395 }
395396
396397 if (fwrite (refbuf -> data , 1 , refbuf -> len , source -> dumpfile ) != refbuf -> len )
@@ -427,7 +428,7 @@ static ebml_t *ebml_create()
427428
428429 ebml -> keyframe_track_number = EBML_UNKNOWN ;
429430 ebml -> parsing_track_number = EBML_UNKNOWN ;
430- ebml -> parsing_track_is_video = 0 ;
431+ ebml -> parsing_track_is_video = false ;
431432
432433 return ebml ;
433434
@@ -465,7 +466,7 @@ static size_t ebml_read_space(ebml_t *ebml)
465466 * we have no choice but to start flushing it.
466467 */
467468
468- ebml -> flush_cluster = 1 ;
469+ ebml -> flush_cluster = true ;
469470 }
470471
471472 if (ebml -> flush_cluster ) {
@@ -601,7 +602,7 @@ static unsigned char *ebml_get_write_buffer(ebml_t *ebml, size_t *bytes)
601602 */
602603static ssize_t ebml_wrote (ebml_t * ebml , size_t len )
603604{
604- int processing = 1 ;
605+ bool processing = true ;
605606 size_t cursor = 0 ;
606607 size_t to_copy ;
607608 unsigned char * end_of_buffer ;
@@ -670,7 +671,7 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
670671
671672 if (track_number_length == 0 ) {
672673 /* Wait for more data */
673- processing = 0 ;
674+ processing = false ;
674675 } else if (track_number_length < 0 ) {
675676 return -1 ;
676677 } else if (track_number == ebml -> keyframe_track_number ) {
@@ -679,7 +680,7 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
679680 /* skip the 16-bit timecode for now, read the flags byte */
680681 if (cursor + tag_length + track_number_length + 2 >= ebml -> input_position ) {
681682 /* Wait for more data */
682- processing = 0 ;
683+ processing = false ;
683684 } else {
684685 flags = ebml -> input_buffer [cursor + tag_length + track_number_length + 2 ];
685686
@@ -701,7 +702,7 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
701702 /* Parse all TrackEntry children; reset the state */
702703 payload_length = 0 ;
703704 ebml -> parsing_track_number = EBML_UNKNOWN ;
704- ebml -> parsing_track_is_video = 0 ;
705+ ebml -> parsing_track_is_video = false ;
705706
706707 } else if (!memcmp (ebml -> input_buffer + cursor , TRACK_NUMBER_MAGIC , COMMON_MAGIC_LEN )) {
707708 /* Probe TrackNumber for value */
@@ -710,7 +711,7 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
710711
711712 if (value_length == 0 ) {
712713 /* Wait for more data */
713- processing = 0 ;
714+ processing = false ;
714715 } else if (value_length < 0 ) {
715716 return -1 ;
716717 } else {
@@ -725,13 +726,13 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
725726
726727 if (value_length == 0 ) {
727728 /* Wait for more data */
728- processing = 0 ;
729+ processing = false ;
729730 } else if (value_length < 0 ) {
730731 return -1 ;
731732 } else {
732733 if (data_value & 0x01 ) {
733734 /* This is a video track (0x01 flag = video) */
734- ebml -> parsing_track_is_video = 1 ;
735+ ebml -> parsing_track_is_video = true ;
735736 ebml_check_track (ebml );
736737 }
737738 }
@@ -748,7 +749,7 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
748749 } else if (tag_length == 0 ) {
749750 /* Wait for more data */
750751 /* ICECAST_LOG_DEBUG("Wait"); */
751- processing = 0 ;
752+ processing = false ;
752753 } else if (tag_length < 0 ) {
753754 /* Parse error */
754755 /* ICECAST_LOG_DEBUG("Stop"); */
@@ -764,8 +765,8 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
764765 */
765766 if (ebml -> cluster_start >= 0 ) {
766767 /* Allow the cluster in the read buffer to flush. */
767- ebml -> flush_cluster = 1 ;
768- processing = 0 ;
768+ ebml -> flush_cluster = true ;
769+ processing = false ;
769770 } else {
770771
771772 tag_length = ebml_parse_tag (ebml -> input_buffer + cursor ,
@@ -779,7 +780,7 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
779780 ebml -> cluster_starts_with_keyframe = EBML_KEYFRAME_UNKNOWN ;
780781
781782 /* Buffer data to give us time to probe for keyframes, etc. */
782- ebml -> flush_cluster = 0 ;
783+ ebml -> flush_cluster = false ;
783784
784785 /* Copy cluster tag to read buffer */
785786 ebml -> copy_len = tag_length ;
@@ -825,13 +826,13 @@ static ssize_t ebml_wrote(ebml_t *ebml, size_t len)
825826 }
826827 } else {
827828 /* wait for more data */
828- processing = 0 ;
829+ processing = false ;
829830 }
830831
831832 break ;
832833
833834 default :
834- processing = 0 ;
835+ processing = false ;
835836
836837 }
837838
@@ -973,7 +974,7 @@ static ssize_t ebml_parse_var_int(unsigned char *buffer,
973974static ssize_t ebml_parse_sized_int (unsigned char * buffer ,
974975 unsigned char * buffer_end ,
975976 size_t len ,
976- int is_signed ,
977+ bool is_signed ,
977978 uint_least64_t * out_value )
978979{
979980 uint_least64_t value ;
0 commit comments