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

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: rebase 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
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
33 packet_(packet.Pass()) { 33 packet_(packet.Pass()) {
34 } 34 }
35 35
36 virtual ~AVPacketBuffer() {} 36 virtual ~AVPacketBuffer() {}
37 37
38 // Buffer implementation. 38 // Buffer implementation.
39 virtual const uint8* GetData() const { 39 virtual const uint8* GetData() const {
40 return reinterpret_cast<const uint8*>(packet_->data); 40 return reinterpret_cast<const uint8*>(packet_->data);
41 } 41 }
42 42
43 virtual size_t GetDataSize() const { 43 virtual int GetDataSize() const {
44 return static_cast<size_t>(packet_->size); 44 return packet_->size;
45 } 45 }
46 46
47 private: 47 private:
48 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet_; 48 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet_;
49 49
50 DISALLOW_COPY_AND_ASSIGN(AVPacketBuffer); 50 DISALLOW_COPY_AND_ASSIGN(AVPacketBuffer);
51 }; 51 };
52 52
53 53
54 // 54 //
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if (read_has_failed_) 382 if (read_has_failed_)
383 return AVERROR(EIO); 383 return AVERROR(EIO);
384 384
385 // Even though FFmpeg defines AVERROR_EOF, it's not to be used with I/O 385 // Even though FFmpeg defines AVERROR_EOF, it's not to be used with I/O
386 // routines. Instead return 0 for any read at or past EOF. 386 // routines. Instead return 0 for any read at or past EOF.
387 int64 file_size; 387 int64 file_size;
388 if (data_source_->GetSize(&file_size) && read_position_ >= file_size) 388 if (data_source_->GetSize(&file_size) && read_position_ >= file_size)
389 return 0; 389 return 0;
390 390
391 // Asynchronous read from data source. 391 // Asynchronous read from data source.
392 data_source_->Read(read_position_, size, data, 392 data_source_->Read(read_position_, size, data, base::Bind(
393 base::Bind(&FFmpegDemuxer::OnReadCompleted, this)); 393 &FFmpegDemuxer::SignalReadCompleted, this));
394 394
395 // TODO(hclam): The method is called on the demuxer thread and this method 395 // TODO(hclam): The method is called on the demuxer thread and this method
396 // call will block the thread. We need to implemented an additional thread to 396 // call will block the thread. We need to implemented an additional thread to
397 // let FFmpeg demuxer methods to run on. 397 // let FFmpeg demuxer methods to run on.
398 size_t last_read_bytes = WaitForRead(); 398 int last_read_bytes = WaitForRead();
399 if (last_read_bytes == DataSource::kReadError) { 399 if (last_read_bytes == DataSource::kReadError) {
400 if (host()) 400 if (host())
401 host()->OnDemuxerError(PIPELINE_ERROR_READ); 401 host()->OnDemuxerError(PIPELINE_ERROR_READ);
402 else 402 else
403 deferred_status_ = PIPELINE_ERROR_READ; 403 deferred_status_ = PIPELINE_ERROR_READ;
404 404
405 // Returns with a negative number to signal an error to FFmpeg. 405 // Returns with a negative number to signal an error to FFmpeg.
406 read_has_failed_ = true; 406 read_has_failed_ = true;
407 return AVERROR(EIO); 407 return AVERROR(EIO);
408 } 408 }
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 if (!*iter || 726 if (!*iter ||
727 (audio_disabled_ && (*iter)->type() == DemuxerStream::AUDIO)) { 727 (audio_disabled_ && (*iter)->type() == DemuxerStream::AUDIO)) {
728 continue; 728 continue;
729 } 729 }
730 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet(new AVPacket()); 730 scoped_ptr_malloc<AVPacket, ScopedPtrAVFreePacket> packet(new AVPacket());
731 memset(packet.get(), 0, sizeof(*packet.get())); 731 memset(packet.get(), 0, sizeof(*packet.get()));
732 (*iter)->EnqueuePacket(packet.Pass()); 732 (*iter)->EnqueuePacket(packet.Pass());
733 } 733 }
734 } 734 }
735 735
736 void FFmpegDemuxer::OnReadCompleted(size_t size) { 736 int FFmpegDemuxer::WaitForRead() {
737 SignalReadCompleted(size);
738 }
739
740 size_t FFmpegDemuxer::WaitForRead() {
741 read_event_.Wait(); 737 read_event_.Wait();
742 return last_read_bytes_; 738 return last_read_bytes_;
743 } 739 }
744 740
745 void FFmpegDemuxer::SignalReadCompleted(size_t size) { 741 void FFmpegDemuxer::SignalReadCompleted(int size) {
746 last_read_bytes_ = size; 742 last_read_bytes_ = size;
747 read_event_.Signal(); 743 read_event_.Signal();
748 } 744 }
749 745
750 } // namespace media 746 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698