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

Side by Side Diff: media/audio/audio_device_thread.h

Issue 1487983002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fixes. Loads of files updated due to interface changes. Created 5 years 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
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 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
6 #define MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 6 #define MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 int total_segments); 43 int total_segments);
44 virtual ~Callback(); 44 virtual ~Callback();
45 45
46 // One time initialization for the callback object on the audio thread. 46 // One time initialization for the callback object on the audio thread.
47 void InitializeOnAudioThread(); 47 void InitializeOnAudioThread();
48 48
49 // Derived implementations must call shared_memory_.Map appropriately 49 // Derived implementations must call shared_memory_.Map appropriately
50 // before Process can be called. 50 // before Process can be called.
51 virtual void MapSharedMemory() = 0; 51 virtual void MapSharedMemory() = 0;
52 52
53 // Called whenever we receive notifications about pending data. 53 // Called whenever we receive notifications about pending input data.
54 virtual void Process(uint32 pending_data) = 0; 54 // |frames_skipped| contains the number of frames that has been skipped. The
55 // source can handle this appropriately depending on its type. An ordinary
56 // file playout would ignore this.
57 virtual void Process(uint32_t pending_data, uint32_t frames_skipped) = 0;
55 58
56 protected: 59 protected:
57 // Protected so that derived classes can access directly. 60 // Protected so that derived classes can access directly.
58 // The variables are 'const' since values are calculated/set in the 61 // The variables are 'const' since values are calculated/set in the
59 // constructor and must never change. 62 // constructor and must never change.
60 const AudioParameters audio_parameters_; 63 const AudioParameters audio_parameters_;
61 const int samples_per_ms_; 64 const int samples_per_ms_;
62 const int bytes_per_ms_; 65 const int bytes_per_ms_;
63 66
64 base::SharedMemory shared_memory_; 67 base::SharedMemory shared_memory_;
65 const int memory_length_; 68 const int memory_length_;
66 const int total_segments_; 69 const int total_segments_;
67 int segment_length_; 70 int segment_length_;
68 71
69 private: 72 private:
70 DISALLOW_COPY_AND_ASSIGN(Callback); 73 DISALLOW_COPY_AND_ASSIGN(Callback);
71 }; 74 };
72 75
73 AudioDeviceThread(); 76 AudioDeviceThread();
74 ~AudioDeviceThread(); 77 ~AudioDeviceThread();
75 78
76 // Starts the audio thread. The thread must not already be running. If 79 // Starts the audio thread. The thread must not already be running. If
77 // |sychronized_buffers| is set, the browser expects to be notified via the 80 // |sychronized_buffers| is set, the browser expects to be notified via the
78 // |socket| every time AudioDeviceThread::Process() completes. 81 // |socket| every time AudioDeviceThread::Process() completes. |input| should
82 // be true for input and false for output. It is used for reading the right
83 // amount of data from the socket.
84 // TODO(grunell): |input| is ugly, but there are plans to re-use a thread for
85 // multiple inputs/outputs (see todo comment above) so we do it this way
86 // meanwhile instead of using separate classes.
79 void Start(AudioDeviceThread::Callback* callback, 87 void Start(AudioDeviceThread::Callback* callback,
80 base::SyncSocket::Handle socket, 88 base::SyncSocket::Handle socket,
81 const char* thread_name, 89 const char* thread_name,
82 bool synchronized_buffers); 90 bool synchronized_buffers,
91 bool input);
83 92
84 // This tells the audio thread to stop and clean up the data. 93 // This tells the audio thread to stop and clean up the data.
85 // The method can stop the thread synchronously or asynchronously. 94 // The method can stop the thread synchronously or asynchronously.
86 // In the latter case, the thread will still be running after Stop() 95 // In the latter case, the thread will still be running after Stop()
87 // returns, but the callback pointer is cleared so no further callbacks will 96 // returns, but the callback pointer is cleared so no further callbacks will
88 // be made (IOW after Stop() returns, it is safe to delete the callback). 97 // be made (IOW after Stop() returns, it is safe to delete the callback).
89 // The |loop_for_join| parameter is required for asynchronous operation 98 // The |loop_for_join| parameter is required for asynchronous operation
90 // in order to join the worker thread and close the thread handle later via a 99 // in order to join the worker thread and close the thread handle later via a
91 // posted task. 100 // posted task.
92 // If set to NULL, function will wait for the thread to exit before returning. 101 // If set to NULL, function will wait for the thread to exit before returning.
(...skipping 14 matching lines...) Expand all
107 116
108 base::Lock thread_lock_; 117 base::Lock thread_lock_;
109 scoped_refptr<AudioDeviceThread::Thread> thread_; 118 scoped_refptr<AudioDeviceThread::Thread> thread_;
110 119
111 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); 120 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread);
112 }; 121 };
113 122
114 } // namespace media. 123 } // namespace media.
115 124
116 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 125 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698