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

Side by Side Diff: experimental/conways_life/audio/audio_player.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 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
« no previous file with comments | « experimental/conways_life/about.html ('k') | experimental/conways_life/audio/audio_player.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client 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 AUDIO_PLAYER_H_
6 #define AUDIO_PLAYER_H_
7
8 #include "experimental/conways_life/threading/pthread_ext.h"
9 #include "experimental/conways_life/web_resource_loader.h"
10 #include "ppapi/cpp/completion_callback.h"
11
12 namespace pp {
13 class Audio;
14 class Instance;
15 }
16
17 namespace audio {
18
19 class AudioSource;
20
21 // Play audio from various audio sources. Usage:
22 //
23 // AudioPlayer player(instance);
24 // AudioSource* source = <create an sudio source>
25 // player.AssignAudioSource(source);
26 // player.Play();
27 class AudioPlayer {
28 public:
29 explicit AudioPlayer(pp::Instance* instance);
30 ~AudioPlayer();
31
32 // Assign an audio source to this player. The player owns the audio source and
33 // is responsible for deleting it when done. Returns true if successful, and
34 // false otherwise (e.g. the source is not playable through this player).
35 void AssignAudioSource(AudioSource* source);
36
37 // Play audio from the sound source. This is an asynchronous call that returns
38 // immediately. Fails silently if the sound source is not ready.
39 void Play();
40 // Stop playing.
41 void Stop();
42
43 // Indicates whether this player instance can play a sound.
44 bool IsReady() const;
45
46 private:
47 // Disallow copy and assigment.
48 AudioPlayer(const AudioPlayer&);
49 AudioPlayer& operator=(const AudioPlayer&);
50
51 // Pepper audio callback function.
52 static void AudioCallback(void* sample_buffer,
53 uint32_t buffer_size_in_bytes,
54 void* user_data);
55
56 // Internal versions of Play/Stop that only run on the main thread.
57 void InternalPlay(int32_t result);
58 void InternalStop(int32_t result);
59
60 // Clear (delete) the audio objects.
61 void ClearAudioSource();
62 void ClearPepperAudio();
63 // Create the pepper audio for the given sopurce. Return true on success.
64 bool CreatePepperAudio();
65
66 AudioSource* audio_source_;
67 size_t playback_offset_;
68 pp::Audio* pp_audio_;
69 pp::Instance* instance_; // Weak reference.
70
71 pp::CompletionCallbackFactory<AudioPlayer, threading::RefCount> factory_;
72 pthread_mutex_t mutex_;
73 };
74
75 } // namespace audio
76 #endif // AUDIO_PLAYER_H_
OLDNEW
« no previous file with comments | « experimental/conways_life/about.html ('k') | experimental/conways_life/audio/audio_player.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698