Update with current status
[gnash.git] / testsuite / misc-ming.all / sound / streamingSoundTest1.c
blob1184c59732b0af48a7cabc0c44b803c9a9410ffa
1 /*
2 * Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
20 * Test for streaming sound
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
31 #include <ming.h>
33 #include "ming_utils.h"
35 #define OUTPUT_VERSION 6
36 #define OUTPUT_FILENAME "streamingSoundTest1.swf"
39 int
40 main(int argc, char** argv)
42 SWFMovie mo;
43 SWFMovieClip mc;
44 SWFSoundStream ss;
45 FILE* sound_f;
46 const char* sound_filename;
47 struct stat statbuf;
49 sound_filename=MEDIADIR"/click.mp3";
51 sound_f = fopen(sound_filename, "r");
52 if ( ! sound_f ) {
53 perror(sound_filename);
54 return EXIT_FAILURE;
57 printf("Using sound file %s\n", sound_filename);
59 if ( -1 == fstat(fileno(sound_f), &statbuf) )
61 perror("fstat");
62 return EXIT_FAILURE;
64 if ( S_ISDIR(statbuf.st_mode) )
66 fprintf(stderr, "%s is a directory, we need a file\n", sound_filename);
67 return EXIT_FAILURE;
70 Ming_init();
71 Ming_useSWFVersion (OUTPUT_VERSION);
73 mo = newSWFMovie();
74 SWFMovie_setDimension(mo, 100, 100);
75 SWFMovie_setRate(mo, 1);
77 ss = newSWFSoundStream(sound_f);
79 mc = newSWFMovieClip();
80 SWFMovieClip_setSoundStream(mc, ss, 2);
81 SWFMovieClip_nextFrame(mc);
82 SWFMovieClip_nextFrame(mc);
83 SWFMovieClip_nextFrame(mc);
84 SWFMovieClip_nextFrame(mc);
86 SWFMovie_add(mo, mc);
87 SWFMovie_nextFrame(mo);
88 SWFMovie_nextFrame(mo);
89 SWFMovie_nextFrame(mo);
90 SWFMovie_nextFrame(mo);
91 SWFMovie_nextFrame(mo);
92 SWFMovie_nextFrame(mo);
93 SWFMovie_nextFrame(mo);
94 SWFMovie_nextFrame(mo);
96 //Output movie
97 puts("Saving " OUTPUT_FILENAME );
98 SWFMovie_save(mo, OUTPUT_FILENAME);
100 return EXIT_SUCCESS;