| OLD | NEW |
| 1 diff --git a/Makefile.in b/Makefile.in | 1 diff --git a/Makefile.in b/Makefile.in |
| 2 index e29dc6d..bb485dd 100644 | 2 index e29dc6d..bb485dd 100644 |
| 3 --- a/Makefile.in | 3 --- a/Makefile.in |
| 4 +++ b/Makefile.in | 4 +++ b/Makefile.in |
| 5 @@ -36,13 +36,13 @@ TARGET = libSDL.la | 5 @@ -36,13 +36,13 @@ TARGET = libSDL.la |
| 6 SOURCES = @SOURCES@ | 6 SOURCES = @SOURCES@ |
| 7 OBJECTS = @OBJECTS@ | 7 OBJECTS = @OBJECTS@ |
| 8 | 8 |
| 9 -SDLMAIN_TARGET = libSDLmain.a | 9 -SDLMAIN_TARGET = libSDLmain.a |
| 10 +SDLMAIN_TARGET = libSDLmain.la | 10 +SDLMAIN_TARGET = libSDLmain.la |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap; | 316 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap; |
| 317 #endif | 317 #endif |
| 318 +#if SDL_AUDIO_DRIVER_NACL | 318 +#if SDL_AUDIO_DRIVER_NACL |
| 319 +extern AudioBootStrap NACLAUD_bootstrap; | 319 +extern AudioBootStrap NACLAUD_bootstrap; |
| 320 +#endif | 320 +#endif |
| 321 #if SDL_AUDIO_DRIVER_DISK | 321 #if SDL_AUDIO_DRIVER_DISK |
| 322 extern AudioBootStrap DISKAUD_bootstrap; | 322 extern AudioBootStrap DISKAUD_bootstrap; |
| 323 #endif | 323 #endif |
| 324 diff --git a/src/audio/nacl/SDL_naclaudio.cc b/src/audio/nacl/SDL_naclaudio.cc | 324 diff --git a/src/audio/nacl/SDL_naclaudio.cc b/src/audio/nacl/SDL_naclaudio.cc |
| 325 new file mode 100644 | 325 new file mode 100644 |
| 326 index 0000000..908a498 | 326 index 0000000..7a02156 |
| 327 --- /dev/null | 327 --- /dev/null |
| 328 +++ b/src/audio/nacl/SDL_naclaudio.cc | 328 +++ b/src/audio/nacl/SDL_naclaudio.cc |
| 329 @@ -0,0 +1,150 @@ | 329 @@ -0,0 +1,140 @@ |
| 330 +#include "SDL_config.h" | 330 +#include "SDL_config.h" |
| 331 +#include "SDL_naclaudio.h" | 331 +#include "SDL_naclaudio.h" |
| 332 + | 332 + |
| 333 +#include <assert.h> | 333 +#include <assert.h> |
| 334 + | 334 + |
| 335 +#include <ppapi/c/pp_instance.h> | 335 +#include <ppapi/c/pp_instance.h> |
| 336 +#include <ppapi/c/ppb.h> | 336 +#include <ppapi/c/ppb.h> |
| 337 +#include <ppapi/c/ppb_audio.h> | 337 +#include <ppapi/c/ppb_audio.h> |
| 338 +#include <ppapi/c/ppb_audio_config.h> | 338 +#include <ppapi/c/ppb_audio_config.h> |
| 339 +#include <ppapi/c/ppb_core.h> | 339 +#include <ppapi/c/ppb_core.h> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 + SDL_OutOfMemory(); | 394 + SDL_OutOfMemory(); |
| 395 + if (_this) { | 395 + if (_this) { |
| 396 + SDL_free(_this); | 396 + SDL_free(_this); |
| 397 + } | 397 + } |
| 398 + return (0); | 398 + return (0); |
| 399 + } | 399 + } |
| 400 + SDL_memset(_this->hidden, 0, (sizeof *_this->hidden)); | 400 + SDL_memset(_this->hidden, 0, (sizeof *_this->hidden)); |
| 401 + | 401 + |
| 402 + _this->hidden->mutex = SDL_CreateMutex(); | 402 + _this->hidden->mutex = SDL_CreateMutex(); |
| 403 + | 403 + |
| 404 + _this->hidden->opened = false; | |
| 405 + | |
| 406 + // TODO: Move audio device creation to NACLAUD_OpenAudio. | 404 + // TODO: Move audio device creation to NACLAUD_OpenAudio. |
| 407 + const PPB_Audio_1_1* g_nacl_audio_interface = | 405 + g_nacl_audio_interface = |
| 408 + (const PPB_Audio_1_1*)g_nacl_get_interface(PPB_AUDIO_INTERFACE_1_1); | 406 + (const PPB_Audio_1_1*)g_nacl_get_interface(PPB_AUDIO_INTERFACE_1_1); |
| 409 + const PPB_AudioConfig_1_1* g_nacl_audio_config_interface = | 407 + g_nacl_audio_config_interface = |
| 410 + (const PPB_AudioConfig_1_1*)g_nacl_get_interface( | 408 + (const PPB_AudioConfig_1_1*)g_nacl_get_interface( |
| 411 + PPB_AUDIO_CONFIG_INTERFACE_1_1); | 409 + PPB_AUDIO_CONFIG_INTERFACE_1_1); |
| 412 + | 410 + |
| 413 + _this->hidden->sample_frame_count = | 411 + _this->hidden->sample_frame_count = |
| 414 + g_nacl_audio_config_interface->RecommendSampleFrameCount( | 412 + g_nacl_audio_config_interface->RecommendSampleFrameCount( |
| 415 + g_nacl_pp_instance, PP_AUDIOSAMPLERATE_44100, kSampleFrameCount); | 413 + g_nacl_pp_instance, PP_AUDIOSAMPLERATE_44100, kSampleFrameCount); |
| 416 + | 414 + |
| 417 + PP_Resource audio_config = g_nacl_audio_config_interface->CreateStereo16Bit( | 415 + PP_Resource audio_config = g_nacl_audio_config_interface->CreateStereo16Bit( |
| 418 + g_nacl_pp_instance, PP_AUDIOSAMPLERATE_44100, | 416 + g_nacl_pp_instance, PP_AUDIOSAMPLERATE_44100, |
| 419 + _this->hidden->sample_frame_count); | 417 + _this->hidden->sample_frame_count); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 431 + | 429 + |
| 432 + return _this; | 430 + return _this; |
| 433 +} | 431 +} |
| 434 + | 432 + |
| 435 +AudioBootStrap NACLAUD_bootstrap = { | 433 +AudioBootStrap NACLAUD_bootstrap = { |
| 436 + NACLAUD_DRIVER_NAME, "SDL nacl audio driver", | 434 + NACLAUD_DRIVER_NAME, "SDL nacl audio driver", |
| 437 + NACLAUD_Available, NACLAUD_CreateDevice | 435 + NACLAUD_Available, NACLAUD_CreateDevice |
| 438 +}; | 436 +}; |
| 439 + | 437 + |
| 440 +static void NACLAUD_CloseAudio(_THIS) { | 438 +static void NACLAUD_CloseAudio(_THIS) { |
| 441 + SDL_LockMutex(_this->hidden->mutex); | |
| 442 + _this->hidden->opened = 0; | |
| 443 + SDL_UnlockMutex(_this->hidden->mutex); | |
| 444 +} | 439 +} |
| 445 + | 440 + |
| 446 +static void AudioCallback(void* samples, uint32_t buffer_size, PP_TimeDelta, | 441 +static void AudioCallback(void* samples, uint32_t buffer_size, PP_TimeDelta, |
| 447 + void* data) { | 442 + void* data) { |
| 448 + SDL_AudioDevice* _this = reinterpret_cast<SDL_AudioDevice*>(data); | 443 + SDL_AudioDevice* _this = reinterpret_cast<SDL_AudioDevice*>(data); |
| 449 + | 444 + |
| 450 + SDL_LockMutex(_this->hidden->mutex); | 445 + SDL_LockMutex(_this->hidden->mutex); |
| 451 + if (_this->hidden->opened) { | 446 + /* Only do anything if audio is enabled and not paused */ |
| 447 + if (_this->enabled && !_this->paused) { |
| 452 + SDL_memset(samples, _this->spec.silence, buffer_size); | 448 + SDL_memset(samples, _this->spec.silence, buffer_size); |
| 453 + SDL_LockMutex(_this->mixer_lock); | 449 + SDL_LockMutex(_this->mixer_lock); |
| 454 + (*_this->spec.callback)(_this->spec.userdata, (Uint8*)samples, buffer_size)
; | 450 + (*_this->spec.callback)(_this->spec.userdata, (Uint8*)samples, buffer_size)
; |
| 455 + SDL_UnlockMutex(_this->mixer_lock); | 451 + SDL_UnlockMutex(_this->mixer_lock); |
| 456 + } else { | 452 + } else { |
| 457 + SDL_memset(samples, 0, buffer_size); | 453 + SDL_memset(samples, 0, buffer_size); |
| 458 + } | 454 + } |
| 459 + SDL_UnlockMutex(_this->hidden->mutex); | 455 + SDL_UnlockMutex(_this->hidden->mutex); |
| 460 + | 456 + |
| 461 + return; | 457 + return; |
| 462 +} | 458 +} |
| 463 + | 459 + |
| 464 +static int NACLAUD_OpenAudio(_THIS, SDL_AudioSpec* spec) { | 460 +static int NACLAUD_OpenAudio(_THIS, SDL_AudioSpec* spec) { |
| 465 + // We don't care what the user wants. | 461 + // We don't care what the user wants. |
| 466 + spec->freq = 44100; | 462 + spec->freq = 44100; |
| 467 + spec->format = AUDIO_S16LSB; | 463 + spec->format = AUDIO_S16LSB; |
| 468 + spec->channels = 2; | 464 + spec->channels = 2; |
| 469 + spec->samples = _this->hidden->sample_frame_count; | 465 + spec->samples = _this->hidden->sample_frame_count; |
| 470 + | |
| 471 + SDL_LockMutex(_this->hidden->mutex); | |
| 472 + _this->hidden->opened = 1; | |
| 473 + SDL_UnlockMutex(_this->hidden->mutex); | |
| 474 + | |
| 475 + // Do not create an audio thread. | |
| 476 + return 1; | 466 + return 1; |
| 477 +} | 467 +} |
| 478 + | 468 + |
| 479 +} // extern "C" | 469 +} // extern "C" |
| 480 diff --git a/src/audio/nacl/SDL_naclaudio.h b/src/audio/nacl/SDL_naclaudio.h | 470 diff --git a/src/audio/nacl/SDL_naclaudio.h b/src/audio/nacl/SDL_naclaudio.h |
| 481 new file mode 100644 | 471 new file mode 100644 |
| 482 index 0000000..b166ab0 | 472 index 0000000..ab52848 |
| 483 --- /dev/null | 473 --- /dev/null |
| 484 +++ b/src/audio/nacl/SDL_naclaudio.h | 474 +++ b/src/audio/nacl/SDL_naclaudio.h |
| 485 @@ -0,0 +1,30 @@ | 475 @@ -0,0 +1,23 @@ |
| 486 +#include "SDL_config.h" | 476 +#include "SDL_config.h" |
| 487 + | 477 + |
| 488 +#ifndef _SDL_naclaudio_h | 478 +#ifndef _SDL_naclaudio_h |
| 489 +#define _SDL_naclaudio_h | 479 +#define _SDL_naclaudio_h |
| 490 + | 480 + |
| 491 +extern "C" { | 481 +extern "C" { |
| 492 +#include "SDL_audio.h" | 482 +#include "SDL_audio.h" |
| 493 +#include "../SDL_sysaudio.h" | 483 +#include "../SDL_sysaudio.h" |
| 494 +#include "SDL_mutex.h" | 484 +#include "SDL_mutex.h" |
| 495 +} | 485 +} |
| 496 + | 486 + |
| 497 +#include <ppapi/c/ppb_audio.h> | 487 +#include <ppapi/c/ppb_audio.h> |
| 498 + | 488 + |
| 499 +/* Hidden "this" pointer for the video functions */ | 489 +/* Hidden "this" pointer for the video functions */ |
| 500 +#define _THIS SDL_AudioDevice *_this | 490 +#define _THIS SDL_AudioDevice *_this |
| 501 + | 491 + |
| 502 +struct SDL_PrivateAudioData { | 492 +struct SDL_PrivateAudioData { |
| 503 + | |
| 504 + SDL_mutex* mutex; | 493 + SDL_mutex* mutex; |
| 505 + // This flag is use to determine when the audio is opened and we can start | |
| 506 + // serving audio data instead of silence. This is needed because current | |
| 507 + // Pepper2 can only be used from the main thread; Therefore, we start the | |
| 508 + // audio thread very early. | |
| 509 + bool opened; | |
| 510 + | |
| 511 + int sample_frame_count; | 494 + int sample_frame_count; |
| 512 + PP_Resource audio; | 495 + PP_Resource audio; |
| 513 +}; | 496 +}; |
| 514 + | 497 + |
| 515 +#endif /* _SDL_naclaudio_h */ | 498 +#endif /* _SDL_naclaudio_h */ |
| 516 diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c | 499 diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c |
| 517 index 5c2d81f..7a757a3 100644 | 500 index 5c2d81f..7a757a3 100644 |
| 518 --- a/src/cpuinfo/SDL_cpuinfo.c | 501 --- a/src/cpuinfo/SDL_cpuinfo.c |
| 519 +++ b/src/cpuinfo/SDL_cpuinfo.c | 502 +++ b/src/cpuinfo/SDL_cpuinfo.c |
| 520 @@ -53,6 +53,8 @@ static void illegal_instruction(int sig) | 503 @@ -53,6 +53,8 @@ static void illegal_instruction(int sig) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 537 +static __inline__ int CPU_getCPUIDFeatures(void) { return 0; } | 520 +static __inline__ int CPU_getCPUIDFeatures(void) { return 0; } |
| 538 + | 521 + |
| 539 +#endif // SDL_ASSEMBLY_ROUTINES | 522 +#endif // SDL_ASSEMBLY_ROUTINES |
| 540 + | 523 + |
| 541 + | 524 + |
| 542 static __inline__ int CPU_haveRDTSC(void) | 525 static __inline__ int CPU_haveRDTSC(void) |
| 543 { | 526 { |
| 544 if ( CPU_haveCPUID() ) { | 527 if ( CPU_haveCPUID() ) { |
| 545 diff --git a/src/main/nacl/pepper_instance.c b/src/main/nacl/pepper_instance.c | 528 diff --git a/src/main/nacl/pepper_instance.c b/src/main/nacl/pepper_instance.c |
| 546 new file mode 100644 | 529 new file mode 100644 |
| 547 index 0000000..0a3ca79 | 530 index 0000000..997e13a |
| 548 --- /dev/null | 531 --- /dev/null |
| 549 +++ b/src/main/nacl/pepper_instance.c | 532 +++ b/src/main/nacl/pepper_instance.c |
| 550 @@ -0,0 +1,310 @@ | 533 @@ -0,0 +1,310 @@ |
| 551 +/* | 534 +/* |
| 552 + * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 535 + * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 553 + * Use of this source code is governed by a BSD-style license that can be | 536 + * Use of this source code is governed by a BSD-style license that can be |
| 554 + * found in the LICENSE file. | 537 + * found in the LICENSE file. |
| 555 + */ | 538 + */ |
| 556 +#include <assert.h> | 539 +#include <assert.h> |
| 557 +#include <errno.h> | 540 +#include <errno.h> |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 + queue_.push(event); | 1789 + queue_.push(event); |
| 1807 + SDL_UnlockMutex(mu_); | 1790 + SDL_UnlockMutex(mu_); |
| 1808 + } | 1791 + } |
| 1809 + | 1792 + |
| 1810 +private: | 1793 +private: |
| 1811 + std::queue<SDL_Event*> queue_; | 1794 + std::queue<SDL_Event*> queue_; |
| 1812 + SDL_mutex* mu_; | 1795 + SDL_mutex* mu_; |
| 1813 +}; | 1796 +}; |
| 1814 + | 1797 + |
| 1815 +#endif // _SDL_nacl_eventqueue_h | 1798 +#endif // _SDL_nacl_eventqueue_h |
| OLD | NEW |