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

Side by Side Diff: libraries/openal-soft/nacl-openal-soft.patch

Issue 12114013: Fix openal NaCl port. (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « examples/audio/openal-ogg/pkg_info ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 diff -Naur openal-soft-1.13/Alc/ALc.c openal-soft-1.13-nacl/Alc/ALc.c 1 diff -Naur openal-soft-1.13/Alc/ALc.c openal-soft-1.13-nacl/Alc/ALc.c
2 --- openal-soft-1.13/Alc/ALc.c 2011-02-09 11:52:19.000000000 -0800 2 --- openal-soft-1.13/Alc/ALc.c 2011-02-09 11:52:19.000000000 -0800
3 +++ openal-soft-1.13-nacl/Alc/ALc.c 2012-01-23 15:45:38.000000000 -0800 3 +++ openal-soft-1.13-nacl/Alc/ALc.c 2012-01-23 15:45:38.000000000 -0800
4 @@ -23,7 +23,7 @@ 4 @@ -23,7 +23,7 @@
5 #include <math.h> 5 #include <math.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 -#include <memory.h> 8 -#include <memory.h>
9 +#include <string.h> 9 +#include <string.h>
10 #include <ctype.h> 10 #include <ctype.h>
11 11
12 #include "alMain.h" 12 #include "alMain.h"
13 @@ -69,7 +69,9 @@ 13 @@ -69,7 +69,9 @@
14 #ifdef HAVE_PORTAUDIO 14 #ifdef HAVE_PORTAUDIO
15 { "port", alc_pa_init, alc_pa_deinit, alc_pa_probe, EmptyFuncs }, 15 { "port", alc_pa_init, alc_pa_deinit, alc_pa_probe, EmptyFuncs },
16 #endif 16 #endif
17 - 17 -
18 +#ifdef HAVE_PPAPI 18 +#ifdef HAVE_PPAPI
19 + { "ppapi", alc_ppapi_init, alc_ppapi_deinit, alc_ppapi_probe, EmptyFuncs }, 19 + { "ppapi", alc_ppapi_init, alc_ppapi_deinit, alc_ppapi_probe, EmptyFuncs },
20 +#endif 20 +#endif
21 { "null", alc_null_init, alc_null_deinit, alc_null_probe, EmptyFuncs }, 21 { "null", alc_null_init, alc_null_deinit, alc_null_probe, EmptyFuncs },
22 #ifdef HAVE_WAVE 22 #ifdef HAVE_WAVE
23 { "wave", alc_wave_init, alc_wave_deinit, alc_wave_probe, EmptyFuncs }, 23 { "wave", alc_wave_init, alc_wave_deinit, alc_wave_probe, EmptyFuncs },
24 diff -Naur openal-soft-1.13/Alc/ppapi.c openal-soft-1.13-nacl/Alc/ppapi.c 24 diff -Naur openal-soft-1.13/Alc/ppapi.c openal-soft-1.13.nacl/Alc/ppapi.c
25 --- openal-soft-1.13/Alc/ppapi.c 1969-12-31 16:00:00.000000000 -0800 25 --- openal-soft-1.13/Alc/ppapi.c 1969-12-31 16:00:00.000000000 -0800
26 +++ openal-soft-1.13-nacl/Alc/ppapi.c» 2012-01-23 15:46:21.000000000 -0800 26 +++ openal-soft-1.13.nacl/Alc/ppapi.c» 2013-01-31 08:54:09.078478389 -0800
27 @@ -0,0 +1,411 @@ 27 @@ -0,0 +1,421 @@
28 +/** 28 +/**
29 + * OpenAL cross platform audio library 29 + * OpenAL cross platform audio library
30 + * Copyright (C) 2012 30 + * Copyright (C) 2012
31 + * This library is free software; you can redistribute it and/or 31 + * This library is free software; you can redistribute it and/or
32 + * modify it under the terms of the GNU Library General Public 32 + * modify it under the terms of the GNU Library General Public
33 + * License as published by the Free Software Foundation; either 33 + * License as published by the Free Software Foundation; either
34 + * version 2 of the License, or (at your option) any later version. 34 + * version 2 of the License, or (at your option) any later version.
35 + * 35 + *
36 + * This library is distributed in the hope that it will be useful, 36 + * This library is distributed in the hope that it will be useful,
37 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 37 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 + ALvoid *buffer; 77 + ALvoid *buffer;
78 + ALuint size; 78 + ALuint size;
79 + 79 +
80 + PPB_AudioConfig* audio_config; 80 + PPB_AudioConfig* audio_config;
81 + PPB_Audio* audio; 81 + PPB_Audio* audio;
82 + PPB_Core* core; 82 + PPB_Core* core;
83 + 83 +
84 + PP_Resource audio_config_resource; 84 + PP_Resource audio_config_resource;
85 + PP_Resource audio_resource; 85 + PP_Resource audio_resource;
86 + ALuint sample_frame_count; 86 + ALuint sample_frame_count;
87 + 87 +
88 + volatile ALuint read_ptr; 88 + volatile ALuint read_ptr;
89 + volatile ALuint write_ptr; 89 + volatile ALuint write_ptr;
90 + 90 +
91 + ALCdevice *device; 91 + ALCdevice *device;
92 + 92 +
93 + volatile int killNow; 93 + volatile int killNow;
94 + ALvoid *thread; 94 + ALvoid *thread;
95 + volatile ALuint main_thread_init_status; 95 + volatile ALuint main_thread_init_status;
96 + ALuint buffer_ready; 96 + ALuint buffer_ready;
97 +} ppapi_data; 97 +} ppapi_data;
(...skipping 12 matching lines...) Expand all
110 + uint32_t buffer_size_in_bytes, 110 + uint32_t buffer_size_in_bytes,
111 + void* user_data) 111 + void* user_data)
112 +{ 112 +{
113 + ppapi_data* data = (ppapi_data*)user_data; 113 + ppapi_data* data = (ppapi_data*)user_data;
114 + if (!data->buffer_ready) return; 114 + if (!data->buffer_ready) return;
115 + 115 +
116 + ALuint write_proxy = data->write_ptr; 116 + ALuint write_proxy = data->write_ptr;
117 + if (data->read_ptr > data->write_ptr) 117 + if (data->read_ptr > data->write_ptr)
118 + write_proxy = data->write_ptr + data->size; 118 + write_proxy = data->write_ptr + data->size;
119 + 119 +
120 + if (data->read_ptr + buffer_size_in_bytes > write_proxy) 120 + int available_bytes = write_proxy - data->read_ptr;
121 + if (available_bytes < buffer_size_in_bytes)
121 + { 122 + {
122 + AL_PRINT("buffer underrun\n"); 123 + AL_PRINT("buffer underrun (buffer size=%d) (only buffering %d)\n", buff er_size_in_bytes, available_bytes);
123 + return; 124 + /* Zero the part of the buffer that we cannot fill */
125 + memset(sample_buffer + available_bytes, 0, buffer_size_in_bytes - avail able_bytes);
126 + buffer_size_in_bytes = available_bytes;
124 + } 127 + }
125 + 128 +
126 + if (data->read_ptr + buffer_size_in_bytes > data->size) 129 + if (data->read_ptr + buffer_size_in_bytes > data->size)
127 + { 130 + {
128 + /* This read straddles the buffer boundary, split it up. */ 131 + /* This read straddles the buffer boundary, split it up. */
129 + memcpy(sample_buffer, 132 + memcpy(sample_buffer,
130 + data->buffer + data->read_ptr, 133 + data->buffer + data->read_ptr,
131 + data->size - data->read_ptr); 134 + data->size - data->read_ptr);
132 + memcpy(sample_buffer + (data->size - data->read_ptr), 135 + memcpy(sample_buffer + (data->size - data->read_ptr),
133 + data->buffer, 136 + data->buffer,
(...skipping 13 matching lines...) Expand all
147 + 150 +
148 +static const ALCchar ppapiDevice[] = "PPAPI Output"; 151 +static const ALCchar ppapiDevice[] = "PPAPI Output";
149 + 152 +
150 +static ALuint PpapiProc(ALvoid *ptr) 153 +static ALuint PpapiProc(ALvoid *ptr)
151 +{ 154 +{
152 + ALCdevice *Device = (ALCdevice*)ptr; 155 + ALCdevice *Device = (ALCdevice*)ptr;
153 + ppapi_data *data = (ppapi_data*)Device->ExtraData; 156 + ppapi_data *data = (ppapi_data*)Device->ExtraData;
154 + 157 +
155 + ALuint UpdateSizeInBytes = Device->UpdateSize * kFrameSizeInBytes; 158 + ALuint UpdateSizeInBytes = Device->UpdateSize * kFrameSizeInBytes;
156 + ALuint SampleFrameInBytes = data->sample_frame_count * kFrameSizeInBytes; 159 + ALuint SampleFrameInBytes = data->sample_frame_count * kFrameSizeInBytes;
160 +
157 + /* Start to buffer when less than this many bytes are buffered. Keep this 161 + /* Start to buffer when less than this many bytes are buffered. Keep this
158 + * small for low latency but large enough so we don't starve Pepper. 162 + * small for low latency but large enough so we don't starve Pepper.
163 + *
164 + * SampleFrameInBytes is the size of the buffer that PPAPI asks for each
165 + * callback. We want to keep twice this amount in the buffer at any given
166 + * time.
159 + */ 167 + */
160 + const ALuint MinBufferSizeInBytes = 168 + const ALuint MinBufferSizeInBytes = max(SampleFrameInBytes*2,
161 + min(max(SampleFrameInBytes*4, UpdateSizeInBytes), data->size/2); 169 + UpdateSizeInBytes);
162 + 170 +
163 + while(!data->killNow && Device->Connected) 171 + while(!data->killNow && Device->Connected)
164 + { 172 + {
165 + ALuint write_proxy = data->write_ptr; 173 + ALuint write_proxy = data->write_ptr;
166 + if (data->read_ptr > data->write_ptr) 174 + if (data->read_ptr > data->write_ptr)
167 + write_proxy = data->write_ptr + data->size; 175 + write_proxy = data->write_ptr + data->size;
168 + 176 +
169 + if (data->read_ptr + MinBufferSizeInBytes >= write_proxy) 177 + if (data->read_ptr + MinBufferSizeInBytes >= write_proxy)
170 + { 178 + {
171 + aluMixData(Device, 179 + aluMixData(Device,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 +#endif 217 +#endif
210 + rate, 218 + rate,
211 + kRequestedFrameCount); 219 + kRequestedFrameCount);
212 + 220 +
213 + data->audio_config_resource = 221 + data->audio_config_resource =
214 + data->audio_config->CreateStereo16Bit(gInstance, 222 + data->audio_config->CreateStereo16Bit(gInstance,
215 + rate, 223 + rate,
216 + data->sample_frame_count); 224 + data->sample_frame_count);
217 + 225 +
218 + if (PP_FALSE == data->audio_config->IsAudioConfig(data->audio_config_resour ce)) { 226 + if (PP_FALSE == data->audio_config->IsAudioConfig(data->audio_config_resour ce)) {
219 + AL_PRINT("PPAPI initialization: audio config creation failed."); 227 + AL_PRINT("PPAPI initialization: audio config creation failed.");
220 + data->main_thread_init_status = -1; 228 + data->main_thread_init_status = -1;
221 + return; 229 + return;
222 + } 230 + }
223 + 231 +
224 + data->audio_resource = data->audio->Create(gInstance, 232 + data->audio_resource = data->audio->Create(gInstance,
225 + data->audio_config_resource, 233 + data->audio_config_resource,
226 + PPAPI_Audio_Callback, 234 + PPAPI_Audio_Callback,
227 + (void*)data); 235 + (void*)data);
228 + 236 +
229 + if (PP_FALSE == data->audio->IsAudio(data->audio_resource)) { 237 + if (PP_FALSE == data->audio->IsAudio(data->audio_resource)) {
230 + AL_PRINT("PPAPI initialization: audio resource creation failed."); 238 + AL_PRINT("PPAPI initialization: audio resource creation failed.");
231 + data->main_thread_init_status = -1; 239 + data->main_thread_init_status = -1;
232 + return; 240 + return;
233 + } 241 + }
234 + 242 +
235 + if (PP_FALSE == data->audio->StartPlayback(data->audio_resource)) { 243 + if (PP_FALSE == data->audio->StartPlayback(data->audio_resource)) {
236 + AL_PRINT("PPAPI initialization: start playback failed."); 244 + AL_PRINT("PPAPI initialization: start playback failed.");
237 + data->main_thread_init_status = -1; 245 + data->main_thread_init_status = -1;
238 + return; 246 + return;
239 + } 247 + }
240 + 248 +
241 + data->main_thread_init_status = 1; 249 + data->main_thread_init_status = 1;
242 +} 250 +}
243 + 251 +
244 +static ALCboolean ppapi_open_playback(ALCdevice *device, 252 +static ALCboolean ppapi_open_playback(ALCdevice *device,
245 + const ALCchar *deviceName) 253 + const ALCchar *deviceName)
246 +{ 254 +{
247 + ppapi_data *data; 255 + ppapi_data *data;
248 + 256 +
249 + if(!deviceName) 257 + if (!deviceName)
250 + deviceName = ppapiDevice; 258 + deviceName = ppapiDevice;
251 + else if(strcmp(deviceName, ppapiDevice) != 0) 259 + else if (strcmp(deviceName, ppapiDevice) != 0)
252 + return ALC_FALSE; 260 + return ALC_FALSE;
253 + 261 +
254 + int channels = ChannelsFromDevFmt(device->FmtChans); 262 + int channels = ChannelsFromDevFmt(device->FmtChans);
255 + int bytes = BytesFromDevFmt(device->FmtType); 263 + int bytes = BytesFromDevFmt(device->FmtType);
256 + 264 +
257 + if (channels != 2) 265 + if (channels != 2)
258 + { 266 + {
259 + AL_PRINT("PPAPI only supports 2 channel output\n"); 267 + AL_PRINT("PPAPI only supports 2 channel output\n");
260 + return ALC_FALSE; 268 + return ALC_FALSE;
261 + } 269 + }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 + } 354 + }
347 + 355 +
348 + device->ExtraData = NULL; 356 + device->ExtraData = NULL;
349 +} 357 +}
350 + 358 +
351 +static ALCboolean ppapi_reset_playback(ALCdevice *device) 359 +static ALCboolean ppapi_reset_playback(ALCdevice *device)
352 +{ 360 +{
353 + ppapi_data *data = (ppapi_data*)device->ExtraData; 361 + ppapi_data *data = (ppapi_data*)device->ExtraData;
354 + 362 +
355 + ALuint UpdateSizeInBytes = device->UpdateSize * kFrameSizeInBytes; 363 + ALuint UpdateSizeInBytes = device->UpdateSize * kFrameSizeInBytes;
364 + ALuint SampleFrameInBytes = data->sample_frame_count * kFrameSizeInBytes;
356 + /* kBufferPadMult is added to protect against buffer underruns. */ 365 + /* kBufferPadMult is added to protect against buffer underruns. */
357 + data->size = UpdateSizeInBytes * kBufferPadMult; 366 + data->size = max(UpdateSizeInBytes, SampleFrameInBytes) * kBufferPadMult;
367 +
358 + /* Extra UpdateSize added so we can read off the end of the buffer in one 368 + /* Extra UpdateSize added so we can read off the end of the buffer in one
359 + * shot from aluMixData, but treat the buffer like it's of size data->size. 369 + * shot from aluMixData, but treat the buffer like it's of size data->size.
360 + */ 370 + */
361 + data->buffer = calloc(1, data->size + UpdateSizeInBytes); 371 + data->buffer = calloc(1, data->size + UpdateSizeInBytes);
362 + if(!data->buffer) 372 + if (!data->buffer)
363 + { 373 + {
364 + AL_PRINT("buffer malloc failed\n"); 374 + AL_PRINT("buffer malloc failed\n");
365 + return ALC_FALSE; 375 + return ALC_FALSE;
366 + } 376 + }
367 + SetDefaultWFXChannelOrder(device); 377 + SetDefaultWFXChannelOrder(device);
368 + 378 +
369 + data->read_ptr = 0; 379 + data->read_ptr = 0;
370 + data->write_ptr = 0; 380 + data->write_ptr = 0;
371 + data->thread = StartThread(PpapiProc, device); 381 + data->thread = StartThread(PpapiProc, device);
372 + if(data->thread == NULL) 382 + if (data->thread == NULL)
373 + { 383 + {
374 + free(data->buffer); 384 + free(data->buffer);
375 + data->buffer = NULL; 385 + data->buffer = NULL;
376 + return ALC_FALSE; 386 + return ALC_FALSE;
377 + } 387 + }
378 + data->buffer_ready = 1; 388 + data->buffer_ready = 1;
379 + return ALC_TRUE; 389 + return ALC_TRUE;
380 +} 390 +}
381 + 391 +
382 +static void ppapi_stop_playback(ALCdevice *device) 392 +static void ppapi_stop_playback(ALCdevice *device)
383 +{ 393 +{
384 + ppapi_data *data = (ppapi_data*)device->ExtraData; 394 + ppapi_data *data = (ppapi_data*)device->ExtraData;
385 + 395 +
386 + if(!data->thread) 396 + if (!data->thread)
387 + return; 397 + return;
388 + 398 +
389 + data->killNow = 1; 399 + data->killNow = 1;
390 + StopThread(data->thread); 400 + StopThread(data->thread);
391 + data->thread = NULL; 401 + data->thread = NULL;
392 + 402 +
393 + data->killNow = 0; 403 + data->killNow = 0;
394 + 404 +
395 + data->buffer_ready = 0; 405 + data->buffer_ready = 0;
396 + free(data->buffer); 406 + free(data->buffer);
(...skipping 27 matching lines...) Expand all
424 +{ 434 +{
425 + *func_list = ppapi_funcs; 435 + *func_list = ppapi_funcs;
426 +} 436 +}
427 + 437 +
428 +void alc_ppapi_deinit(void) 438 +void alc_ppapi_deinit(void)
429 +{ 439 +{
430 +} 440 +}
431 + 441 +
432 +void alc_ppapi_probe(int type) 442 +void alc_ppapi_probe(int type)
433 +{ 443 +{
434 + if(type == DEVICE_PROBE) 444 + if (type == DEVICE_PROBE)
435 + AppendDeviceList(ppapiDevice); 445 + AppendDeviceList(ppapiDevice);
436 + else if(type == ALL_DEVICE_PROBE) 446 + else if (type == ALL_DEVICE_PROBE)
437 + AppendAllDeviceList(ppapiDevice); 447 + AppendAllDeviceList(ppapiDevice);
438 +} 448 +}
439 diff -Naur openal-soft-1.13/Alc/wave.c openal-soft-1.13-nacl/Alc/wave.c 449 diff -Naur openal-soft-1.13/Alc/wave.c openal-soft-1.13-nacl/Alc/wave.c
440 --- openal-soft-1.13/Alc/wave.c 2010-12-04 17:51:16.000000000 -0800 450 --- openal-soft-1.13/Alc/wave.c 2010-12-04 17:51:16.000000000 -0800
441 +++ openal-soft-1.13-nacl/Alc/wave.c 2012-01-23 15:45:38.000000000 -0800 451 +++ openal-soft-1.13-nacl/Alc/wave.c 2012-01-23 15:45:38.000000000 -0800
442 @@ -22,7 +22,7 @@ 452 @@ -22,7 +22,7 @@
443 453
444 #include <stdlib.h> 454 #include <stdlib.h>
445 #include <stdio.h> 455 #include <stdio.h>
446 -#include <memory.h> 456 -#include <memory.h>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 +SET(CMAKE_FIND_ROOT_PATH ${NACL_TOOLCHAIN_ROOT}) 544 +SET(CMAKE_FIND_ROOT_PATH ${NACL_TOOLCHAIN_ROOT})
535 + 545 +
536 +# adjust the default behaviour of the FIND_XXX() commands: 546 +# adjust the default behaviour of the FIND_XXX() commands:
537 +# search headers and libraries in the target environment, search 547 +# search headers and libraries in the target environment, search
538 +# programs in the host environment 548 +# programs in the host environment
539 +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 549 +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
540 +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 550 +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
541 +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 551 +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
542 +set(CMAKE_REQUIRED_INCLUDES "${NACL_SDK_ROOT}/include") 552 +set(CMAKE_REQUIRED_INCLUDES "${NACL_SDK_ROOT}/include")
543 +include_directories(${NACL_SDK_ROOT}/include) 553 +include_directories(${NACL_SDK_ROOT}/include)
554 diff -Naur openal-soft-1.13/include/AL/alc.h openal-soft-1.13.nacl/include/AL/al c.h
555 --- openal-soft-1.13/include/AL/alc.h 2010-11-28 14:51:15.000000000 -0800
556 +++ openal-soft-1.13.nacl/include/AL/alc.h 2013-01-31 11:01:44.812082634 -0 800
557 @@ -270,6 +270,15 @@
558 #pragma export off
559 #endif
560
561 +#if defined(__native_client__)
562 +#include <ppapi/c/ppp.h>
563 +#include <ppapi/c/ppp_instance.h>
564 +/* This function is part of the NaCl libopenal port and is
565 + * required to be called before OpenAL initialization.
566 + */
567 +extern void alSetPpapiInfo(PP_Instance, PPB_GetInterface);
568 +#endif
569 +
570 #if defined(__cplusplus)
571 }
572 #endif
OLDNEW
« no previous file with comments | « examples/audio/openal-ogg/pkg_info ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698