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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2010 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_AUDIO_H_
6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_AUDIO_H_
7
8 #include <nacl/nacl_srpc.h>
9 #include <pthread.h>
10 #include "native_client/src/include/nacl_base.h"
11 #include "native_client/src/include/nacl_macros.h"
12 #include "native_client/src/include/portability.h"
13 #include "native_client/src/include/ref_counted.h"
14 #include "native_client/src/shared/ppapi_proxy/plugin_resource.h"
15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/ppb_audio.h"
17
18 namespace ppapi_proxy {
19
20 enum PluginAudioState {
21 AUDIO_INCOMPLETE = 0, // StreamCreated not yet invoked
22 AUDIO_PENDING, // Incomplete and app requested StartPlayback
23 AUDIO_READY, // StreamCreated invoked, ready for playback
24 AUDIO_PLAYING // Audio in playback
25 };
26
27 // Implements the untrusted side of the PPB_Audio interface.
28 // All methods in PluginAudio class will be invoked on the main thread.
29 // The only exception is AudioThread(), which will invoke the application
30 // supplied callback to periodically obtain more audio data.
31 class PluginAudio : public PluginResource {
32 public:
33 PluginAudio();
34 virtual ~PluginAudio();
35 void StreamCreated(NaClSrpcImcDescType socket,
36 NaClSrpcImcDescType shm, size_t shm_size);
37 void set_state(PluginAudioState state) { state_ = state; }
38 void set_callback(PPB_Audio_Callback user_callback, void* user_data) {
39 user_callback_ = user_callback;
40 user_data_ = user_data;
41 }
42 PluginAudioState state() { return state_; }
43 bool StartAudioThread();
44 bool StopAudioThread();
45 static void AudioThread(void* self);
46 static const PPB_Audio* GetInterface();
47 virtual bool InitFromBrowserResource(PP_Resource resource);
48 private:
49 PP_Resource resource_;
50 NaClSrpcImcDescType socket_;
51 NaClSrpcImcDescType shm_;
52 size_t shm_size_;
53 void *shm_buffer_;
54 PluginAudioState state_;
55 uintptr_t thread_id_;
56 bool thread_active_;
57 PPB_Audio_Callback user_callback_;
58 void* user_data_;
59 IMPLEMENT_RESOURCE(PluginAudio);
60 NACL_DISALLOW_COPY_AND_ASSIGN(PluginAudio);
61 };
62
63 } // namespace ppapi_proxy
64
65 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_AUDIO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698