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

Side by Side Diff: media/audio/fake_audio_output_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: rebased and fixed the speech recognition unittest 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 AudioOutputStream. It is used for testing purpose. 5 // A fake implementation of AudioOutputStream. It is used for testing purpose.
6 // TODO(hclam): Implement a thread in this fake output stream to simulate an 6 // TODO(hclam): Implement a thread in this fake output stream to simulate an
7 // audio output stream reading from AudioSourceCallback. 7 // audio output stream reading from AudioSourceCallback.
8 8
9 #ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ 9 #ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
10 #define MEDIA_AUDIO_FAKE_AUDIO_OUTOUT_STREAM_H_ 10 #define MEDIA_AUDIO_FAKE_AUDIO_OUTOUT_STREAM_H_
11 11
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "media/audio/audio_io.h" 15 #include "media/audio/audio_io.h"
16 #include "media/audio/audio_parameters.h" 16 #include "media/audio/audio_parameters.h"
17 17
18 class AudioManagerBase;
19
18 class MEDIA_EXPORT FakeAudioOutputStream : public AudioOutputStream { 20 class MEDIA_EXPORT FakeAudioOutputStream : public AudioOutputStream {
19 public: 21 public:
20 static AudioOutputStream* MakeFakeStream(const AudioParameters& params); 22 static AudioOutputStream* MakeFakeStream(AudioManagerBase* manager,
21 static FakeAudioOutputStream* GetLastFakeStream(); 23 const AudioParameters& params);
24
25 static FakeAudioOutputStream* GetCurrentFakeStream();
22 26
23 virtual bool Open() OVERRIDE; 27 virtual bool Open() OVERRIDE;
24 virtual void Start(AudioSourceCallback* callback) OVERRIDE; 28 virtual void Start(AudioSourceCallback* callback) OVERRIDE;
25 virtual void Stop() OVERRIDE; 29 virtual void Stop() OVERRIDE;
26 virtual void SetVolume(double volume) OVERRIDE; 30 virtual void SetVolume(double volume) OVERRIDE;
27 virtual void GetVolume(double* volume) OVERRIDE; 31 virtual void GetVolume(double* volume) OVERRIDE;
28 virtual void Close() OVERRIDE; 32 virtual void Close() OVERRIDE;
29 33
30 uint8* buffer() { return buffer_.get(); } 34 uint8* buffer() { return buffer_.get(); }
31 double volume() { return volume_; } 35 double volume() { return volume_; }
32 36
33 private: 37 private:
34 explicit FakeAudioOutputStream(const AudioParameters& params); 38 explicit FakeAudioOutputStream(AudioManagerBase* manager,
39 const AudioParameters& params);
40
35 virtual ~FakeAudioOutputStream(); 41 virtual ~FakeAudioOutputStream();
36 42
37 static void DestroyLastFakeStream(void* param); 43 static FakeAudioOutputStream* current_fake_stream_;
38 static bool has_created_fake_stream_;
39 static FakeAudioOutputStream* last_fake_stream_;
40 44
45 AudioManagerBase* audio_manager_;
41 double volume_; 46 double volume_;
42 AudioSourceCallback* callback_; 47 AudioSourceCallback* callback_;
43 scoped_array<uint8> buffer_; 48 scoped_array<uint8> buffer_;
44 uint32 packet_size_; 49 uint32 packet_size_;
45 bool closed_; 50 bool closed_;
46 51
47 DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream); 52 DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream);
48 }; 53 };
49 54
50 #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ 55 #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698