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

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

Issue 1830933002: Making AudioThread::Thread restartable *** DRAFT *** (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | media/audio/audio_device_thread.cc » ('j') | media/audio/audio_device_thread.cc » ('J')
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 #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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const int total_segments_; 69 const int total_segments_;
70 int segment_length_; 70 int segment_length_;
71 71
72 private: 72 private:
73 DISALLOW_COPY_AND_ASSIGN(Callback); 73 DISALLOW_COPY_AND_ASSIGN(Callback);
74 }; 74 };
75 75
76 AudioDeviceThread(); 76 AudioDeviceThread();
77 ~AudioDeviceThread(); 77 ~AudioDeviceThread();
78 78
79 // Starts the audio thread. The thread must not already be running. If 79 // Starts the audio thread and puts into wait mode. Play() must
80 // |sychronized_buffers| is set, the browser expects to be notified via the 80 // be called to release it and actually start running. The thread must not
81 // |socket| every time AudioDeviceThread::Process() completes. 81 // already be started. If |sychronized_buffers| is set, the browser expects
82 void Start(AudioDeviceThread::Callback* callback, 82 // to be notified via the |socket| every time AudioDeviceThread::Process()
83 base::SyncSocket::Handle socket, 83 // completes.
84 const char* thread_name, 84 void Start(const char* thread_name, bool synchronized_buffers);
85 bool synchronized_buffers);
86 85
87 // This tells the audio thread to stop and clean up the data. 86 // This tells the audio thread to stop and clean up the data.
88 // The method can stop the thread synchronously or asynchronously. 87 // The method can stop the thread synchronously or asynchronously.
89 // In the latter case, the thread will still be running after Stop() 88 // In the latter case, the thread will still be running after Stop()
90 // returns, but the callback pointer is cleared so no further callbacks will 89 // returns, but the callback pointer is cleared so no further callbacks will
91 // be made (IOW after Stop() returns, it is safe to delete the callback). 90 // be made (IOW after Stop() returns, it is safe to delete the callback).
92 // The |loop_for_join| parameter is required for asynchronous operation 91 // The |loop_for_join| parameter is required for asynchronous operation
93 // in order to join the worker thread and close the thread handle later via a 92 // in order to join the worker thread and close the thread handle later via a
94 // posted task. 93 // posted task.
95 // If set to NULL, function will wait for the thread to exit before returning. 94 // If set to NULL, function will wait for the thread to exit before returning.
96 void Stop(base::MessageLoop* loop_for_join); 95 void Stop(base::MessageLoop* loop_for_join);
97 96
97 // Releases the thread from wait mode so that it starts running with the given
Guido Urdaneta 2016/04/01 10:17:01 Nit: Release is perhaps not the most familiar term
Henrik Grunell 2016/05/09 12:13:37 Done in other CL.
98 // |callback| and |socket|. This will also reset the index used for
99 // sychronized buffers.
100 void Play(AudioDeviceThread::Callback* callback,
101 base::SyncSocket::Handle socket);
102
103 // Puts the thread in the wait mode and shuts down the socket.
104 // It can be resumed again with Play().
105 void Pause();
106
98 // Returns true if the thread is stopped or stopping. 107 // Returns true if the thread is stopped or stopping.
99 bool IsStopped(); 108 bool IsStopped();
100 109
101 private: 110 private:
111 // Not sure if we need this extra class and extra lock?
Henrik Grunell 2016/03/25 09:24:01 Yeah, does the below motivation hold? It seems pre
Henrik Grunell 2016/05/09 12:13:37 Changed to TODO in other CL.
102 // Our own private SimpleThread override. We implement this in a 112 // Our own private SimpleThread override. We implement this in a
103 // private class so that we get the following benefits: 113 // private class so that we get the following benefits:
104 // 1) AudioDeviceThread doesn't expose SimpleThread methods. 114 // 1) AudioDeviceThread doesn't expose SimpleThread methods.
105 // I.e. the caller can't call Start()/Stop() - which would be bad. 115 // I.e. the caller can't call Start()/Stop() - which would be bad.
106 // 2) We override ThreadMain to add additional on-thread initialization 116 // 2) We override ThreadMain to add additional on-thread initialization
107 // while still synchronized with SimpleThread::Start() to provide 117 // while still synchronized with SimpleThread::Start() to provide
108 // reliable initialization. 118 // reliable initialization.
109 class Thread; 119 class Thread;
110 120
111 base::Lock thread_lock_; 121 base::Lock thread_lock_;
112 scoped_refptr<AudioDeviceThread::Thread> thread_; 122 scoped_refptr<AudioDeviceThread::Thread> thread_;
113 123
114 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread); 124 DISALLOW_COPY_AND_ASSIGN(AudioDeviceThread);
115 }; 125 };
116 126
117 } // namespace media. 127 } // namespace media.
118 128
119 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_ 129 #endif // MEDIA_AUDIO_AUDIO_DEVICE_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_device_thread.cc » ('j') | media/audio/audio_device_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698