comparison ffm.c @ 1787:eb16c64144ee libavformat

This fixes error handling for BeOS, removing the need for some ifdefs. AVERROR_ defines are moved to avcodec.h as they are needed in there as well. Feel free to move that to avutil/common.h. Bumped up avcodec/format version numbers as though it's binary compatible we will want to rebuild apps as error values changed. Please from now on use return AVERROR(EFOO) instead of the ugly return -EFOO in your code. This also removes the need for berrno.h.
author mmu_man
date Tue, 13 Feb 2007 18:26:14 +0000
parents 65b7b3ff4ed7
children 491581a2b9a7
comparison
equal deleted inserted replaced
1786:8cc34fe98a3b 1787:eb16c64144ee
577 int duration; 577 int duration;
578 578
579 switch(ffm->read_state) { 579 switch(ffm->read_state) {
580 case READ_HEADER: 580 case READ_HEADER:
581 if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) { 581 if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) {
582 return -EAGAIN; 582 return AVERROR(EAGAIN);
583 } 583 }
584 #if 0 584 #if 0
585 printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n", 585 printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
586 url_ftell(&s->pb), s->pb.pos, ffm->write_index, ffm->file_size); 586 url_ftell(&s->pb), s->pb.pos, ffm->write_index, ffm->file_size);
587 #endif 587 #endif
588 if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) != 588 if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
589 FRAME_HEADER_SIZE) 589 FRAME_HEADER_SIZE)
590 return -EAGAIN; 590 return AVERROR(EAGAIN);
591 #if 0 591 #if 0
592 { 592 {
593 int i; 593 int i;
594 for(i=0;i<FRAME_HEADER_SIZE;i++) 594 for(i=0;i<FRAME_HEADER_SIZE;i++)
595 printf("%02x ", ffm->header[i]); 595 printf("%02x ", ffm->header[i]);
599 ffm->read_state = READ_DATA; 599 ffm->read_state = READ_DATA;
600 /* fall thru */ 600 /* fall thru */
601 case READ_DATA: 601 case READ_DATA:
602 size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4]; 602 size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4];
603 if (!ffm_is_avail_data(s, size)) { 603 if (!ffm_is_avail_data(s, size)) {
604 return -EAGAIN; 604 return AVERROR(EAGAIN);
605 } 605 }
606 606
607 duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7]; 607 duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7];
608 608
609 av_new_packet(pkt, size); 609 av_new_packet(pkt, size);
614 614
615 ffm->read_state = READ_HEADER; 615 ffm->read_state = READ_HEADER;
616 if (ffm_read_data(s, pkt->data, size, 0) != size) { 616 if (ffm_read_data(s, pkt->data, size, 0) != size) {
617 /* bad case: desynchronized packet. we cancel all the packet loading */ 617 /* bad case: desynchronized packet. we cancel all the packet loading */
618 av_free_packet(pkt); 618 av_free_packet(pkt);
619 return -EAGAIN; 619 return AVERROR(EAGAIN);
620 } 620 }
621 if (ffm->first_frame_in_packet) 621 if (ffm->first_frame_in_packet)
622 { 622 {
623 pkt->pts = ffm->pts; 623 pkt->pts = ffm->pts;
624 ffm->first_frame_in_packet = 0; 624 ffm->first_frame_in_packet = 0;