~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/sdl_audio.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <stdio.h>
 
2
#include <stdlib.h>
2
3
#include <SDL/SDL.h>
3
4
#include <SDL/SDL_mixer.h>
4
5
#include <assert.h>
5
6
#include <emscripten.h>
6
 
 
7
 
Mix_Chunk *sound, *sound2;
8
 
 
 
7
#include <sys/stat.h>
 
8
 
 
9
Mix_Chunk *sound, *sound2, *sound3;
 
10
Mix_Music * music;
9
11
int play2();
10
12
 
11
13
int play() {
28
30
 
29
31
  int channel2 = Mix_PlayChannel(-1, sound2, 0);
30
32
  assert(channel2 == 1);
 
33
  int channel3 = Mix_PlayChannel(-1, sound3, 0);
 
34
  assert(channel3 == 2);
 
35
  assert(Mix_PlayMusic(music, 1) == 0);
31
36
  return channel2;
32
37
}
33
38
 
39
44
 
40
45
  sound = Mix_LoadWAV("sound.ogg");
41
46
  assert(sound);
 
47
  
 
48
  {
 
49
      struct stat info;
 
50
      int result = stat("noise.ogg", &info);
 
51
      char * bytes = malloc( info.st_size );
 
52
      FILE * f = fopen( "noise.ogg", "rb" );
 
53
      fread( bytes, 1, info.st_size, f  );
 
54
      fclose(f);
 
55
  
 
56
      SDL_RWops * ops = SDL_RWFromConstMem(bytes, info.st_size);
 
57
      sound3 = Mix_LoadWAV_RW(ops, 0);
 
58
      SDL_FreeRW(ops);
 
59
      free(bytes);
 
60
  }
 
61
 
 
62
  {
 
63
      music = Mix_LoadMUS("the_entertainer.ogg");
 
64
  }
 
65
  
 
66
  
42
67
  sound2 = Mix_LoadWAV("sound2.wav");
43
68
  assert(sound);
44
69