sounds_manager.h revision 0f1bc08d4cfcc34181b0b5cbf065c40f687bf740
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 3// found in the LICENSE file. 4 5#ifndef MEDIA_AUDIO_SOUNDS_SOUNDS_MANAGER_H_ 6#define MEDIA_AUDIO_SOUNDS_SOUNDS_MANAGER_H_ 7 8#include <vector> 9 10#include "base/basictypes.h" 11#include "base/strings/string_piece.h" 12#include "base/threading/non_thread_safe.h" 13#include "base/time/time.h" 14#include "media/base/media_export.h" 15 16namespace media { 17 18// This class is used for reproduction of system sounds. All methods 19// should be accessed from the Audio thread. 20class MEDIA_EXPORT SoundsManager : public base::NonThreadSafe { 21 public: 22 enum Sound { 23 SOUND_STARTUP = 0, 24 SOUND_LOCK, 25 SOUND_UNLOCK, 26 SOUND_SHUTDOWN, 27 SOUND_COUNT 28 }; 29 30 // Creates a singleton instance of the SoundsManager. 31 static void Create(); 32 33 // Removes a singleton instance of the SoundsManager. 34 static void Shutdown(); 35 36 // Returns a pointer to a singleton instance of the SoundsManager. 37 static SoundsManager* Get(); 38 39 // Initializes SoundsManager with the wav data for the system 40 // sounds. Returns true if SoundsManager was successfully 41 // initialized. 42 virtual bool Initialize(const std::vector<base::StringPiece>& resources) = 0; 43 44 // Plays |sound|, returns false if SoundsManager was not properly 45 // initialized. 46 virtual bool Play(Sound sound) = 0; 47 48 // Returns duration of the |sound|. If SoundsManager was not 49 // properly initialized returns an empty value. 50 virtual base::TimeDelta GetDuration(Sound sound) = 0; 51 52 protected: 53 SoundsManager(); 54 virtual ~SoundsManager(); 55 56 private: 57 DISALLOW_COPY_AND_ASSIGN(SoundsManager); 58}; 59 60} // namespace media 61 62#endif // MEDIA_AUDIO_SOUNDS_SOUNDS_MANAGER_H_ 63