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.
5 #ifndef MEDIA_AUDIO_SOUNDS_SOUNDS_MANAGER_H_
6 #define MEDIA_AUDIO_SOUNDS_SOUNDS_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/strings/string_piece.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "base/time/time.h"
13 #include "media/base/media_export.h"
17 // This class is used for reproduction of system sounds. All methods
18 // should be accessed from the Audio thread.
19 class MEDIA_EXPORT SoundsManager
: public base::NonThreadSafe
{
23 // Creates a singleton instance of the SoundsManager.
26 // Removes a singleton instance of the SoundsManager.
27 static void Shutdown();
29 // Returns a pointer to a singleton instance of the SoundsManager.
30 static SoundsManager
* Get();
32 // Initializes sounds manager for testing. The |manager| will be owned
33 // by the internal pointer and will be deleted by Shutdown().
34 static void InitializeForTesting(SoundsManager
* manager
);
36 // Initializes SoundsManager with the wav data for the system
37 // sounds. Returns true if SoundsManager was successfully
39 virtual bool Initialize(SoundKey key
, const base::StringPiece
& data
) = 0;
41 // Plays sound identified by |key|, returns false if SoundsManager
42 // was not properly initialized.
43 virtual bool Play(SoundKey key
) = 0;
45 // Returns duration of the sound identified by |key|. If SoundsManager
46 // was not properly initialized or |key| was not registered, this
47 // method returns an empty value.
48 virtual base::TimeDelta
GetDuration(SoundKey key
) = 0;
52 virtual ~SoundsManager();
55 DISALLOW_COPY_AND_ASSIGN(SoundsManager
);
60 #endif // MEDIA_AUDIO_SOUNDS_SOUNDS_MANAGER_H_