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

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

Issue 9692038: stopping the audio thread before destroying the AudioManager<Platform> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Android compiling problem 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 // A fake implementation of AudioInputStream, useful for testing purpose. 5 // A fake implementation of AudioInputStream, useful for testing purpose.
6 6
7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ 7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
8 #define MEDIA_AUDIO_FAKE_AUDIO_INOUT_STREAM_H_ 8 #define MEDIA_AUDIO_FAKE_AUDIO_INOUT_STREAM_H_
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
15 #include "base/time.h" 14 #include "base/time.h"
16 #include "media/audio/audio_io.h" 15 #include "media/audio/audio_io.h"
17 #include "media/audio/audio_parameters.h" 16 #include "media/audio/audio_parameters.h"
18 17
18 class AudioManagerBase;
19
19 class FakeAudioInputStream 20 class FakeAudioInputStream
20 : public AudioInputStream, 21 : public AudioInputStream {
21 public base::RefCountedThreadSafe<FakeAudioInputStream> {
22 public: 22 public:
23 static AudioInputStream* MakeFakeStream(const AudioParameters& params); 23 static AudioInputStream* MakeFakeStream(AudioManagerBase* manager,
24 const AudioParameters& params);
25
26 virtual ~FakeAudioInputStream();
tommi (sloooow) - chröme 2012/03/13 16:20:09 hmm... you replied to my comment about the destruc
no longer working on chromium 2012/03/13 16:38:08 Sorry, I did not press the save button in eclipse.
24 27
25 virtual bool Open() OVERRIDE; 28 virtual bool Open() OVERRIDE;
26 virtual void Start(AudioInputCallback* callback) OVERRIDE; 29 virtual void Start(AudioInputCallback* callback) OVERRIDE;
27 virtual void Stop() OVERRIDE; 30 virtual void Stop() OVERRIDE;
28 virtual void Close() OVERRIDE; 31 virtual void Close() OVERRIDE;
29 virtual double GetMaxVolume() OVERRIDE; 32 virtual double GetMaxVolume() OVERRIDE;
30 virtual void SetVolume(double volume) OVERRIDE; 33 virtual void SetVolume(double volume) OVERRIDE;
31 virtual double GetVolume() OVERRIDE; 34 virtual double GetVolume() OVERRIDE;
32 35
33 private: 36 private:
34 // Give RefCountedThreadSafe access our destructor. 37 FakeAudioInputStream(AudioManagerBase* manager,
35 friend class base::RefCountedThreadSafe<FakeAudioInputStream>; 38 const AudioParameters& params);
36
37 FakeAudioInputStream(const AudioParameters& params);
38 virtual ~FakeAudioInputStream();
39 39
40 void DoCallback(); 40 void DoCallback();
41 41
42 AudioManagerBase* audio_manager_;
42 AudioInputCallback* callback_; 43 AudioInputCallback* callback_;
43 scoped_array<uint8> buffer_; 44 scoped_array<uint8> buffer_;
44 int buffer_size_; 45 int buffer_size_;
45 base::Thread thread_; 46 base::Thread thread_;
46 base::Time last_callback_time_; 47 base::Time last_callback_time_;
47 base::TimeDelta callback_interval_; 48 base::TimeDelta callback_interval_;
48 49
49 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); 50 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream);
50 }; 51 };
51 52
52 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ 53 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698