Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
clone2727 committed Jun 22, 2012
1 parent 0a2a0b3 commit 781e50a
Show file tree
Hide file tree
Showing 30 changed files with 5,746 additions and 4 deletions.
26 changes: 26 additions & 0 deletions AUTHORS
@@ -0,0 +1,26 @@
smushplay - A simple LucasArts SMUSH video player
Copyright (c) 2012 by the following:

Matthew Hoops (clone2727) <clone2727@gmail.com>

smushplay is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Thanks To:
==========

ScummVM team
ResidualVM team

Since they provided the initial implementation of both SMUSH versions :)
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions README
@@ -0,0 +1,39 @@
smushplay 0.0.1
===============

What is it?
***********
A standalone LucasArts SMUSH movie player.

How do I build it?
******************
1) Have SDL installed on your system
2) Type 'make'
3) If that doesn't work, submit a pull request that fixes it

How do I use it?
****************
From the command line! Just run "./smushplay <video name>" and a window should appear with the video.

What videos are supported?
**************************
Since there are many games out there using SMUSH, not all variants are supported right now. Here are games and their statuses:

* Rebel Assault
Rebel Assault videos use the oldest version of SMUSH. Only a few of these videos play. No sound.
* Rebel Assault II
Most Rebel Assault II videos play properly, but there are some glitches. No sound.
* Mortimer
Some Mortimer videos work, but they are using a scaling feature that is not supported yet. No sound.
* Full Throttle/The Dig
The videos should play properly. No sound.
* The Curse of Monkey Island/Shadows of the Empire/Grim Fandango *demo*/Outlaws
The videos should play properly. Sound works.
* Mysteries of the Sith
The videos do not show anything. Sound works.
* X-Wing Alliance/Episode I Racer/Grim Fandango *full*
The videos should play properly. Sound works.
* Other games
Untested! Please test and report!

Also note that playing "NUT" files may or may not work. They weren't meant to be played as videos. Also note that text is not displayed in videos at this time, but hopefully will in the future.
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

121 changes: 121 additions & 0 deletions audioman.cpp
@@ -0,0 +1,121 @@
/* smushplay - A simple LucasArts SMUSH video player
*
* smushplay is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#include <assert.h>
#include "audioman.h"
#include "audiostream.h"
#include "rate.h"

AudioManager::AudioManager() {
_mutex = SDL_CreateMutex();
}

AudioManager::~AudioManager() {
stopAll();
SDL_CloseAudio();
SDL_DestroyMutex(_mutex);
}

bool AudioManager::init() {
SDL_AudioSpec spec;
spec.freq = 44100;
spec.format = AUDIO_S16SYS;
spec.channels = 2;
spec.samples = 4096;
spec.callback = sdlCallback;
spec.userdata = this;

if (SDL_OpenAudio(&spec, &_spec) != 0)
return false;

if (_spec.channels != 2 || _spec.format != AUDIO_S16SYS)
return false;

SDL_PauseAudio(0);
return true;
}

void AudioManager::play(uint channel, AudioStream *stream) {
stop(channel);

Channel *chan = new Channel();
chan->stream = stream;
chan->converter = makeRateConverter(stream->getRate(), _spec.freq, stream->getChannels() == 2);

SDL_mutexP(_mutex);
_channels[channel] = chan;
SDL_mutexV(_mutex);
}

void AudioManager::stop(uint channel) {
SDL_mutexP(_mutex);

ChannelMap::iterator it = _channels.find(channel);

if (it != _channels.end()) {
Channel *chan = it->second;
delete chan->stream;
delete chan->converter;
delete chan;
_channels.erase(it);
}

SDL_mutexV(_mutex);
}

void AudioManager::stopAll() {
SDL_mutexP(_mutex);

for (ChannelMap::iterator it = _channels.begin(); it != _channels.end(); it++) {
Channel *channel = it->second;
delete channel->stream;
delete channel->converter;
delete channel;
}

_channels.clear();

SDL_mutexV(_mutex);
}

void AudioManager::sdlCallback(void *manager, byte *samples, int len) {
((AudioManager *)manager)->callbackHandler(samples, len);
}

void AudioManager::callbackHandler(byte *samples, int len) {
assert((len % 4) == 0);
memset(samples, 0, len);

SDL_mutexP(_mutex);

for (ChannelMap::iterator it = _channels.begin(); it != _channels.end(); it++) {
Channel *channel = it->second;

if (channel->stream->endOfData()) {
// TODO: Remove the channel?
} else {
channel->converter->flow(*channel->stream, (int16 *)samples, len >> 2, 255, 255);
}
}

SDL_mutexV(_mutex);
}
63 changes: 63 additions & 0 deletions audioman.h
@@ -0,0 +1,63 @@
/* smushplay - A simple LucasArts SMUSH video player
*
* smushplay is the legal property of its developers, whose names can be
* found in the AUTHORS file distributed with this source
* distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef AUDIOMAN_H
#define AUDIOMAN_H

#include <SDL.h>
#include <SDL_thread.h>
#include <map>
#include "types.h"

class AudioStream;
class RateConverter;

// TODO: Expand with a handle system similar to ScummVM's
// Maybe eventually just replace with ScummVM's

class AudioManager {
public:
AudioManager();
~AudioManager();

bool init();
void play(uint channel, AudioStream *stream);
void stop(uint channel);
void stopAll();

private:
void callbackHandler(byte *samples, int len);
static void sdlCallback(void *manager, byte *samples, int len);

SDL_AudioSpec _spec;
SDL_mutex *_mutex;

struct Channel {
AudioStream *stream;
RateConverter *converter;
};

typedef std::map<uint, Channel*> ChannelMap;
ChannelMap _channels;
};

#endif

0 comments on commit 781e50a

Please sign in to comment.