| 554 | } |
| 555 | |
| 556 | bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) { |
| 557 | while (av_read_frame(FormatContext, Packet) >= 0) { |
| 558 | if (Packet->stream_index == TrackNumber) { |
| 559 | // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead. |
| 560 | if (Packet->pts == AV_NOPTS_VALUE) |
| 561 | Packet->pts = LastValidTS; |
| 562 | else |
| 563 | LastValidTS = Packet->pts; |
| 564 | |
| 565 | // This only happens if a really shitty demuxer seeks to a packet without pts *hrm* ogg *hrm* so read until a valid pts is reached |
| 566 | int64_t PacketTS = Frames.HasTS ? Packet->pts : Packet->pos; |
| 567 | if (PacketTS != AV_NOPTS_VALUE) { |
| 568 | while (PacketNumber > 0 && FrameTS(PacketNumber) > PacketTS) --PacketNumber; |
| 569 | while (FrameTS(PacketNumber) < PacketTS) ++PacketNumber; |
| 570 | return true; |
| 571 | } |
| 572 | } |
| 573 | av_packet_unref(Packet); |
| 574 | } |
| 575 | return false; |
| 576 | } |
| 577 |
nothing calls this directly
no outgoing calls
no test coverage detected