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

Unified Diff: ppapi/thunk/ppb_audio_config_thunk.cc

Issue 9129007: Work on improving PpbAudioConfig:RecommendSampleFrameCount (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/thunk/ppb_audio_config_thunk.cc
===================================================================
--- ppapi/thunk/ppb_audio_config_thunk.cc (revision 120806)
+++ ppapi/thunk/ppb_audio_config_thunk.cc (working copy)
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/shared_impl/ppb_audio_config_shared.h"
#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_audio_config_api.h"
@@ -22,10 +23,10 @@
sample_frame_count);
}
-uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate,
- uint32_t requested_sample_frame_count) {
- // TODO(brettw) Currently we don't actually query to get a value from the
- // hardware, so we always return the input for in-range values.
+uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count) {
+ // Version 1.0: Don't actually query to get a value from the
+ // hardware; instead return the input for in-range values.
if (requested_sample_frame_count < PP_AUDIOMINSAMPLEFRAMECOUNT)
return PP_AUDIOMINSAMPLEFRAMECOUNT;
if (requested_sample_frame_count > PP_AUDIOMAXSAMPLEFRAMECOUNT)
@@ -33,6 +34,24 @@
return requested_sample_frame_count;
}
+uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance,
+ PP_AudioSampleRate sample_rate,
+ uint32_t requested_sample_frame_count) {
+ EnterInstance enter(instance);
brettw 2012/02/10 19:01:33 The thunks shouldn't have actual code in them. I w
nfullagar 2012/02/14 00:42:37 code moved, shared_impl func takes the same args a
+ if (enter.failed())
+ return 0;
+ uint32_t hardware_sample_rate =
+ enter.functions()->AudioHardwareOutputSampleRate(instance);
+ uint32_t hardware_sample_frame_count =
+ enter.functions()->AudioHardwareOutputBufferSize(instance);
+ return PPB_AudioConfig_Shared::RecommendSampleFrameCount(
+ sample_rate,
+ requested_sample_frame_count,
+ static_cast<PP_AudioSampleRate>(hardware_sample_rate),
+ hardware_sample_frame_count);
+}
+
+
PP_Bool IsAudioConfig(PP_Resource resource) {
EnterResource<PPB_AudioConfig_API> enter(resource, false);
return PP_FromBool(enter.succeeded());
@@ -52,19 +71,41 @@
return enter.object()->GetSampleFrameCount();
}
-const PPB_AudioConfig g_ppb_audio_config_thunk = {
+PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) {
+ EnterInstance enter(instance);
+ if (enter.failed())
+ return PP_AUDIOSAMPLERATE_NONE;
+ return static_cast<PP_AudioSampleRate>(
+ enter.functions()->AudioHardwareOutputSampleRate(instance));
+}
+
+const PPB_AudioConfig_1_0 g_ppb_audio_config_thunk_1_0 = {
&CreateStereo16bit,
- &RecommendSampleFrameCount,
+ &RecommendSampleFrameCount_1_0,
&IsAudioConfig,
&GetSampleRate,
&GetSampleFrameCount
};
+const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1 = {
+ &CreateStereo16bit,
+ &RecommendSampleFrameCount_1_1,
+ &IsAudioConfig,
+ &GetSampleRate,
+ &GetSampleFrameCount,
+ &RecommendSampleRate
+};
+
+
} // namespace
const PPB_AudioConfig_1_0* GetPPB_AudioConfig_1_0_Thunk() {
- return &g_ppb_audio_config_thunk;
+ return &g_ppb_audio_config_thunk_1_0;
}
+const PPB_AudioConfig_1_1* GetPPB_AudioConfig_1_1_Thunk() {
+ return &g_ppb_audio_config_thunk_1_1;
+}
+
} // namespace thunk
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698