Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1715)

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 9854031: Replace size_t with int in a few media classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 virtual ~AVPacketBuffer() { 37 virtual ~AVPacketBuffer() {
38 } 38 }
39 39
40 // Buffer implementation. 40 // Buffer implementation.
41 virtual const uint8* GetData() const { 41 virtual const uint8* GetData() const {
42 return reinterpret_cast<const uint8*>(packet_->data); 42 return reinterpret_cast<const uint8*>(packet_->data);
43 } 43 }
44 44
45 virtual size_t GetDataSize() const { 45 virtual int GetDataSize() const {
46 return static_cast<size_t>(packet_->size); 46 return packet_->size;
47 } 47 }
48 48
49 private: 49 private:
50 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet_; 50 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet_;
51 51
52 DISALLOW_COPY_AND_ASSIGN(AVPacketBuffer); 52 DISALLOW_COPY_AND_ASSIGN(AVPacketBuffer);
53 }; 53 };
54 54
55 55
56 // 56 //
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 if (read_has_failed_) 384 if (read_has_failed_)
385 return AVERROR(EIO); 385 return AVERROR(EIO);
386 386
387 // Even though FFmpeg defines AVERROR_EOF, it's not to be used with I/O 387 // Even though FFmpeg defines AVERROR_EOF, it's not to be used with I/O
388 // routines. Instead return 0 for any read at or past EOF. 388 // routines. Instead return 0 for any read at or past EOF.
389 int64 file_size; 389 int64 file_size;
390 if (data_source_->GetSize(&file_size) && read_position_ >= file_size) 390 if (data_source_->GetSize(&file_size) && read_position_ >= file_size)
391 return 0; 391 return 0;
392 392
393 // Asynchronous read from data source. 393 // Asynchronous read from data source.
394 data_source_->Read(read_position_, size, data, 394 data_source_->Read(read_position_, size, data, base::Bind(
395 base::Bind(&FFmpegDemuxer::OnReadCompleted, this)); 395 &FFmpegDemuxer::SignalReadCompleted, this));
396 396
397 // TODO(hclam): The method is called on the demuxer thread and this method 397 // TODO(hclam): The method is called on the demuxer thread and this method
398 // call will block the thread. We need to implemented an additional thread to 398 // call will block the thread. We need to implemented an additional thread to
399 // let FFmpeg demuxer methods to run on. 399 // let FFmpeg demuxer methods to run on.
400 size_t last_read_bytes = WaitForRead(); 400 int last_read_bytes = WaitForRead();
401 if (last_read_bytes == DataSource::kReadError) { 401 if (last_read_bytes == DataSource::kReadError) {
402 if (host()) 402 if (host())
403 host()->OnDemuxerError(PIPELINE_ERROR_READ); 403 host()->OnDemuxerError(PIPELINE_ERROR_READ);
404 else 404 else
405 deferred_status_ = PIPELINE_ERROR_READ; 405 deferred_status_ = PIPELINE_ERROR_READ;
406 406
407 // Returns with a negative number to signal an error to FFmpeg. 407 // Returns with a negative number to signal an error to FFmpeg.
408 read_has_failed_ = true; 408 read_has_failed_ = true;
409 return AVERROR(EIO); 409 return AVERROR(EIO);
410 } 410 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 if (!*iter || 728 if (!*iter ||
729 (audio_disabled_ && (*iter)->type() == DemuxerStream::AUDIO)) { 729 (audio_disabled_ && (*iter)->type() == DemuxerStream::AUDIO)) {
730 continue; 730 continue;
731 } 731 }
732 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet(new AVPacket()); 732 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet(new AVPacket());
733 memset(packet.get(), 0, sizeof(*packet.get())); 733 memset(packet.get(), 0, sizeof(*packet.get()));
734 (*iter)->EnqueuePacket(packet.Pass()); 734 (*iter)->EnqueuePacket(packet.Pass());
735 } 735 }
736 } 736 }
737 737
738 void FFmpegDemuxer::OnReadCompleted(size_t size) { 738 int FFmpegDemuxer::WaitForRead() {
739 SignalReadCompleted(size);
740 }
741
742 size_t FFmpegDemuxer::WaitForRead() {
743 read_event_.Wait(); 739 read_event_.Wait();
744 return last_read_bytes_; 740 return last_read_bytes_;
745 } 741 }
746 742
747 void FFmpegDemuxer::SignalReadCompleted(size_t size) { 743 void FFmpegDemuxer::SignalReadCompleted(int size) {
748 last_read_bytes_ = size; 744 last_read_bytes_ = size;
749 read_event_.Signal(); 745 read_event_.Signal();
750 } 746 }
751 747
752 } // namespace media 748 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698