OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SOUNDS_AUDIO_STREAM_HANDLER_H_ | 5 #ifndef MEDIA_AUDIO_SOUNDS_AUDIO_STREAM_HANDLER_H_ |
6 #define MEDIA_AUDIO_SOUNDS_AUDIO_STREAM_HANDLER_H_ | 6 #define MEDIA_AUDIO_SOUNDS_AUDIO_STREAM_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 }; | 35 }; |
36 | 36 |
37 // C-tor for AudioStreamHandler. |wav_data| should be a raw | 37 // C-tor for AudioStreamHandler. |wav_data| should be a raw |
38 // uncompressed WAVE data which will be sent to the audio manager. | 38 // uncompressed WAVE data which will be sent to the audio manager. |
39 explicit AudioStreamHandler(const base::StringPiece& wav_data); | 39 explicit AudioStreamHandler(const base::StringPiece& wav_data); |
40 virtual ~AudioStreamHandler(); | 40 virtual ~AudioStreamHandler(); |
41 | 41 |
42 // Returns true iff AudioStreamHandler is correctly initialized; | 42 // Returns true iff AudioStreamHandler is correctly initialized; |
43 bool IsInitialized() const; | 43 bool IsInitialized() const; |
44 | 44 |
45 // Stops any previous playback if it's still not completed and | 45 // Plays sound. Volume level will be set according to current settings |
46 // starts new playback. Volume level will be set according to | 46 // and won't be changed during playback. Returns true iff new playback |
47 // current settings and won't be changed during playback. Returns | 47 // was successfully started. |
48 // true iff new playback was successfully started. | 48 // |
| 49 // NOTE: if current playback isn't at end of stream, playback request |
| 50 // is dropped, but true is returned. |
49 bool Play(); | 51 bool Play(); |
50 | 52 |
51 // Stops current playback. | 53 // Stops current playback. |
52 void Stop(); | 54 void Stop(); |
53 | 55 |
54 const WavAudioHandler& wav_audio_handler() const { return wav_audio_; } | 56 const WavAudioHandler& wav_audio_handler() const { return wav_audio_; } |
55 | 57 |
56 private: | 58 private: |
57 friend class AudioStreamHandlerTest; | 59 friend class AudioStreamHandlerTest; |
58 friend class SoundsManagerTest; | 60 friend class SoundsManagerTest; |
59 | 61 |
60 class AudioStreamContainer; | 62 class AudioStreamContainer; |
61 | 63 |
62 static void SetObserverForTesting(TestObserver* observer); | 64 static void SetObserverForTesting(TestObserver* observer); |
63 static void SetAudioSourceForTesting( | 65 static void SetAudioSourceForTesting( |
64 AudioOutputStream::AudioSourceCallback* source); | 66 AudioOutputStream::AudioSourceCallback* source); |
65 | 67 |
66 WavAudioHandler wav_audio_; | 68 WavAudioHandler wav_audio_; |
67 scoped_ptr<AudioStreamContainer> stream_; | 69 scoped_ptr<AudioStreamContainer> stream_; |
68 | 70 |
69 bool initialized_; | 71 bool initialized_; |
70 | 72 |
71 DISALLOW_COPY_AND_ASSIGN(AudioStreamHandler); | 73 DISALLOW_COPY_AND_ASSIGN(AudioStreamHandler); |
72 }; | 74 }; |
73 | 75 |
74 } // namespace media | 76 } // namespace media |
75 | 77 |
76 #endif // MEDIA_AUDIO_SOUNDS_AUDIO_STREAM_HANDLER_H_ | 78 #endif // MEDIA_AUDIO_SOUNDS_AUDIO_STREAM_HANDLER_H_ |
OLD | NEW |