~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to testsuite/misc-ming.all/EmbeddedSoundTest.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 *   Copyright (C) 2005, 2006, 2007, 2008 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
 
16
 *
 
17
 *
 
18
 */ 
 
19
 
 
20
#include <stdlib.h>
 
21
#include <stdio.h>
 
22
#include <ming.h>
 
23
 
 
24
#include "ming_utils.h"
 
25
 
 
26
#define OUTPUT_VERSION 8
 
27
#define OUTPUT_FILENAME "EmbeddedSoundTest.swf"
 
28
 
 
29
void addSoundExport(SWFMovie mo);
 
30
 
 
31
void
 
32
addSoundExport(SWFMovie mo)
 
33
{
 
34
    SWFSound soundMP3a;
 
35
    SWFSound soundMP3b;
 
36
    SWFSound soundMP3c;
 
37
    SWFSound soundMP3d;
 
38
 
 
39
    FILE* f;
 
40
    FILE* f2;
 
41
 
 
42
    f = fopen(MEDIADIR"/mono44.mp2", "r");
 
43
 
 
44
    if (!f)
 
45
    {
 
46
        exit(EXIT_FAILURE);
 
47
    }
 
48
    soundMP3a = newSWFSound(f, SWF_SOUND_MP3_COMPRESSED |
 
49
            SWF_SOUND_44KHZ |
 
50
            SWF_SOUND_16BITS |
 
51
            SWF_SOUND_MONO);
 
52
    
 
53
    soundMP3b = newSWFSound(f, SWF_SOUND_MP3_COMPRESSED |
 
54
            SWF_SOUND_22KHZ |
 
55
            SWF_SOUND_16BITS |
 
56
            SWF_SOUND_STEREO);
 
57
 
 
58
 
 
59
    f2 = fopen(MEDIADIR"/stereo8.mp3", "r");
 
60
    if (f2 == NULL)
 
61
    {
 
62
        exit(EXIT_FAILURE);
 
63
    }
 
64
 
 
65
    soundMP3c = newSWFSound(f2, SWF_SOUND_MP3_COMPRESSED |
 
66
            SWF_SOUND_44KHZ |
 
67
            SWF_SOUND_16BITS |
 
68
            SWF_SOUND_MONO);
 
69
    
 
70
    soundMP3d = newSWFSound(f2, SWF_SOUND_MP3_COMPRESSED |
 
71
            SWF_SOUND_5KHZ |
 
72
            SWF_SOUND_16BITS |
 
73
            SWF_SOUND_STEREO);
 
74
 
 
75
    SWFMovie_addExport(mo, (SWFSound)soundMP3a, "mono22_mp2");
 
76
    SWFMovie_addExport(mo, (SWFSound)soundMP3b, "mono22_mp2b");
 
77
    SWFMovie_addExport(mo, (SWFSound)soundMP3c, "stereo8_mp3");
 
78
    SWFMovie_addExport(mo, (SWFSound)soundMP3d, "stereo8_mp3b");
 
79
 
 
80
    SWFMovie_writeExports(mo);
 
81
}
 
82
 
 
83
int
 
84
main(int argc, char** argv)
 
85
{
 
86
        SWFMovie mo;
 
87
        const char *srcdir=".";
 
88
        SWFMovieClip  dejagnuclip;
 
89
 
 
90
 
 
91
        /*********************************************
 
92
         *
 
93
         * Initialization
 
94
         *
 
95
         *********************************************/
 
96
 
 
97
        if ( argc>1 ) srcdir=argv[1];
 
98
        else
 
99
        {
 
100
                fprintf(stderr, "Usage: %s\n", argv[0]);
 
101
                return 1;
 
102
        }
 
103
 
 
104
        puts("Setting things up");
 
105
 
 
106
        Ming_init();
 
107
  Ming_useSWFVersion (OUTPUT_VERSION);
 
108
        Ming_setScale(20.0); /* let's talk pixels */
 
109
 
 
110
        mo = newSWFMovie();
 
111
        SWFMovie_setRate(mo, 1.33);
 
112
        SWFMovie_setDimension(mo, 640, 400);
 
113
 
 
114
        /*********************************************
 
115
         *
 
116
         * Body
 
117
         *
 
118
         *********************************************/
 
119
 
 
120
        dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 80, 800, 600);
 
121
        SWFMovie_add(mo, (SWFBlock)dejagnuclip);
 
122
        addSoundExport(mo);
 
123
 
 
124
        SWFMovie_nextFrame(mo);  /* end of frame1 */
 
125
 
 
126
    // Tracker variables for calls to onSoundComplete
 
127
    add_actions(mo, "c_soundComplete = 0;");
 
