SCI: Reimplemented the SCI mixer based on the old SCI DC mixer by walter, and by taking advantage of ScummVM's mixers capabilities. Got rid of sfx_pcm_mixer_t
svn-id: r39053
This commit is contained in:
parent
a718713925
commit
00db87563a
5 changed files with 189 additions and 1243 deletions
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/timer.h"
|
#include "common/timer.h"
|
||||||
|
#include "sound/mixer.h"
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
|
@ -43,11 +44,10 @@ int sciprintf(char *msg, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static sfx_player_t *player = NULL;
|
static sfx_player_t *player = NULL;
|
||||||
sfx_pcm_mixer_t *mixer = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
int sfx_pcm_available() {
|
int sfx_pcm_available() {
|
||||||
return (mixer != NULL);
|
return g_system->getMixer()->isReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_reset_player() {
|
void sfx_reset_player() {
|
||||||
|
@ -340,11 +340,11 @@ int sfx_play_iterator_pcm(song_iterator_t *it, song_handle_t handle) {
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle);
|
fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle);
|
||||||
#endif
|
#endif
|
||||||
if (mixer) {
|
if (g_system->getMixer()->isReady()) {
|
||||||
sfx_pcm_feed_t *newfeed = it->get_pcm_feed(it);
|
sfx_pcm_feed_t *newfeed = it->get_pcm_feed(it);
|
||||||
if (newfeed) {
|
if (newfeed) {
|
||||||
newfeed->debug_nr = (int) handle;
|
newfeed->debug_nr = (int) handle;
|
||||||
mixer->subscribe(mixer, newfeed);
|
mixer_subscribe(newfeed);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,8 +362,7 @@ static void _sfx_timer_callback(void *data) {
|
||||||
if (player)
|
if (player)
|
||||||
player->maintenance();
|
player->maintenance();
|
||||||
|
|
||||||
if (mixer)
|
mixer_process();
|
||||||
mixer->process(mixer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
||||||
|
@ -373,13 +372,11 @@ void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
||||||
self->debug = 0; /* Disable all debugging by default */
|
self->debug = 0; /* Disable all debugging by default */
|
||||||
|
|
||||||
if (flags & SFX_STATE_FLAG_NOSOUND) {
|
if (flags & SFX_STATE_FLAG_NOSOUND) {
|
||||||
mixer = NULL;
|
|
||||||
player = NULL;
|
player = NULL;
|
||||||
sciprintf("[SFX] Sound disabled.\n");
|
sciprintf("[SFX] Sound disabled.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mixer = getMixer();
|
|
||||||
player = sfx_find_player(NULL);
|
player = sfx_find_player(NULL);
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,15 +384,6 @@ void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
||||||
fprintf(stderr, "[sfx-core] Initialising: flags=%x\n", flags);
|
fprintf(stderr, "[sfx-core] Initialising: flags=%x\n", flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*------------------*/
|
|
||||||
/* Initialise mixer */
|
|
||||||
/*------------------*/
|
|
||||||
|
|
||||||
if (mixer->init(mixer)) {
|
|
||||||
sciprintf("[SFX] Failed to initialise PCM mixer; disabling PCM support\n");
|
|
||||||
mixer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------*/
|
/*-------------------*/
|
||||||
/* Initialise player */
|
/* Initialise player */
|
||||||
/*-------------------*/
|
/*-------------------*/
|
||||||
|
@ -421,12 +409,11 @@ void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
||||||
// timer callback being triggered while the mixer or player are
|
// timer callback being triggered while the mixer or player are
|
||||||
// still being initialized.
|
// still being initialized.
|
||||||
|
|
||||||
if (mixer || (player && player->maintenance)) {
|
if (g_system->getMixer()->isReady() || (player && player->maintenance)) {
|
||||||
if (!g_system->getTimerManager()->installTimerProc(&_sfx_timer_callback, DELAY, NULL)) {
|
if (!g_system->getTimerManager()->installTimerProc(&_sfx_timer_callback, DELAY, NULL)) {
|
||||||
warning("[SFX] " __FILE__": Timer failed to initialize");
|
warning("[SFX] " __FILE__": Timer failed to initialize");
|
||||||
warning("[SFX] Disabled sound support");
|
warning("[SFX] Disabled sound support");
|
||||||
player = NULL;
|
player = NULL;
|
||||||
mixer = NULL;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} /* With no PCM device and no player, we don't need a timer */
|
} /* With no PCM device and no player, we don't need a timer */
|
||||||
|
@ -446,16 +433,12 @@ void sfx_exit(sfx_state_t *self) {
|
||||||
|
|
||||||
song_lib_free(self->songlib);
|
song_lib_free(self->songlib);
|
||||||
|
|
||||||
/* WARNING: The mixer may hold feeds from the
|
// WARNING: The mixer may hold feeds from the player, so we must
|
||||||
** player, so we must stop the mixer BEFORE
|
// stop the mixer BEFORE stopping the player.
|
||||||
** stopping the player. */
|
g_system->getMixer()->stopAll();
|
||||||
if (mixer) {
|
|
||||||
mixer->exit(mixer);
|
|
||||||
mixer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
/* See above: This must happen AFTER stopping the mixer */
|
// See above: This must happen AFTER stopping the mixer
|
||||||
player->exit();
|
player->exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -30,53 +30,21 @@
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
struct sfx_pcm_mixer_t {
|
/**
|
||||||
/* Mixers are the heart of all matters PCM. They take PCM data from subscribed feeds,
|
* Subscribes the mixer to a new feed.
|
||||||
** mix it (hence the name) and ask the pcm device they are attached to to play the
|
* @param feed The feed to subscribe to
|
||||||
** result. */
|
*/
|
||||||
|
void mixer_subscribe(sfx_pcm_feed_t *feed);
|
||||||
|
|
||||||
const char *name;
|
/**
|
||||||
const char *version;
|
* Processes all feeds, mixes their results, and passes everything to the output device.
|
||||||
|
* Returns : (int) SFX_OK on success, SFX_ERROR otherwise (output device error or
|
||||||
int (*init)(sfx_pcm_mixer_t *self);
|
* internal assertion failure)
|
||||||
/* Initialises the mixer
|
* Effects : All feeds are poll()ed, and the device is asked to output(). Buffer size
|
||||||
** Parameters: (sfx_pcm_mixer_t *) self: Self reference
|
* depends on the time that has passed since the last call to process(), if
|
||||||
** Returns : (int) SFX_OK on success, SFX_ERROR otherwise
|
* any.
|
||||||
*/
|
*/
|
||||||
|
int mixer_process();
|
||||||
void (*exit)(sfx_pcm_mixer_t *self);
|
|
||||||
/* Uninitialises the mixer
|
|
||||||
** Parameters: (sfx_pcm_mixer_t *) self: Self reference
|
|
||||||
** Also uninitialises all feeds and the attached output device.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void (*subscribe)(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed);
|
|
||||||
/* Subscribes the mixer to a new feed
|
|
||||||
** Parameters: (sfx_pcm_mixer_t *) self: Self reference
|
|
||||||
** (sfx_pcm_feed_t *) feed: The feed to subscribe to
|
|
||||||
*/
|
|
||||||
|
|
||||||
int (*process)(sfx_pcm_mixer_t *self);
|
|
||||||
/* Processes all feeds, mixes their results, and passes everything to the output device
|
|
||||||
** Returns : (int) SFX_OK on success, SFX_ERROR otherwise (output device error or
|
|
||||||
** internal assertion failure)
|
|
||||||
** Effects : All feeds are poll()ed, and the device is asked to output(). Buffer size
|
|
||||||
** depends on the time that has passed since the last call to process(), if
|
|
||||||
** any.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void *private_bits;
|
|
||||||
};
|
|
||||||
|
|
||||||
sfx_pcm_mixer_t *sfx_pcm_find_mixer(char *name);
|
|
||||||
/* Looks up a mixer by name, or a default mixer
|
|
||||||
** Parameters: (char *) name: Name of the mixer to look for, or NULL to
|
|
||||||
** take a default
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern sfx_pcm_mixer_t *mixer; /* _THE_ global pcm mixer */
|
|
||||||
|
|
||||||
sfx_pcm_mixer_t *getMixer();
|
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
||||||
|
|
|
@ -1,347 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* 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 2
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Mixer inspection/test program */
|
|
||||||
|
|
||||||
|
|
||||||
#include "../mixer.h"
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
namespace Sci {
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
sfx_pcm_mixer_t *mix;
|
|
||||||
|
|
||||||
int dev_init(sfx_pcm_device_t *self);
|
|
||||||
void dev_exit(sfx_pcm_device_t *self);
|
|
||||||
int dev_option(sfx_pcm_device_t *self, char *name, char *value);
|
|
||||||
int dev_output(sfx_pcm_device_t *self, byte *buf, int count);
|
|
||||||
|
|
||||||
#define MIN_OUTPUT 128
|
|
||||||
/* Min amount of output to compute */
|
|
||||||
|
|
||||||
#define DEVICES_NR 10
|
|
||||||
|
|
||||||
sfx_pcm_device_t devices[DEVICES_NR] = {
|
|
||||||
{ "test-1", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_U8 }, 1024, NULL },
|
|
||||||
#if (DEVICES_NR > 1)
|
|
||||||
{ "test-2", "0", dev_init, dev_exit, dev_option, dev_output, { 200, SFX_PCM_STEREO_LR, SFX_PCM_FORMAT_U8 }, 1024, NULL
|
|
||||||
},
|
|
||||||
{ "test-3", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_STEREO_RL, SFX_PCM_FORMAT_U8 }, 1024, NULL },
|
|
||||||
{ "test-4", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_S8 }, 1024, NULL },
|
|
||||||
{ "test-5", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_U16_LE }, 1024, NULL },
|
|
||||||
{ "test-6", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_U16_BE }, 1024, NULL },
|
|
||||||
{ "test-7", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_S16_LE }, 1024, NULL },
|
|
||||||
{ "test-8", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_S16_BE }, 1024, NULL },
|
|
||||||
{ "test-9", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_STEREO_RL, SFX_PCM_FORMAT_S16_LE }, 1024, NULL },
|
|
||||||
{ "test-10", "0", dev_init, dev_exit, dev_option, dev_output,
|
|
||||||
{ 200, SFX_PCM_STEREO_LR, SFX_PCM_FORMAT_U16_BE }, 1024, NULL }
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
int output_count;
|
|
||||||
|
|
||||||
int dev_init(sfx_pcm_device_t *self) {
|
|
||||||
output_count = 0;
|
|
||||||
|
|
||||||
fprintf(stderr, "[DEV] Initialised device %p as follows:\n"
|
|
||||||
"\trate = %d\n"
|
|
||||||
"\tstereo = %s\n"
|
|
||||||
"\tbias = %x\n"
|
|
||||||
"\tbytes/sample = %d\n"
|
|
||||||
"\tendianness = %s\n",
|
|
||||||
self,
|
|
||||||
self->conf.rate,
|
|
||||||
self->conf.stereo ? ((self->conf.stereo == SFX_PCM_STEREO_LR) ? "Left, Right" : "Right, Left") : "No",
|
|
||||||
self->conf.format & ~SFX_PCM_FORMAT_LMASK,
|
|
||||||
(self->conf.format & SFX_PCM_FORMAT_16) ? 2 : 1,
|
|
||||||
((self->conf.format & SFX_PCM_FORMAT_ENDIANNESS) == SFX_PCM_FORMAT_BE) ? "big" : "little");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dev_exit(sfx_pcm_device_t *self) {
|
|
||||||
fprintf(stderr, "[DEV] Uninitialising device\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int dev_option(sfx_pcm_device_t *self, char *name, char *value) {
|
|
||||||
fprintf(stderr, "[DEV] Set option '%s' to '%s'\n", name, value);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dev_output_enabled = 0;
|
|
||||||
|
|
||||||
int dev_output(sfx_pcm_device_t *self, byte *buf, int count) {
|
|
||||||
int mono_sample_size = ((self->conf.format & SFX_PCM_FORMAT_16) ? 2 : 1);
|
|
||||||
int sample_size = (self->conf.stereo ? 2 : 1) * mono_sample_size;
|
|
||||||
int bias = self->conf.format & ~SFX_PCM_FORMAT_LMASK;
|
|
||||||
int is_bigendian = (self->conf.format & SFX_PCM_FORMAT_ENDIANNESS) == SFX_PCM_FORMAT_BE;
|
|
||||||
byte *left_channel = buf;
|
|
||||||
byte *right_channel = buf;
|
|
||||||
|
|
||||||
if (!dev_output_enabled)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (self->conf.format & SFX_PCM_FORMAT_16)
|
|
||||||
bias <<= 8;
|
|
||||||
|
|
||||||
if (self->conf.stereo == SFX_PCM_STEREO_LR)
|
|
||||||
right_channel += mono_sample_size;
|
|
||||||
if (self->conf.stereo == SFX_PCM_STEREO_RL)
|
|
||||||
left_channel += mono_sample_size;
|
|
||||||
|
|
||||||
while (count--) {
|
|
||||||
int right = right_channel[0];
|
|
||||||
int left = left_channel[0];
|
|
||||||
int second_byte = ((self->conf.format & SFX_PCM_FORMAT_16) ? 1 : 0);
|
|
||||||
|
|
||||||
if (second_byte) {
|
|
||||||
|
|
||||||
if (is_bigendian) {
|
|
||||||
left = left << 8 | left_channel[1];
|
|
||||||
right = right << 8 | right_channel[1];
|
|
||||||
} else {
|
|
||||||
left = left | left_channel[1] << 8;
|
|
||||||
right = right | right_channel[1] << 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left -= bias;
|
|
||||||
right -= bias;
|
|
||||||
|
|
||||||
if (!second_byte) {
|
|
||||||
left <<= 8;
|
|
||||||
right <<= 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "[DEV] %p play %04x:\t%04x %04x\n", self, output_count++, left & 0xffff, right & 0xffff);
|
|
||||||
|
|
||||||
left_channel += sample_size;
|
|
||||||
right_channel += sample_size;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Feeds for debugging */
|
|
||||||
|
|
||||||
struct int_struct {
|
|
||||||
int i;
|
|
||||||
};
|
|
||||||
|
|
||||||
int feed_poll(sfx_pcm_feed_t *self, byte *dest, int size);
|
|
||||||
void feed_destroy(sfx_pcm_feed_t *self);
|
|
||||||
|
|
||||||
int_struct private_bits[10] = {
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0},
|
|
||||||
{0}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct sample_feed_t {
|
|
||||||
int start;
|
|
||||||
int samples_nr;
|
|
||||||
byte *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define FEEDS_NR 4
|
|
||||||
|
|
||||||
sfx_pcm_feed_t feeds[FEEDS_NR] = {
|
|
||||||
{ feed_poll, feed_destroy, &(private_bits[0]),
|
|
||||||
{ 200, SFX_PCM_MONO, SFX_PCM_FORMAT_S8 }, "test-feed", 0, 0}
|
|
||||||
#if FEEDS_NR > 1
|
|
||||||
, { feed_poll, feed_destroy, &(private_bits[1]),
|
|
||||||
{ 400, SFX_PCM_MONO, SFX_PCM_FORMAT_U8 }, "test-feed", 1, 0}
|
|
||||||
#endif
|
|
||||||
#if FEEDS_NR > 2
|
|
||||||
, { feed_poll, feed_destroy, &(private_bits[2]),
|
|
||||||
{ 20, SFX_PCM_MONO, SFX_PCM_FORMAT_S16_LE }, "test-feed", 2, 0}
|
|
||||||
#endif
|
|
||||||
#if FEEDS_NR > 3
|
|
||||||
, { feed_poll, feed_destroy, &(private_bits[3]),
|
|
||||||
{ 150, SFX_PCM_STEREO_LR, SFX_PCM_FORMAT_S8 }, "test-feed", 3, 0}
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
,{ feed_poll, feed_destroy, &(private_bits[4]),
|
|
||||||
{}, "test-feed", 4, 0}
|
|
||||||
,{ feed_poll, feed_destroy, &(private_bits[5]),
|
|
||||||
{}, "test-feed", 5, 0}
|
|
||||||
*/
|
|
||||||
};
|
|
||||||
|
|
||||||
byte feed_data_0[] = {0xfd, 0xfe, 0xff, 0, 1, 2, 3, 4, 5, 6};
|
|
||||||
byte feed_data_1[] = {0x80, 0x90, 0xA0, 0xB0, 0xC0,
|
|
||||||
0xD0, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80
|
|
||||||
};
|
|
||||||
byte feed_data_2[] = {0x00, 0x00,
|
|
||||||
0x00, 0x80,
|
|
||||||
0xe8, 0x03
|
|
||||||
};
|
|
||||||
byte feed_data_3[] = {0x00, 0x10,
|
|
||||||
0x01, 0x20,
|
|
||||||
0x02, 0x30
|
|
||||||
};
|
|
||||||
|
|
||||||
sample_feed_t sample_feeds[FEEDS_NR] = {
|
|
||||||
{ 1, 10, feed_data_0 }
|
|
||||||
#if FEEDS_NR > 1
|
|
||||||
, { 21, 12, feed_data_1 }
|
|
||||||
#endif
|
|
||||||
#if FEEDS_NR > 2
|
|
||||||
, { 0, 3, feed_data_2 }
|
|
||||||
#endif
|
|
||||||
#if FEEDS_NR > 3
|
|
||||||
, { 40, 3, feed_data_3 }
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
void feed_destroy(sfx_pcm_feed_t *self) {
|
|
||||||
int_struct *s = (int_struct *) self->internal;
|
|
||||||
s->i = 0; /* reset */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int feed_poll(sfx_pcm_feed_t *self, byte *dest, int size) {
|
|
||||||
int_struct *s = (int_struct *) self->internal;
|
|
||||||
int sample_size = self->sample_size;
|
|
||||||
sample_feed_t *data = &(sample_feeds[self->debug_nr]);
|
|
||||||
int bias = self->conf.format & ~SFX_PCM_FORMAT_LMASK;
|
|
||||||
byte neutral[4] = {0, 0, 0, 0};
|
|
||||||
int i;
|
|
||||||
fprintf(stderr, "[feed] Asked for %d at %p, ss=%d\n", size, dest, sample_size);
|
|
||||||
if (bias) {
|
|
||||||
byte first = bias >> 8;
|
|
||||||
byte second = bias & 0xff;
|
|
||||||
|
|
||||||
if ((self->conf.format & SFX_PCM_FORMAT_ENDIANNESS) == SFX_PCM_FORMAT_LE) {
|
|
||||||
int t = first;
|
|
||||||
first = second;
|
|
||||||
second = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->conf.format & SFX_PCM_FORMAT_16) {
|
|
||||||
neutral[0] = first;
|
|
||||||
neutral[1] = second;
|
|
||||||
neutral[2] = first;
|
|
||||||
neutral[3] = second;
|
|
||||||
} else {
|
|
||||||
neutral[0] = bias;
|
|
||||||
neutral[1] = bias;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
|
||||||
int t = s->i - data->start;
|
|
||||||
|
|
||||||
if (t >= data->samples_nr)
|
|
||||||
return i;
|
|
||||||
|
|
||||||
if (t >= 0)
|
|
||||||
memcpy(dest, data->data + t * sample_size, sample_size);
|
|
||||||
else
|
|
||||||
memcpy(dest, neutral, sample_size);
|
|
||||||
|
|
||||||
dest += sample_size;
|
|
||||||
s->i++;
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern FILE *con_file;
|
|
||||||
|
|
||||||
#define DELAY usleep((rand() / (RAND_MAX / 250L)))
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
int dev_nr;
|
|
||||||
|
|
||||||
mix = sfx_pcm_find_mixer(NULL);
|
|
||||||
|
|
||||||
if (!mix) {
|
|
||||||
fprintf(stderr, "Error: Could not find a mixer!\n");
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Running %s, v%s\n",
|
|
||||||
mix->name, mix->version);
|
|
||||||
}
|
|
||||||
con_file = stderr;
|
|
||||||
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
for (dev_nr = 0; dev_nr < DEVICES_NR; dev_nr++) {
|
|
||||||
sfx_pcm_device_t *dev = &(devices[dev_nr++]);
|
|
||||||
int j;
|
|
||||||
dev->init(dev);
|
|
||||||
mix->init(mix, dev);
|
|
||||||
|
|
||||||
dev_output_enabled = 0;
|
|
||||||
/* Prime it to our timing */
|
|
||||||
for (j = 0; j < 250; j++) {
|
|
||||||
DELAY;
|
|
||||||
mix->process(mix);
|
|
||||||
}
|
|
||||||
dev_output_enabled = 1;
|
|
||||||
|
|
||||||
fprintf(stderr, "[test] Subscribing...\n");
|
|
||||||
|
|
||||||
for (j = 0; j < FEEDS_NR; j++)
|
|
||||||
mix->subscribe(mix, &(feeds[j]));
|
|
||||||
|
|
||||||
fprintf(stderr, "[test] Subscribed %d feeds.\n",
|
|
||||||
FEEDS_NR);
|
|
||||||
|
|
||||||
while (output_count < MIN_OUTPUT) {
|
|
||||||
DELAY;
|
|
||||||
mix->process(mix);
|
|
||||||
fprintf(stderr, "<tick>\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "[test] Preparing finalisation\n");
|
|
||||||
mix->exit(mix);
|
|
||||||
fprintf(stderr, "[test] Mixer uninitialised\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
int main() {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // End of namespace Sci
|
|
|
@ -161,9 +161,6 @@ static int pp_set_option(char *name, char *value) {
|
||||||
static int pp_init(ResourceManager *resmgr, int expected_latency) {
|
static int pp_init(ResourceManager *resmgr, int expected_latency) {
|
||||||
Resource *res = NULL, *res2 = NULL;
|
Resource *res = NULL, *res2 = NULL;
|
||||||
|
|
||||||
if (!mixer)
|
|
||||||
return SFX_ERROR;
|
|
||||||
|
|
||||||
/* FIXME Temporary hack to detect Amiga games. */
|
/* FIXME Temporary hack to detect Amiga games. */
|
||||||
if (!Common::File::exists("bank.001"))
|
if (!Common::File::exists("bank.001"))
|
||||||
seq = sfx_find_softseq(NULL);
|
seq = sfx_find_softseq(NULL);
|
||||||
|
@ -196,7 +193,7 @@ static int pp_init(ResourceManager *resmgr, int expected_latency) {
|
||||||
pcmfeed.conf = seq->pcm_conf;
|
pcmfeed.conf = seq->pcm_conf;
|
||||||
|
|
||||||
seq->set_volume(seq, volume);
|
seq->set_volume(seq, volume);
|
||||||
mixer->subscribe(mixer, &pcmfeed);
|
mixer_subscribe(&pcmfeed);
|
||||||
|
|
||||||
sfx_player_polled.polyphony = seq->polyphony;
|
sfx_player_polled.polyphony = seq->polyphony;
|
||||||
return SFX_OK;
|
return SFX_OK;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue