update copyright date
[gnash.git] / libcore / swf / SoundInfoRecord.cpp
blobcfcd7a50af3c94cdf1e436ec7f096fddf674fdeb
1 // SoundInfo.cpp: parse and store a SoundInfo record.
2 //
3 // Copyright (C) 2006, 2007, 2008, 2009, 2010,
4 // 2011 Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SoundInfoRecord.h"
23 #include "sound_handler.h" // sound::SoundEnvelopes
24 #include "SWFStream.h"
25 #include "log.h"
27 namespace gnash {
28 namespace SWF {
31 void
32 SoundInfoRecord::read(SWFStream& in)
34 in.ensureBytes(1);
36 // highest 2 bits are reserved(unused).
37 int flags = in.read_u8();
38 stopPlayback = flags & (1 << 5);
39 noMultiple = flags & (1 << 4);
40 hasEnvelope = flags & (1 << 3);
41 hasLoops = flags & (1 << 2);
42 hasOutPoint = flags & (1 << 1);
43 hasInPoint = flags & (1 << 0);
45 in.ensureBytes(hasInPoint * 4 + hasOutPoint * 4 + hasLoops * 2);
47 if (hasInPoint) {
48 inPoint = in.read_u32();
51 if (hasOutPoint) {
52 outPoint = in.read_u32();
55 if (hasLoops) {
56 loopCount = in.read_u16();
59 if (hasEnvelope) {
60 in.ensureBytes(1);
61 int nPoints = in.read_u8();
62 envelopes.resize(nPoints);
63 in.ensureBytes(8 * nPoints);
64 for (int i=0; i < nPoints; i++)
66 envelopes[i].m_mark44 = in.read_u32();
67 envelopes[i].m_level0 = in.read_u16();
68 envelopes[i].m_level1 = in.read_u16();
71 else {
72 envelopes.clear();
75 IF_VERBOSE_PARSE(
76 log_parse(" hasEnvelope = %d", hasEnvelope);
77 log_parse(" hasLoops = %d", hasLoops);
78 log_parse(" hasOutPoint = %d", hasOutPoint);
79 log_parse(" hasInPoint = %d", hasInPoint);
80 log_parse(" inPoint = %d", inPoint);
81 log_parse(" outPoint = %d", outPoint);
82 log_parse(" loopCount = %d", loopCount);
83 log_parse(" envelope size = %d", envelopes.size());