128
    add_actions(mo, "d_soundComplete = 0;");
 
129
    add_actions(mo, "e_soundComplete = 0;");
 
130
 
 
131
    add_actions(mo, "a = new Sound(); a.attachSound('mono22_mp2');");
 
132
    add_actions(mo, "b = new Sound(); b.attachSound('mono22_mp2b');");
 
133
    add_actions(mo, "c = new Sound(); c.attachSound('stereo8_mp3');");
 
134
 
 
135
    // Two different Sounds with the same exported sound.
 
136
    add_actions(mo, "d = new Sound(); d.attachSound('stereo8_mp3b');");
 
137
    add_actions(mo, "e = new Sound(); e.attachSound('stereo8_mp3b');");
 
138
 
 
139
    check_equals(mo, "a.duration", "13740");
 
140
    add_actions(mo, "check_equals(a.getBytesTotal(), undefined);");
 
141
    add_actions(mo, "check_equals(a.getBytesLoaded(), undefined);");
 
142
    add_actions(mo, "check_equals(a.id3, undefined);");
 
143
    check_equals(mo, "a.position", "0");
 
144
    add_actions(mo, "a.start();");
 
145
    // This isn't very consistent either. Please re-enable when it is.
 
146
    //check_equals(mo, "a.position", "0");
 
147
 
 
148
    check_equals(mo, "b.duration", "13740");
 
149
    check_equals(mo, "b.position", "0");
 
150
    add_actions(mo, "b.start();");
 
151
 
 
152
    // Here, gst gives 46, ffmpeg 0.
 
153
    //check_equals(mo, "b.position", "0");
 
154
 
 
155
    check_equals(mo, "c.duration", "5224");
 
156
    check_equals(mo, "c.position", "0");
 
157
    // Play twice (loop).
 
158
    add_actions(mo, "c.start(0, 2);");
 
159
    check_equals(mo, "c.position", "0");
 
160
 
 
161
    check_equals(mo, "d.duration", "5224");
 
162
    check_equals(mo, "d.position", "0");
 
163
    // Start twice.
 
164
    add_actions(mo, "d.start();");
 
165
    add_actions(mo, "d.start(4);");
 
166
    check_equals(mo, "d.position", "0");
 
167
 
 
168
    add_actions(mo, "e.start();");
 
169
 
 
170
    SWFMovie_nextFrame(mo);
 
171
 
 
172
    add_actions(mo, "stop();"
 
173
            "note('will wait for onSoundComplete to finish the test (about "
 
174
            "13 seconds).');");
 
175
 
 
176
    // This is the longest sound, so the test should end when this is called.
 
177
    add_actions(mo, "a.onSoundComplete = function() {"
 
178
            "check_equals(a.position, 13740);"
 
179
            "check_equals(c_soundComplete, 1);"
 
180
            "check_equals(d_soundComplete, 1);"
 
181
            "check_equals(e_soundComplete, 2);"
 
182
            "totals(24); "
 
183
            "finished = true;"
 
184
            "};");
 
185
 
 
186
    // Check position of b, c, d, and e after the first loop of c.
 
187
    add_actions(mo, "c.onSoundComplete = function() {"
 
188
            // I'm not sure how reliable this is:
 
189
            "check_equals(b.position, 10472);"
 
190
            "check_equals(c.position, 5224);"
 
191
            "check_equals(d.position, 5224);"
 
192
            "check_equals(e.position, 5224);"
 
193
            "c_soundComplete++;"
 
194
            "note('c.onSoundComplete() called '+c_soundComplete+' time(s).');"
 
195
            "};");
 
196
 
 
197
    add_actions(mo, "d.onSoundComplete = function() {"
 
198
            "check_equals(d.position, 5224);"
 
199
            "d_soundComplete++;"
 
200
            "note('d.onSoundComplete() called '+d_soundComplete+' time(s).');"
 
201
            "};");
 
202
 
 
203
    // This starts e again. It should run twice before the longest
 
204
    // sound stops.
 
205
    add_actions(mo, "e.onSoundComplete = function() {"
 
206
            "check_equals(e.position, 5224);"
 
207
            "e_soundComplete++;"
 
208
            "note('e.onSoundComplete() called '+e_soundComplete+' time(s).');"
 
209
            "e.start();"
 
210
            "};");
 
211
 
 
212
 
 
213
        /*****************************************************
 
214
         *
 
215
         * Output movie
 
216
         *
 
217
         *****************************************************/
 
218
 
 
219
        puts("Saving " OUTPUT_FILENAME );
 
220
 
 
221
        SWFMovie_save(mo, OUTPUT_FILENAME);
 
222
 
 
223
        return 0;
 
224
}