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

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-30 13:53:29.840835797 -0800
27 @@ -0,0 +1,411 @@ 27 @@ -0,0 +1,458 @@
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 17 matching lines...) Expand all
55 +#include "ppapi/c/pp_completion_callback.h" 55 +#include "ppapi/c/pp_completion_callback.h"
56 +#include "ppapi/c/pp_instance.h" 56 +#include "ppapi/c/pp_instance.h"
57 +#include "ppapi/c/ppb.h" 57 +#include "ppapi/c/ppb.h"
58 +#include "ppapi/c/ppb_audio.h" 58 +#include "ppapi/c/ppb_audio.h"
59 +#include "ppapi/c/ppb_audio_config.h" 59 +#include "ppapi/c/ppb_audio_config.h"
60 +#include "ppapi/c/ppb_core.h" 60 +#include "ppapi/c/ppb_core.h"
61 + 61 +
62 +/* The output buffer will be this multiple of the OpenAL device update size. 62 +/* The output buffer will be this multiple of the OpenAL device update size.
63 + * This needs to be at least 2 or we can't buffer output properly. 63 + * This needs to be at least 2 or we can't buffer output properly.
64 + */ 64 + */
65 +const ALuint kBufferPadMult = 4; 65 +const ALuint kBufferPadMult = 3;
66 +
66 +/* How many samples for each frame will be buffered to Pepper. 67 +/* How many samples for each frame will be buffered to Pepper.
67 + * Keep this low for low latency, but not too low or we will be CPU bound. 68 + * Keep this low for low latency, but not too low or we will be CPU bound.
68 + */ 69 + */
69 +const ALuint kRequestedFrameCount = 1024; 70 +const ALuint kRequestedFrameCount = 1024;
70 +/* 4 is 2-channels, 2-bytes per sample. */ 71 +/* 4 is 2-channels, 2-bytes per sample. */
71 +const ALuint kFrameSizeInBytes = 4; 72 +const ALuint kFrameSizeInBytes = 4;
72 + 73 +
73 +typedef struct { 74 +typedef struct {
74 + /* Simple circular buffer (single producer/consumer) to buffer data output 75 + /* Simple circular buffer (single producer/consumer) to buffer data output
75 + * from OpenAL before it's handed off to PPAPI. 76 + * from OpenAL before it's handed off to PPAPI.
76 + */ 77 + */
77 + ALvoid *buffer; 78 + ALvoid *buffer;
78 + ALuint size; 79 + ALuint size;
79 + 80 +
80 + PPB_AudioConfig* audio_config; 81 + PPB_AudioConfig* audio_config;
81 + PPB_Audio* audio; 82 + PPB_Audio* audio;
82 + PPB_Core* core; 83 + PPB_Core* core;
83 + 84 +
84 + PP_Resource audio_config_resource; 85 + PP_Resource audio_config_resource;
85 + PP_Resource audio_resource; 86 + PP_Resource audio_resource;
86 + ALuint sample_frame_count; 87 + ALuint sample_frame_count;
87 + 88 +
88 + volatile ALuint read_ptr; 89 + volatile ALuint read_ptr;
89 + volatile ALuint write_ptr; 90 + volatile ALuint write_ptr;
91 + pthread_mutex_t mutex;
92 + pthread_cond_t cond;
90 + 93 +
91 + ALCdevice *device; 94 + ALCdevice *device;
92 + 95 +
93 + volatile int killNow; 96 + int killNow;
94 + ALvoid *thread; 97 + ALvoid *thread;
95 + volatile ALuint main_thread_init_status; 98 + volatile ALuint main_thread_init_status;
96 + ALuint buffer_ready; 99 + ALuint buffer_ready;
97 +} ppapi_data; 100 +} ppapi_data;
98 + 101 +
99 +static PP_Instance gInstance; 102 +static PP_Instance gInstance;
100 +static PPB_GetInterface gGetInterface; 103 +static PPB_GetInterface gGetInterface;
101 + 104 +
102 +AL_API void AL_APIENTRY alSetPpapiInfo(PP_Instance instance, PPB_GetInterface g et_interface) 105 +AL_API void AL_APIENTRY alSetPpapiInfo(PP_Instance instance, PPB_GetInterface g et_interface)
103 +{ 106 +{
104 + gInstance = instance; 107 + gInstance = instance;
105 + gGetInterface = get_interface; 108 + gGetInterface = get_interface;
106 +} 109 +}
107 + 110 +
108 +/* This is the callback from PPAPI to fill in the audio buffer. */ 111 +/* This is the callback from PPAPI to fill in the audio buffer. */
109 +void PPAPI_Audio_Callback(void *sample_buffer, 112 +static void PPAPI_Audio_Callback(void *sample_buffer,
110 + uint32_t buffer_size_in_bytes, 113 + uint32_t buffer_size_in_bytes,
111 + void* user_data) 114 + void* user_data)
112 +{ 115 +{
113 + ppapi_data* data = (ppapi_data*)user_data; 116 + ppapi_data* data = (ppapi_data*)user_data;
114 + if (!data->buffer_ready) return; 117 + if (!data->buffer_ready) return;
115 + 118 +
116 + ALuint write_proxy = data->write_ptr; 119 + ALuint write_proxy = data->write_ptr;
117 + if (data->read_ptr > data->write_ptr) 120 + if (data->read_ptr > data->write_ptr)
118 + write_proxy = data->write_ptr + data->size; 121 + write_proxy = data->write_ptr + data->size;
119 + 122 +
120 + if (data->read_ptr + buffer_size_in_bytes > write_proxy) 123 + int available_bytes = write_proxy - data->read_ptr;
124 + if (available_bytes < buffer_size_in_bytes)
121 + { 125 + {
122 + AL_PRINT("buffer underrun\n"); 126 + AL_PRINT("buffer underrun (buffer size=%d) (only buffering %d)\n", buff er_size_in_bytes, available_bytes);
123 + return; 127 + buffer_size_in_bytes = available_bytes;
elijahtaylor1 2013/01/31 00:32:24 If you're going to fill in part of the buffer, you
Sam Clegg 2013/01/31 17:13:45 Done.
124 + } 128 + }
125 + 129 +
126 + if (data->read_ptr + buffer_size_in_bytes > data->size) 130 + if (data->read_ptr + buffer_size_in_bytes > data->size)
127 + { 131 + {
128 + /* This read straddles the buffer boundary, split it up. */ 132 + /* This read straddles the buffer boundary, split it up. */
129 + memcpy(sample_buffer, 133 + memcpy(sample_buffer,
130 + data->buffer + data->read_ptr, 134 + data->buffer + data->read_ptr,
131 + data->size - data->read_ptr); 135 + data->size - data->read_ptr);
132 + memcpy(sample_buffer + (data->size - data->read_ptr), 136 + memcpy(sample_buffer + (data->size - data->read_ptr),
133 + data->buffer, 137 + data->buffer,
134 + buffer_size_in_bytes - (data->size - data->read_ptr)); 138 + buffer_size_in_bytes - (data->size - data->read_ptr));
135 + } 139 + }
136 + else 140 + else
137 + { 141 + {
138 + memcpy(sample_buffer, 142 + memcpy(sample_buffer,
139 + data->buffer + data->read_ptr, 143 + data->buffer + data->read_ptr,
140 + buffer_size_in_bytes); 144 + buffer_size_in_bytes);
141 + } 145 + }
142 + 146 +
147 + pthread_mutex_lock(&data->mutex);
143 + data->read_ptr += buffer_size_in_bytes; 148 + data->read_ptr += buffer_size_in_bytes;
149 + // wrap read_ptr in circular buffer;
144 + if (data->read_ptr >= data->size) 150 + if (data->read_ptr >= data->size)
145 + data->read_ptr -= data->size; 151 + data->read_ptr -= data->size;
152 + pthread_cond_signal(&data->cond);
153 + pthread_mutex_unlock(&data->mutex);
nfullagar1 2013/01/30 22:19:31 Putting locks in the audio callback is usually not
Sam Clegg 2013/01/31 17:13:45 Removed the pthread stuff from this change.
146 +} 154 +}
147 + 155 +
148 +static const ALCchar ppapiDevice[] = "PPAPI Output"; 156 +static const ALCchar ppapiDevice[] = "PPAPI Output";
149 + 157 +
150 +static ALuint PpapiProc(ALvoid *ptr) 158 +static ALuint PpapiProc(ALvoid *ptr)
151 +{ 159 +{
152 + ALCdevice *Device = (ALCdevice*)ptr; 160 + ALCdevice *Device = (ALCdevice*)ptr;
153 + ppapi_data *data = (ppapi_data*)Device->ExtraData; 161 + ppapi_data *data = (ppapi_data*)Device->ExtraData;
154 + 162 +
155 + ALuint UpdateSizeInBytes = Device->UpdateSize * kFrameSizeInBytes; 163 + ALuint UpdateSizeInBytes = Device->UpdateSize * kFrameSizeInBytes;
156 + ALuint SampleFrameInBytes = data->sample_frame_count * kFrameSizeInBytes; 164 + ALuint SampleFrameInBytes = data->sample_frame_count * kFrameSizeInBytes;
165 +
157 + /* Start to buffer when less than this many bytes are buffered. Keep this 166 + /* 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. 167 + * small for low latency but large enough so we don't starve Pepper.
168 + *
169 + * SampleFrameInBytes is the size of the buffer that PPAPI asks for each
170 + * callback. We want to keep twice this amount in the buffer at any given
171 + * time.
159 + */ 172 + */
160 + const ALuint MinBufferSizeInBytes = 173 + const ALuint MinBufferSizeInBytes = max(SampleFrameInBytes,
elijahtaylor1 2013/01/31 00:32:24 Did you mean (SampleFrameInBytes*2, UpdateSizeInBy
Sam Clegg 2013/01/31 17:13:45 Done.
161 + min(max(SampleFrameInBytes*4, UpdateSizeInBytes), data->size/2); 174 + UpdateSizeInBytes*2);
162 + 175 +
163 + while(!data->killNow && Device->Connected) 176 + pthread_mutex_lock(&data->mutex);
177 + while (!data->killNow && Device->Connected)
164 + { 178 + {
165 + ALuint write_proxy = data->write_ptr; 179 + ALuint write_proxy = data->write_ptr;
180 +
166 + if (data->read_ptr > data->write_ptr) 181 + if (data->read_ptr > data->write_ptr)
167 + write_proxy = data->write_ptr + data->size; 182 + write_proxy = data->write_ptr + data->size;
168 + 183 +
169 + if (data->read_ptr + MinBufferSizeInBytes >= write_proxy) 184 + ALuint bytes_in_buffer = write_proxy - data->read_ptr;
185 + if (bytes_in_buffer < MinBufferSizeInBytes)
170 + { 186 + {
171 + aluMixData(Device, 187 + // Time to buffer more data
172 + data->buffer + data->write_ptr, 188 + pthread_mutex_unlock(&data->mutex);
173 + Device->UpdateSize); 189 +
174 + if (data->write_ptr + UpdateSizeInBytes > data->size) 190 + // Mix samples into buffer in UpdateSizeInBytes chunks
191 + // untill there are more then MinBufferSizeInBytes available.
elijahtaylor1 2013/01/31 00:32:24 until than
Sam Clegg 2013/01/31 17:13:45 Reverted this stuff until we can find a non-busy s
192 + while (bytes_in_buffer < MinBufferSizeInBytes)
175 + { 193 + {
176 + /* Spilled over the edge, copy the last bits to the beginning 194 + aluMixData(Device,
177 + * of the buffer. 195 + data->buffer + data->write_ptr,
178 + */ 196 + Device->UpdateSize);
179 + memcpy(data->buffer, 197 + if (data->write_ptr + UpdateSizeInBytes > data->size)
180 + data->buffer + data->size, 198 + {
181 + UpdateSizeInBytes - (data->size - data->write_ptr)); 199 + /* Spilled over the edge, copy the last bits to the beginni ng
elijahtaylor1 2013/01/31 00:32:24 80 cols. I know it's annoying because there might
Sam Clegg 2013/01/31 17:13:45 Reverted this stuff until we can find a non-busy s
200 + * of the buffer.
201 + */
202 + memcpy(data->buffer,
203 + data->buffer + data->size,
204 + UpdateSizeInBytes - (data->size - data->write_ptr));
205 + }
206 +
207 + data->write_ptr += UpdateSizeInBytes;
208 + if (data->write_ptr >= data->size)
209 + data->write_ptr -= data->size;
210 +
211 + bytes_in_buffer += UpdateSizeInBytes;
182 + } 212 + }
183 + 213 +
184 + data->write_ptr += UpdateSizeInBytes; 214 + pthread_mutex_lock(&data->mutex);
185 + if (data->write_ptr >= data->size)
186 + data->write_ptr -= data->size;
187 + } 215 + }
188 + /* Small 1 ms sleep so we don't use too much CPU time. */ 216 + else
189 + Sleep(1); 217 + {
218 + // The first time we finished buffering we trigger the reader to
219 + // start reading
220 + if (!data->buffer_ready)
221 + {
222 + data->buffer_ready = 1;
223 + }
224 +
225 + // Wait for reader to read more data
226 + pthread_cond_wait(&data->cond, &data->mutex);
227 + }
190 + } 228 + }
229 + pthread_mutex_unlock(&data->mutex);
191 + 230 +
192 + return 0; 231 + return 0;
193 +} 232 +}
194 + 233 +
195 +/* This needs to be called on the main PPAPI thread. */ 234 +/* This needs to be called on the main PPAPI thread. */
196 +static void ppapi_open_playback_main_thread(void* user_data, int32_t result) 235 +static void ppapi_open_playback_main_thread(void* user_data, int32_t result)
197 +{ 236 +{
198 + ppapi_data *data = (ppapi_data*)user_data; 237 + ppapi_data *data = (ppapi_data*)user_data;
199 + (void)result; 238 + (void)result;
200 + 239 +
201 + PP_AudioSampleRate rate = PP_AUDIOSAMPLERATE_44100; 240 + PP_AudioSampleRate rate = PP_AUDIOSAMPLERATE_44100;
202 + if (data->device->Frequency == 48000) 241 + if (data->device->Frequency == 48000)
203 + rate = PP_AUDIOSAMPLERATE_48000; 242 + rate = PP_AUDIOSAMPLERATE_48000;
204 + 243 +
205 + data->sample_frame_count = 244 + data->sample_frame_count =
206 + data->audio_config->RecommendSampleFrameCount( 245 + data->audio_config->RecommendSampleFrameCount(
207 +#ifdef PPB_AUDIO_CONFIG_INTERFACE_1_1 246 +#ifdef PPB_AUDIO_CONFIG_INTERFACE_1_1
208 + gInstance, 247 + gInstance,
209 +#endif 248 +#endif
210 + rate, 249 + rate,
211 + kRequestedFrameCount); 250 + kRequestedFrameCount);
212 + 251 +
252 + //AL_PRINT("recommend frames: %d (rate=%d) (size=%d)\n", data->sample_frame _count, rate, data->sample_frame_count*2*2);
213 + data->audio_config_resource = 253 + data->audio_config_resource =
214 + data->audio_config->CreateStereo16Bit(gInstance, 254 + data->audio_config->CreateStereo16Bit(gInstance,
215 + rate, 255 + rate,
216 + data->sample_frame_count); 256 + data->sample_frame_count);
217 + 257 +
218 + if (PP_FALSE == data->audio_config->IsAudioConfig(data->audio_config_resour ce)) { 258 + if (PP_FALSE == data->audio_config->IsAudioConfig(data->audio_config_resour ce)) {
219 + AL_PRINT("PPAPI initialization: audio config creation failed."); 259 + AL_PRINT("PPAPI initialization: audio config creation failed.");
220 + data->main_thread_init_status = -1; 260 + data->main_thread_init_status = -1;
221 + return; 261 + return;
222 + } 262 + }
223 + 263 +
224 + data->audio_resource = data->audio->Create(gInstance, 264 + data->audio_resource = data->audio->Create(gInstance,
225 + data->audio_config_resource, 265 + data->audio_config_resource,
226 + PPAPI_Audio_Callback, 266 + PPAPI_Audio_Callback,
227 + (void*)data); 267 + (void*)data);
228 + 268 +
229 + if (PP_FALSE == data->audio->IsAudio(data->audio_resource)) { 269 + if (PP_FALSE == data->audio->IsAudio(data->audio_resource)) {
230 + AL_PRINT("PPAPI initialization: audio resource creation failed."); 270 + AL_PRINT("PPAPI initialization: audio resource creation failed.");
231 + data->main_thread_init_status = -1; 271 + data->main_thread_init_status = -1;
232 + return; 272 + return;
233 + } 273 + }
234 + 274 +
235 + if (PP_FALSE == data->audio->StartPlayback(data->audio_resource)) { 275 + if (PP_FALSE == data->audio->StartPlayback(data->audio_resource)) {
236 + AL_PRINT("PPAPI initialization: start playback failed."); 276 + AL_PRINT("PPAPI initialization: start playback failed.");
237 + data->main_thread_init_status = -1; 277 + data->main_thread_init_status = -1;
238 + return; 278 + return;
239 + } 279 + }
240 + 280 +
241 + data->main_thread_init_status = 1; 281 + data->main_thread_init_status = 1;
242 +} 282 +}
243 + 283 +
244 +static ALCboolean ppapi_open_playback(ALCdevice *device, 284 +static ALCboolean ppapi_open_playback(ALCdevice *device,
245 + const ALCchar *deviceName) 285 + const ALCchar *deviceName)
246 +{ 286 +{
247 + ppapi_data *data; 287 + ppapi_data *data;
248 + 288 +
249 + if(!deviceName) 289 + if (!deviceName)
250 + deviceName = ppapiDevice; 290 + deviceName = ppapiDevice;
251 + else if(strcmp(deviceName, ppapiDevice) != 0) 291 + else if (strcmp(deviceName, ppapiDevice) != 0)
252 + return ALC_FALSE; 292 + return ALC_FALSE;
253 + 293 +
254 + int channels = ChannelsFromDevFmt(device->FmtChans); 294 + int channels = ChannelsFromDevFmt(device->FmtChans);
255 + int bytes = BytesFromDevFmt(device->FmtType); 295 + int bytes = BytesFromDevFmt(device->FmtType);
256 + 296 +
257 + if (channels != 2) 297 + if (channels != 2)
258 + { 298 + {
259 + AL_PRINT("PPAPI only supports 2 channel output\n"); 299 + AL_PRINT("PPAPI only supports 2 channel output\n");
260 + return ALC_FALSE; 300 + return ALC_FALSE;
261 + } 301 + }
262 + if (bytes != 2) 302 + if (bytes != 2)
263 + { 303 + {
264 + AL_PRINT("PPAPI only supports 16-bit output\n"); 304 + AL_PRINT("PPAPI only supports 16-bit output\n");
265 + return ALC_FALSE; 305 + return ALC_FALSE;
266 + } 306 + }
267 + if (device->Frequency != 44100 && device->Frequency != 44800) 307 + if (device->Frequency != 44100 && device->Frequency != 44800)
268 + { 308 + {
269 + AL_PRINT("PPAPI only supports 44100 and 44800 sample frequencies\n"); 309 + AL_PRINT("PPAPI only supports 44100 and 44800 sample frequencies\n");
270 + return ALC_FALSE; 310 + return ALC_FALSE;
271 + } 311 + }
272 + 312 +
273 + data = (ppapi_data*)calloc(1, sizeof(*data)); 313 + data = (ppapi_data*)calloc(1, sizeof(*data));
314 + pthread_mutex_init(&data->mutex, NULL);
315 + pthread_cond_init(&data->cond, NULL);
274 + 316 +
275 + device->szDeviceName = strdup(deviceName); 317 + device->szDeviceName = strdup(deviceName);
276 + device->ExtraData = data; 318 + device->ExtraData = data;
277 + data->device = device; 319 + data->device = device;
278 + 320 +
279 + data->audio_config = 321 + data->audio_config =
280 + (PPB_AudioConfig*)gGetInterface(PPB_AUDIO_CONFIG_INTERFACE); 322 + (PPB_AudioConfig*)gGetInterface(PPB_AUDIO_CONFIG_INTERFACE);
281 + if (!data->audio_config) 323 + if (!data->audio_config)
282 + { 324 + {
283 + free(data); 325 + free(data);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 + } 388 + }
347 + 389 +
348 + device->ExtraData = NULL; 390 + device->ExtraData = NULL;
349 +} 391 +}
350 + 392 +
351 +static ALCboolean ppapi_reset_playback(ALCdevice *device) 393 +static ALCboolean ppapi_reset_playback(ALCdevice *device)
352 +{ 394 +{
353 + ppapi_data *data = (ppapi_data*)device->ExtraData; 395 + ppapi_data *data = (ppapi_data*)device->ExtraData;
354 + 396 +
355 + ALuint UpdateSizeInBytes = device->UpdateSize * kFrameSizeInBytes; 397 + ALuint UpdateSizeInBytes = device->UpdateSize * kFrameSizeInBytes;
398 + ALuint SampleFrameInBytes = data->sample_frame_count * kFrameSizeInBytes;
356 + /* kBufferPadMult is added to protect against buffer underruns. */ 399 + /* kBufferPadMult is added to protect against buffer underruns. */
357 + data->size = UpdateSizeInBytes * kBufferPadMult; 400 + data->size = max(UpdateSizeInBytes, SampleFrameInBytes) * kBufferPadMult;
401 +
358 + /* Extra UpdateSize added so we can read off the end of the buffer in one 402 + /* 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. 403 + * shot from aluMixData, but treat the buffer like it's of size data->size.
360 + */ 404 + */
361 + data->buffer = calloc(1, data->size + UpdateSizeInBytes); 405 + data->buffer = calloc(1, data->size + UpdateSizeInBytes);
362 + if(!data->buffer) 406 + if (!data->buffer)
363 + { 407 + {
364 + AL_PRINT("buffer malloc failed\n"); 408 + AL_PRINT("buffer malloc failed\n");
365 + return ALC_FALSE; 409 + return ALC_FALSE;
366 + } 410 + }
367 + SetDefaultWFXChannelOrder(device); 411 + SetDefaultWFXChannelOrder(device);
368 + 412 +
369 + data->read_ptr = 0; 413 + data->read_ptr = 0;
370 + data->write_ptr = 0; 414 + data->write_ptr = 0;
371 + data->thread = StartThread(PpapiProc, device); 415 + data->thread = StartThread(PpapiProc, device);
372 + if(data->thread == NULL) 416 + if (data->thread == NULL)
373 + { 417 + {
374 + free(data->buffer); 418 + free(data->buffer);
375 + data->buffer = NULL; 419 + data->buffer = NULL;
376 + return ALC_FALSE; 420 + return ALC_FALSE;
377 + } 421 + }
378 + data->buffer_ready = 1;
379 + return ALC_TRUE; 422 + return ALC_TRUE;
380 +} 423 +}
381 + 424 +
382 +static void ppapi_stop_playback(ALCdevice *device) 425 +static void ppapi_stop_playback(ALCdevice *device)
383 +{ 426 +{
384 + ppapi_data *data = (ppapi_data*)device->ExtraData; 427 + ppapi_data *data = (ppapi_data*)device->ExtraData;
385 + 428 +
386 + if(!data->thread) 429 + if (!data->thread)
387 + return; 430 + return;
388 + 431 +
432 + // Signal thread to die
433 + pthread_mutex_lock(&data->mutex);
389 + data->killNow = 1; 434 + data->killNow = 1;
435 + pthread_cond_signal(&data->cond);
436 + pthread_mutex_unlock(&data->mutex);
437 +
390 + StopThread(data->thread); 438 + StopThread(data->thread);
439 +
391 + data->thread = NULL; 440 + data->thread = NULL;
392 +
393 + data->killNow = 0; 441 + data->killNow = 0;
394 +
395 + data->buffer_ready = 0; 442 + data->buffer_ready = 0;
396 + free(data->buffer); 443 + free(data->buffer);
397 + data->buffer = NULL; 444 + data->buffer = NULL;
398 +} 445 +}
399 + 446 +
400 + 447 +
401 +static ALCboolean ppapi_open_capture(ALCdevice *device, 448 +static ALCboolean ppapi_open_capture(ALCdevice *device,
402 + const ALCchar *deviceName) 449 + const ALCchar *deviceName)
403 +{ 450 +{
404 + (void)device; 451 + (void)device;
(...skipping 19 matching lines...) Expand all
424 +{ 471 +{
425 + *func_list = ppapi_funcs; 472 + *func_list = ppapi_funcs;
426 +} 473 +}
427 + 474 +
428 +void alc_ppapi_deinit(void) 475 +void alc_ppapi_deinit(void)
429 +{ 476 +{
430 +} 477 +}
431 + 478 +
432 +void alc_ppapi_probe(int type) 479 +void alc_ppapi_probe(int type)
433 +{ 480 +{
434 + if(type == DEVICE_PROBE) 481 + if (type == DEVICE_PROBE)
435 + AppendDeviceList(ppapiDevice); 482 + AppendDeviceList(ppapiDevice);
436 + else if(type == ALL_DEVICE_PROBE) 483 + else if (type == ALL_DEVICE_PROBE)
437 + AppendAllDeviceList(ppapiDevice); 484 + AppendAllDeviceList(ppapiDevice);
438 +} 485 +}
439 diff -Naur openal-soft-1.13/Alc/wave.c openal-soft-1.13-nacl/Alc/wave.c 486 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 487 --- 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 488 +++ openal-soft-1.13-nacl/Alc/wave.c 2012-01-23 15:45:38.000000000 -0800
442 @@ -22,7 +22,7 @@ 489 @@ -22,7 +22,7 @@
443 490
444 #include <stdlib.h> 491 #include <stdlib.h>
445 #include <stdio.h> 492 #include <stdio.h>
446 -#include <memory.h> 493 -#include <memory.h>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 +SET(CMAKE_FIND_ROOT_PATH ${NACL_TOOLCHAIN_ROOT}) 581 +SET(CMAKE_FIND_ROOT_PATH ${NACL_TOOLCHAIN_ROOT})
535 + 582 +
536 +# adjust the default behaviour of the FIND_XXX() commands: 583 +# adjust the default behaviour of the FIND_XXX() commands:
537 +# search headers and libraries in the target environment, search 584 +# search headers and libraries in the target environment, search
538 +# programs in the host environment 585 +# programs in the host environment
539 +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 586 +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
540 +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 587 +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
541 +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 588 +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
542 +set(CMAKE_REQUIRED_INCLUDES "${NACL_SDK_ROOT}/include") 589 +set(CMAKE_REQUIRED_INCLUDES "${NACL_SDK_ROOT}/include")
543 +include_directories(${NACL_SDK_ROOT}/include) 590 +include_directories(${NACL_SDK_ROOT}/include)
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