OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/filters/source_buffer_stream.h" | 5 #include "media/filters/source_buffer_stream.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 DVLOG(3) << __FUNCTION__ << " Removed " << back << " bytes from the back" | 723 DVLOG(3) << __FUNCTION__ << " Removed " << back << " bytes from the back" |
724 << " ranges_=" << RangesToString(ranges_); | 724 << " ranges_=" << RangesToString(ranges_); |
725 bytes_freed += back; | 725 bytes_freed += back; |
726 } | 726 } |
727 | 727 |
728 // If even that wasn't enough, then try greedily deleting from the front, | 728 // If even that wasn't enough, then try greedily deleting from the front, |
729 // that should allow us to remove as much data as necessary to succeed. | 729 // that should allow us to remove as much data as necessary to succeed. |
730 if (bytes_freed < bytes_to_free) { | 730 if (bytes_freed < bytes_to_free) { |
731 size_t front2 = FreeBuffers(bytes_to_free - bytes_freed, | 731 size_t front2 = FreeBuffers(bytes_to_free - bytes_freed, |
732 ranges_.back()->GetEndTimestamp(), false); | 732 ranges_.back()->GetEndTimestamp(), false); |
733 DVLOG(3) << __FUNCTION__ << " Removed " << front << " bytes from the" | 733 DVLOG(3) << __FUNCTION__ << " Removed " << front2 << " bytes from the" |
734 << " front. ranges_=" << RangesToString(ranges_); | 734 << " front. ranges_=" << RangesToString(ranges_); |
735 bytes_freed += front2; | 735 bytes_freed += front2; |
736 } | 736 } |
737 DCHECK(bytes_freed >= bytes_to_free); | 737 DCHECK(bytes_freed >= bytes_to_free); |
738 } | 738 } |
739 | 739 |
740 // Try removing data from the front of the SourceBuffer up to |media_time| | 740 // Try removing data from the front of the SourceBuffer up to |media_time| |
741 // position. | 741 // position. |
742 if (bytes_freed < bytes_to_free) { | 742 if (bytes_freed < bytes_to_free) { |
743 size_t front = FreeBuffers(bytes_to_free - bytes_freed, media_time, false); | 743 size_t front = FreeBuffers(bytes_to_free - bytes_freed, media_time, false); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 | 835 |
836 // This range will save the last GOP appended to |range_for_next_append_| | 836 // This range will save the last GOP appended to |range_for_next_append_| |
837 // if the buffers surrounding it get deleted during garbage collection. | 837 // if the buffers surrounding it get deleted during garbage collection. |
838 SourceBufferRange* new_range_for_append = NULL; | 838 SourceBufferRange* new_range_for_append = NULL; |
839 | 839 |
840 while (!ranges_.empty() && bytes_freed < total_bytes_to_free) { | 840 while (!ranges_.empty() && bytes_freed < total_bytes_to_free) { |
841 SourceBufferRange* current_range = NULL; | 841 SourceBufferRange* current_range = NULL; |
842 BufferQueue buffers; | 842 BufferQueue buffers; |
843 size_t bytes_deleted = 0; | 843 size_t bytes_deleted = 0; |
844 | 844 |
845 if (reverse_direction) { | 845 if (reverse_direction) { |
chcunningham
2016/02/16 21:27:02
I don't see that there is any check in the reverse
wolenetz
2016/02/16 22:05:05
l.848 is that check.
if last append is reached fir
servolk
2016/02/16 23:11:24
media_time is certainly useful for pending seeks,
servolk
2016/02/16 23:11:24
The reason why the next buffer position (i.e. demu
chcunningham
2016/02/16 23:36:25
Sorry missed that check
| |
846 current_range = ranges_.back(); | 846 current_range = ranges_.back(); |
847 DVLOG(5) << "current_range=" << RangeToString(*current_range); | 847 DVLOG(5) << "current_range=" << RangeToString(*current_range); |
848 if (current_range->LastGOPContainsNextBufferPosition()) { | 848 if (current_range->LastGOPContainsNextBufferPosition()) { |
849 DCHECK_EQ(current_range, selected_range_); | 849 DCHECK_EQ(current_range, selected_range_); |
850 DVLOG(5) << "current_range contains next read position, stopping GC"; | 850 DVLOG(5) << "current_range contains next read position, stopping GC"; |
851 break; | 851 break; |
852 } | 852 } |
853 DVLOG(5) << "Deleting GOP from back: " << RangeToString(*current_range); | 853 DVLOG(5) << "Deleting GOP from back: " << RangeToString(*current_range); |
854 bytes_deleted = current_range->DeleteGOPFromBack(&buffers); | 854 bytes_deleted = current_range->DeleteGOPFromBack(&buffers); |
855 } else { | 855 } else { |
856 current_range = ranges_.front(); | 856 current_range = ranges_.front(); |
857 DVLOG(5) << "current_range=" << RangeToString(*current_range); | 857 DVLOG(5) << "current_range=" << RangeToString(*current_range); |
858 if (!current_range->FirstGOPEarlierThanMediaTime(media_time)) { | 858 if (!current_range->FirstGOPEarlierThanMediaTime(media_time) || |
859 current_range->FirstGOPContainsNextBufferPosition()) { | |
wolenetz
2016/02/13 01:35:07
This is the core of the fix...
servolk
2016/02/16 19:28:38
Have you been able to figure out exactly how this
wolenetz
2016/02/16 20:12:47
Yes. I've confirmed at least one way this happens
servolk
2016/02/16 23:11:24
ok, but this requires seeking to a very precise po
chcunningham
2016/02/16 23:36:25
After chatting f2f we settled on doing the "altern
wolenetz
2016/02/16 23:37:55
Acknowledged. Unfortunately, I have been hitting t
| |
859 // We have removed all data up to the GOP that contains current playback | 860 // We have removed all data up to the GOP that contains current playback |
860 // position, we can't delete any further. | 861 // position, we can't delete any further. |
861 DVLOG(5) << "current_range contains playback position, stopping GC"; | 862 DVLOG(5) << "current_range contains playback position, stopping GC"; |
862 break; | 863 break; |
863 } | 864 } |
864 DVLOG(4) << "Deleting GOP from front: " << RangeToString(*current_range); | 865 DVLOG(4) << "Deleting GOP from front: " << RangeToString(*current_range) |
866 << ", media_time: " << media_time.InMicroseconds() | |
867 << ", current_range->HasNextBufferPosition(): " | |
868 << current_range->HasNextBufferPosition(); | |
865 bytes_deleted = current_range->DeleteGOPFromFront(&buffers); | 869 bytes_deleted = current_range->DeleteGOPFromFront(&buffers); |
866 } | 870 } |
867 | 871 |
868 // Check to see if we've just deleted the GOP that was last appended. | 872 // Check to see if we've just deleted the GOP that was last appended. |
869 DecodeTimestamp end_timestamp = buffers.back()->GetDecodeTimestamp(); | 873 DecodeTimestamp end_timestamp = buffers.back()->GetDecodeTimestamp(); |
870 if (end_timestamp == last_appended_buffer_timestamp_) { | 874 if (end_timestamp == last_appended_buffer_timestamp_) { |
871 DCHECK(last_appended_buffer_timestamp_ != kNoDecodeTimestamp()); | 875 DCHECK(last_appended_buffer_timestamp_ != kNoDecodeTimestamp()); |
872 DCHECK(!new_range_for_append); | 876 DCHECK(!new_range_for_append); |
873 | 877 |
874 // Create a new range containing these buffers. | 878 // Create a new range containing these buffers. |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 return false; | 1786 return false; |
1783 | 1787 |
1784 DCHECK_NE(have_splice_buffers, have_preroll_buffer); | 1788 DCHECK_NE(have_splice_buffers, have_preroll_buffer); |
1785 splice_buffers_index_ = 0; | 1789 splice_buffers_index_ = 0; |
1786 pending_buffer_.swap(*out_buffer); | 1790 pending_buffer_.swap(*out_buffer); |
1787 pending_buffers_complete_ = false; | 1791 pending_buffers_complete_ = false; |
1788 return true; | 1792 return true; |
1789 } | 1793 } |
1790 | 1794 |
1791 } // namespace media | 1795 } // namespace media |
OLD | NEW |