~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to engines/kyra/vqa.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff
  • Date: 2010-05-07 18:57:09 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100507185709-34v8yycywjrou5o3
Tags: upstream-1.1.1
ImportĀ upstreamĀ versionĀ 1.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-0-0/engines/kyra/vqa.cpp $
22
 
 * $Id: vqa.cpp 41879 2009-06-25 19:55:25Z lordhoto $
 
21
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-1-1/engines/kyra/vqa.cpp $
 
22
 * $Id: vqa.cpp 47579 2010-01-26 22:48:45Z fingolfin $
23
23
 *
24
24
 */
25
25
 
37
37
#include "common/system.h"
38
38
#include "sound/audiostream.h"
39
39
#include "sound/mixer.h"
 
40
#include "sound/decoders/raw.h"
40
41
 
41
42
#include "kyra/sound.h"
42
43
#include "kyra/screen.h"
50
51
        _screen = _vm->screen();
51
52
        _opened = false;
52
53
        _x = _y = _drawPage = -1;
 
54
        _frame = 0;
 
55
        _vectorPointers = 0;
 
56
        _numPartialCodeBooks = 0;
 
57
        _partialCodeBookSize = 0;
 
58
        _compressedCodeBook = 0;
 
59
        _partialCodeBook = 0;
 
60
        _codeBook = 0;
 
61
        _frameInfo = 0;
 
62
        memset(_buffers, 0, sizeof(_buffers));
53
63
}
54
64
 
55
65
VQAMovie::~VQAMovie() {
283
293
                                assert(_header.bits == 8);
284
294
                                assert(_header.channels == 1);
285
295
 
286
 
                                _stream = Audio::makeAppendableAudioStream(_header.freq, Audio::Mixer::FLAG_UNSIGNED);
 
296
                                _stream = Audio::makeQueuingAudioStream(_header.freq, false);
287
297
                        } else {
288
298
                                _stream = NULL;
289
299
                        }
410
420
                switch (tag) {
411
421
                case MKID_BE('SND0'):   // Uncompressed sound
412
422
                        foundSound = true;
413
 
                        inbuf = new byte[size];
 
423
                        inbuf = (byte *)malloc(size);
414
424
                        _file->read(inbuf, size);
415
425
                        assert(_stream);
416
 
                        _stream->queueBuffer(inbuf, size);
 
426
                        _stream->queueBuffer(inbuf, size, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
417
427
                        break;
418
428
 
419
429
                case MKID_BE('SND1'):   // Compressed sound, almost like AUD
421
431
                        outsize = _file->readUint16LE();
422
432
                        insize = _file->readUint16LE();
423
433
 
424
 
                        inbuf = new byte[insize];
 
434
                        inbuf = (byte *)malloc(insize);
425
435
                        _file->read(inbuf, insize);
426
436
 
427
437
                        if (insize == outsize) {
428
438
                                assert(_stream);
429
 
                                _stream->queueBuffer(inbuf, insize);
 
439
                                _stream->queueBuffer(inbuf, insize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
430
440
                        } else {
431
 
                                outbuf = new byte[outsize];
 
441
                                outbuf = (byte *)malloc(outsize);
432
442
                                decodeSND1(inbuf, insize, outbuf, outsize);
433
443
                                assert(_stream);
434
 
                                _stream->queueBuffer(outbuf, outsize);
435
 
                                delete[] inbuf;
 
444
                                _stream->queueBuffer(outbuf, outsize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
 
445
                                free(inbuf);
436
446
                        }
437
447
                        break;
438
448
 
601
611
 
602
612
                        switch (tag) {
603
613
                        case MKID_BE('SND0'):   // Uncompressed sound
604
 
                                inbuf = new byte[size];
 
614
                                inbuf = (byte *)malloc(size);
605
615
                                _file->read(inbuf, size);
606
 
                                _stream->queueBuffer(inbuf, size);
 
616
                                _stream->queueBuffer(inbuf, size, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
607
617
                                break;
608
618
 
609
619
                        case MKID_BE('SND1'):   // Compressed sound
610
620
                                outsize = _file->readUint16LE();
611
621
                                insize = _file->readUint16LE();
612
622
 
613
 
                                inbuf = new byte[insize];
 
623
                                inbuf = (byte *)malloc(insize);
614
624
                                _file->read(inbuf, insize);
615
625
 
616
626
                                if (insize == outsize) {
617
 
                                        _stream->queueBuffer(inbuf, insize);
 
627
                                        _stream->queueBuffer(inbuf, insize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
618
628
                                } else {
619
 
                                        outbuf = new byte[outsize];
 
629
                                        outbuf = (byte *)malloc(outsize);
620
630
                                        decodeSND1(inbuf, insize, outbuf, outsize);
621
 
                                        _stream->queueBuffer(outbuf, outsize);
622
 
                                        delete[] inbuf;
 
631
                                        _stream->queueBuffer(outbuf, outsize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
 
632
                                        free(inbuf);
623
633
                                }
624
634
                                break;
625
635
 
684
694
        // TODO: Wait for the sound to finish?
685
695
}
686
696
 
687
 
} // end of namespace Kyra
 
697
} // End of namespace Kyra