unsigned int evtime;
struct audio_channel_data2 data[AUDIO_CHANNEL_MAX_STREAM_CH];
SOUND_STREAM_CALLBACK cb;
+ void *cb_data;
};
struct audio_channel_data
}
}
-static void do_extra_channels(int i, int *data1, int *data2, int *data3, int *data4, int *data5, int *data6)
+static void do_extra_channels(int idx, int ch, int *data1, int *data2, int *data3, int *data4, int *data5, int *data6)
{
- int idx = AUDIO_CHANNELS_PAULA + i * AUDIO_CHANNEL_MAX_STREAM_CH;
- if (audio_extra_streams[i] == 2) {
+ idx += AUDIO_CHANNELS_PAULA;
+ if (ch == 2) {
int datas[2];
samplexx_anti_handler(datas, idx, 2);
get_extra_channels(data1, data2, datas[0], datas[1]);
- } else if (audio_extra_streams[i] == 1) {
+ } else if (ch == 1) {
int datas[1];
samplexx_anti_handler(datas, idx, 1);
int d1 = *data1 + datas[0];
*data1 = d1;
if (data2)
*data2 = d1;
- } else if (audio_extra_streams[i] > 2) {
+ } else if (ch > 2) {
int datas[AUDIO_CHANNEL_MAX_STREAM_CH];
samplexx_anti_handler(datas, idx, 6);
get_extra_channels(data1, data2, datas[0], datas[1]);
{
if (!audio_total_extra_streams)
return;
+ int idx = 0;
for (int i = 0; i < AUDIO_CHANNEL_STREAMS; i++) {
- do_extra_channels(i, data1, data2, NULL, NULL, NULL, NULL);
+ int ch = audio_extra_streams[i];
+ if (ch) {
+ do_extra_channels(idx, ch, data1, data2, NULL, NULL, NULL, NULL);
+ idx += ch;
+ }
}
}
{
if (!audio_total_extra_streams)
return;
+ int idx = 0;
for (int i = 0; i < AUDIO_CHANNEL_STREAMS; i++) {
- do_extra_channels(i, data1, data2, data3, data4, data5, data6);
+ int ch = audio_extra_streams[i];
+ if (ch) {
+ do_extra_channels(idx, ch, data1, data2, data3, data4, data5, data6);
+ idx += ch;
+ }
}
}
int streamid = nr - AUDIO_CHANNELS_PAULA + 1;
struct audio_stream_data *asd = &audio_stream[nr - AUDIO_CHANNELS_PAULA];
if (asd->cb) {
- ok = asd->cb(streamid);
+ ok = asd->cb(streamid, asd->cb_data);
}
if (!ok) {
audio_state_stream_state(streamid, NULL, 0, MAX_EV);
set_extra_prehandler();
}
-int audio_enable_stream(bool enable, int streamid, int ch, SOUND_STREAM_CALLBACK cb)
+int audio_enable_stream(bool enable, int streamid, int ch, SOUND_STREAM_CALLBACK cb, void *cb_data)
{
if (streamid == 0)
return 0;
audio_extra_streams[streamid] = ch;
struct audio_stream_data *asd = audio_stream + streamid;
asd->cb = cb;
+ asd->cb_data = cb_data;
asd->evtime = CYCLE_UNIT;
for (int i = 0; i < ch; i++) {
struct audio_channel_data2 *acd = &asd->data[i];
asd->evtime = evt;
}
-static uae_s16 *cda_bufptr;
-static int cda_length, cda_userdata;
static unsigned int cda_evt;
static uae_s16 dummy_buffer[4] = { 0 };
-static CDA_CALLBACK cda_next_cd_audio_buffer_callback;
-static int cda_volume[2];
-static int cda_streamid = -1;
void update_cda_sound(double clk)
{
cda_evt = clk * CYCLE_UNIT / 44100;
}
-void audio_cda_volume(int left, int right)
+void audio_cda_volume(struct cd_audio_state *cas, int left, int right)
{
for (int j = 0; j < 2; j++) {
- cda_volume[j] = j == 0 ? left : right;
- cda_volume[j] = sound_cd_volume[j] * cda_volume[j] / 32768;
- if (cda_volume[j])
- cda_volume[j]++;
- if (cda_volume[j] >= 32768)
- cda_volume[j] = 32768;
+ cas->cda_volume[j] = j == 0 ? left : right;
+ cas->cda_volume[j] = sound_cd_volume[j] * cas->cda_volume[j] / 32768;
+ if (cas->cda_volume[j])
+ cas->cda_volume[j]++;
+ if (cas->cda_volume[j] >= 32768)
+ cas->cda_volume[j] = 32768;
}
}
-static bool audio_state_cda(int streamid)
+static bool audio_state_cda(int streamid, void *state)
{
- if (cda_bufptr >= dummy_buffer && cda_bufptr <= dummy_buffer + 4) {
- audio_enable_stream(false, cda_streamid, 0, NULL);
- cda_streamid = 0;
+ struct cd_audio_state *cas = (struct cd_audio_state*)state;
+ if (cas->cda_bufptr >= dummy_buffer && cas->cda_bufptr <= dummy_buffer + 4) {
+ audio_enable_stream(false, cas->cda_streamid, 0, NULL, NULL);
+ cas->cda_streamid = 0;
return false;
}
- if (cda_streamid <= 0)
+ if (cas->cda_streamid <= 0)
return false;
int samples[2];
- samples[0] = cda_bufptr[0] * cda_volume[0] / 32768;
- samples[1] = cda_bufptr[1] * cda_volume[1] / 32768;
+ samples[0] = cas->cda_bufptr[0] * cas->cda_volume[0] / 32768;
+ samples[1] = cas->cda_bufptr[1] * cas->cda_volume[1] / 32768;
audio_state_stream_state(streamid, samples, 2, cda_evt);
- cda_bufptr += 2;
- cda_length--;
- if (cda_length <= 0 && cda_next_cd_audio_buffer_callback) {
- cda_next_cd_audio_buffer_callback(cda_userdata);
+ cas->cda_bufptr += 2;
+ cas->cda_length--;
+ if (cas->cda_length <= 0 && cas->cda_next_cd_audio_buffer_callback) {
+ cas->cda_next_cd_audio_buffer_callback(cas->cda_userdata, cas->cb_data);
}
return true;
}
-void audio_cda_new_buffer(uae_s16 *buffer, int length, int userdata, CDA_CALLBACK next_cd_audio_buffer_callback)
+void audio_cda_new_buffer(struct cd_audio_state *cas, uae_s16 *buffer, int length, int userdata, CDA_CALLBACK next_cd_audio_buffer_callback, void *cb_data)
{
- if (length < 0 && cda_streamid > 0) {
- audio_enable_stream(false, cda_streamid, 0, NULL);
- cda_streamid = 0;
+ if (length < 0 && cas->cda_streamid > 0) {
+ audio_enable_stream(false, cas->cda_streamid, 0, NULL, cas);
+ cas->cda_streamid = 0;
return;
}
if (!buffer) {
- cda_bufptr = dummy_buffer;
- cda_length = 0;
+ cas->cda_bufptr = dummy_buffer;
+ cas->cda_length = 0;
} else {
- cda_bufptr = buffer;
- cda_length = length;
- cda_userdata = userdata;
- if (cda_streamid <= 0)
- cda_streamid = audio_enable_stream(true, -1, 2, audio_state_cda);
- }
- cda_next_cd_audio_buffer_callback = next_cd_audio_buffer_callback;
- audio_activate();
+ cas->cda_bufptr = buffer;
+ cas->cda_length = length;
+ cas->cda_userdata = userdata;
+ if (cas->cda_streamid <= 0)
+ cas->cda_streamid = audio_enable_stream(true, -1, 2, audio_state_cda, cas);
+ }
+ cas->cda_next_cd_audio_buffer_callback = next_cd_audio_buffer_callback;
+ cas->cb_data = cb_data;
+ if (cas->cda_streamid > 0)
+ audio_activate();
}
chd_file *chd_f;
cdrom_file *chd_cdf;
#endif
+ volatile int cda_bufon[2];
+ cda_audio *cda;
+ struct cd_audio_state cas;
};
static struct cdunit cdunits[MAX_TOTAL_SCSI_DEVICES];
sleep_millis(10);
}
-static volatile int cda_bufon[2];
-static cda_audio *cda;
-
-static void next_cd_audio_buffer_callback(int bufnum)
+static void next_cd_audio_buffer_callback(int bufnum, void *params)
{
+ struct cdunit *cdu = (struct cdunit*)params;
uae_sem_wait(&play_sem);
if (bufnum >= 0) {
- cda_bufon[bufnum] = 0;
+ cdu->cda_bufon[bufnum] = 0;
bufnum = 1 - bufnum;
- if (cda_bufon[bufnum])
- audio_cda_new_buffer((uae_s16*)cda->buffers[bufnum], CDDA_BUFFERS * 2352 / 4, bufnum, next_cd_audio_buffer_callback);
+ if (cdu->cda_bufon[bufnum])
+ audio_cda_new_buffer(&cdu->cas, (uae_s16*)cdu->cda->buffers[bufnum], CDDA_BUFFERS * 2352 / 4, bufnum, next_cd_audio_buffer_callback, cdu);
else
bufnum = -1;
}
if (bufnum < 0) {
- audio_cda_new_buffer(NULL, 0, -1, NULL);
+ audio_cda_new_buffer(&cdu->cas, NULL, -1, 0, NULL, cdu);
}
uae_sem_post(&play_sem);
}
bool restart = false;
cdu->thread_active = true;
+ memset(&cdu->cas, 0, sizeof(struct cd_audio_state));
while (cdu->cdda_play == 0)
sleep_millis(10);
oldplay = -1;
- cda_bufon[0] = cda_bufon[1] = 0;
+ cdu->cda_bufon[0] = cdu->cda_bufon[1] = 0;
bufnum = 0;
- cda = new cda_audio (CDDA_BUFFERS, 2352, 44100);
+ cdu->cda = new cda_audio (CDDA_BUFFERS, 2352, 44100, mode != 0);
while (cdu->cdda_play > 0) {
}
if (mode) {
- while (cda_bufon[bufnum] && cdu->cdda_play > 0) {
+ while (cdu->cda_bufon[bufnum] && cdu->cdda_play > 0) {
if (cd_audio_mode_changed) {
restart = true;
goto end;
sleep_millis(10);
}
} else {
- cda->wait(bufnum);
+ cdu->cda->wait(bufnum);
}
- cda_bufon[bufnum] = 0;
+ cdu->cda_bufon[bufnum] = 0;
if (cdu->cdda_play <= 0)
goto end;
setstate(cdu, AUDIO_STATUS_IN_PROGRESS, cdda_pos);
- memset (cda->buffers[bufnum], 0, CDDA_BUFFERS * 2352);
+ memset (cdu->cda->buffers[bufnum], 0, CDDA_BUFFERS * 2352);
for (cnt = 0; cnt < CDDA_BUFFERS && cdu->cdda_play > 0; cnt++) {
- uae_u8 *dst = cda->buffers[bufnum] + cnt * 2352;
+ uae_u8 *dst = cdu->cda->buffers[bufnum] + cnt * 2352;
uae_u8 subbuf[SUB_CHANNEL_SIZE];
sector = cdda_pos;
cdu->cd_last_pos = cdda_pos;
if (mode) {
- if (cda_bufon[0] == 0 && cda_bufon[1] == 0) {
- cda_bufon[bufnum] = 1;
- next_cd_audio_buffer_callback(1 - bufnum);
+ if (cdu->cda_bufon[0] == 0 && cdu->cda_bufon[1] == 0) {
+ cdu->cda_bufon[bufnum] = 1;
+ next_cd_audio_buffer_callback(1 - bufnum, cdu);
}
- audio_cda_volume(cdu->cdda_volume[0], cdu->cdda_volume[1]);
- cda_bufon[bufnum] = 1;
+ audio_cda_volume(&cdu->cas, cdu->cdda_volume[0], cdu->cdda_volume[1]);
+ cdu->cda_bufon[bufnum] = 1;
} else {
- cda_bufon[bufnum] = 1;
- cda->setvolume (cdu->cdda_volume[0], cdu->cdda_volume[1]);
- if (!cda->play (bufnum)) {
+ cdu->cda_bufon[bufnum] = 1;
+ cdu->cda->setvolume (cdu->cdda_volume[0], cdu->cdda_volume[1]);
+ if (!cdu->cda->play (bufnum)) {
if (cdu->cdda_play > 0)
setstate (cdu, AUDIO_STATUS_PLAY_ERROR, -1);
goto end;
}
- if (cda_bufon[0] == 0 && cda_bufon[1] == 0) {
+ if (cdu->cda_bufon[0] == 0 && cdu->cda_bufon[1] == 0) {
while (cdu->cdda_paused && cdu->cdda_play == oldplay)
sleep_millis(10);
}
end:
*outpos = cdda_pos;
if (mode) {
- next_cd_audio_buffer_callback(-1);
+ next_cd_audio_buffer_callback(-1, cdu);
if (restart)
- audio_cda_new_buffer(NULL, -1, -1, NULL);
+ audio_cda_new_buffer(&cdu->cas, NULL, -1, -1, NULL, NULL);
} else {
- cda->wait (0);
- cda->wait (1);
+ cdu->cda->wait (0);
+ cdu->cda->wait (1);
}
while (cdimage_unpack_active == 1)
sleep_millis(10);
- delete cda;
+ delete cdu->cda;
write_log (_T("IMAGE CDDA: thread killed (%s)\n"), restart ? _T("restart") : _T("play end"));
cd_audio_mode_changed = false;
static uae_sem_t play_sem;
static volatile bool fmv_bufon[2];
static double fmv_syncadjust;
+static struct cd_audio_state cas;
struct cl450_videoram
{
write_log(_T("L64111 mute %d\n"), volume ? 0 : 1);
if (cda) {
if (audio_mode) {
- audio_cda_volume(volume, volume);
+ audio_cda_volume(&cas, volume, volume);
} else {
cda->setvolume(volume, volume);
}
fmv_syncadjust = adjust;
}
-static void fmv_next_cd_audio_buffer_callback(int bufnum)
+static void fmv_next_cd_audio_buffer_callback(int bufnum, void *param)
{
uae_sem_wait(&play_sem);
if (bufnum >= 0) {
fmv_bufon[bufnum] = 0;
bufnum = 1 - bufnum;
if (fmv_bufon[bufnum])
- audio_cda_new_buffer((uae_s16*)cda->buffers[bufnum], PCM_SECTORS * KJMP2_SAMPLES_PER_FRAME, bufnum, fmv_next_cd_audio_buffer_callback);
+ audio_cda_new_buffer(&cas, (uae_s16*)cda->buffers[bufnum], PCM_SECTORS * KJMP2_SAMPLES_PER_FRAME, bufnum, fmv_next_cd_audio_buffer_callback, param);
else
bufnum = -1;
}
if (bufnum < 0) {
- audio_cda_new_buffer(NULL, 0, -1, NULL);
+ audio_cda_new_buffer(&cas, NULL, 0, -1, NULL, NULL);
}
uae_sem_post(&play_sem);
}
if (!fmv_ram_bank.baseaddr)
return;
- if (cd_audio_mode_changed) {
+ if (cd_audio_mode_changed || (cl450_play && !cda)) {
cd_audio_mode_changed = false;
if (cl450_play) {
if (audio_mode) {
- audio_cda_new_buffer(NULL, -1, -1, NULL);
+ audio_cda_new_buffer(&cas, NULL, -1, -1, NULL, NULL);
}
audio_mode = currprefs.sound_cdaudio;
fmv_bufon[0] = fmv_bufon[1] = 0;
+ delete cda;
+ cda = new cda_audio(PCM_SECTORS, KJMP2_SAMPLES_PER_FRAME * 4, 44100, audio_mode != 0);
+ l64111_setvolume();
}
}
if (audio_mode) {
if (!play0 && !play1) {
fmv_bufon[bufnum] = 1;
- fmv_next_cd_audio_buffer_callback(1 - bufnum);
+ fmv_next_cd_audio_buffer_callback(1 - bufnum, NULL);
}
fmv_bufon[bufnum] = 1;
} else {
videoram = NULL;
if (cda) {
if (audio_mode) {
- fmv_next_cd_audio_buffer_callback(-1);
+ fmv_next_cd_audio_buffer_callback(-1, NULL);
} else {
cda->wait(0);
cda->wait(1);
mapped_malloc(&fmv_ram_bank);
if (!pcmaudio)
pcmaudio = xcalloc(struct fmv_pcmaudio, L64111_CHANNEL_BUFFERS);
-
kjmp2_init(&mp2);
- if (!cda) {
- cda = new cda_audio(PCM_SECTORS, KJMP2_SAMPLES_PER_FRAME * 4, 44100);
- l64111_setvolume();
- }
if (!mpeg_decoder) {
mpeg_decoder = mpeg2_init();
mpeg_info = mpeg2_info(mpeg_decoder);
}
+ memset(&cas, 0, sizeof(cas));
fmv_bank.mask = fmv_board_size - 1;
map_banks(&fmv_rom_bank, (fmv_start + ROM_BASE) >> 16, fmv_rom_size >> 16, 0);
map_banks(&fmv_ram_bank, (fmv_start + RAM_BASE) >> 16, fmv_ram_size >> 16, 0);
extern int sampleripper_enabled;
-typedef void(*CDA_CALLBACK)(int);
-typedef bool(*SOUND_STREAM_CALLBACK)(int);
+typedef void(*CDA_CALLBACK)(int, void*);
+typedef bool(*SOUND_STREAM_CALLBACK)(int, void*);
-extern int audio_enable_stream(bool, int, int, SOUND_STREAM_CALLBACK);
+extern int audio_enable_stream(bool, int, int, SOUND_STREAM_CALLBACK, void*);
extern void audio_state_stream_state(int, int*, int, unsigned int);
-extern void audio_cda_new_buffer(uae_s16 *buffer, int length, int userdata, CDA_CALLBACK next_cd_audio_buffer_callback);
-extern void audio_cda_volume(int left, int right);
+struct cd_audio_state
+{
+ uae_s16 *cda_bufptr;
+ int cda_length, cda_userdata;
+ CDA_CALLBACK cda_next_cd_audio_buffer_callback;
+ void *cb_data;
+ int cda_volume[2];
+ int cda_streamid = -1;
+};
+
+extern void audio_cda_new_buffer(struct cd_audio_state *cas, uae_s16 *buffer, int length, int userdata, CDA_CALLBACK next_cd_audio_buffer_callback, void *cb_data);
+extern void audio_cda_volume(struct cd_audio_state *cas, int left, int right);
extern int sound_cd_volume[2];
extern int sound_paula_volume[2];
bool open;
bool usesptiread;
bool changed;
+ cda_audio *cda;
+ volatile int cda_bufon[2];
+ struct cd_audio_state cas;
};
static struct dev_info_ioctl ciw32[MAX_TOTAL_SCSI_DEVICES];
return 0;
}
-static cda_audio *cda;
-static volatile int cda_bufon[2];
-
-void ioctl_next_cd_audio_buffer_callback(int bufnum)
+void ioctl_next_cd_audio_buffer_callback(int bufnum, void *param)
{
+ struct dev_info_ioctl *ciw = (struct dev_info_ioctl*)param;
uae_sem_wait(&play_sem);
if (bufnum >= 0) {
- cda_bufon[bufnum] = 0;
+ ciw->cda_bufon[bufnum] = 0;
bufnum = 1 - bufnum;
- if (cda_bufon[bufnum])
- audio_cda_new_buffer((uae_s16*)cda->buffers[bufnum], CDDA_BUFFERS * 2352 / 4, bufnum, ioctl_next_cd_audio_buffer_callback);
+ if (ciw->cda_bufon[bufnum])
+ audio_cda_new_buffer(&ciw->cas, (uae_s16*)ciw->cda->buffers[bufnum], CDDA_BUFFERS * 2352 / 4, bufnum, ioctl_next_cd_audio_buffer_callback, ciw);
else
bufnum = -1;
}
if (bufnum < 0) {
- audio_cda_new_buffer(NULL, 0, -1, NULL);
+ audio_cda_new_buffer(&ciw->cas, NULL, 0, -1, NULL, ciw);
}
uae_sem_post(&play_sem);
}
sleep_millis(10);
oldplay = -1;
- cda_bufon[0] = cda_bufon[1] = 0;
+ ciw->cda_bufon[0] = ciw->cda_bufon[1] = 0;
bufnum = 0;
buffered = 0;
- cda = new cda_audio (CDDA_BUFFERS, 2352, 44100);
+ memset(&ciw->cas, 0, sizeof(struct cd_audio_state));
+ ciw->cda = new cda_audio (CDDA_BUFFERS, 2352, 44100, mode != 0);
while (ciw->cdda_play > 0) {
if (mode) {
- while (cda_bufon[bufnum] && ciw->cdda_play > 0) {
+ while (ciw->cda_bufon[bufnum] && ciw->cdda_play > 0) {
if (cd_audio_mode_changed) {
restart = true;
goto end;
sleep_millis(10);
}
} else {
- cda->wait(bufnum);
+ ciw->cda->wait(bufnum);
}
if (ciw->cdda_play <= 0)
goto end;
- cda_bufon[bufnum] = 0;
+ ciw->cda_bufon[bufnum] = 0;
if (oldplay != ciw->cdda_play) {
idleframes = 0;
}
// force spin up
if (isaudiotrack (&ciw->di.toc, cdda_pos))
- read_block (ciw, -1, cda->buffers[bufnum], cdda_pos, CDDA_BUFFERS, readblocksize);
+ read_block (ciw, -1, ciw->cda->buffers[bufnum], cdda_pos, CDDA_BUFFERS, readblocksize);
if (!isaudiotrack (&ciw->di.toc, cdda_pos - 150))
muteframes = 75;
// buggy CD32/CDTV software CD+G handling does not miss any frames
bool seenindex = false;
for (int sector = cdda_pos - 200; sector < cdda_pos; sector++) {
- uae_u8 *dst = cda->buffers[bufnum];
+ uae_u8 *dst = ciw->cda->buffers[bufnum];
if (sector >= 0 && isaudiotrack (&ciw->di.toc, sector) && read_block (ciw, -1, dst, sector, 1, readblocksize)) {
uae_u8 subbuf[SUB_CHANNEL_SIZE];
sub_deinterleave (dst + 2352, subbuf);
ciw->subcodevalid = false;
memset (ciw->subcode, 0, sizeof ciw->subcode);
- memset (cda->buffers[bufnum], 0, CDDA_BUFFERS * readblocksize);
+ memset (ciw->cda->buffers[bufnum], 0, CDDA_BUFFERS * readblocksize);
if (cdda_pos >= 0) {
setstate(ciw, AUDIO_STATUS_IN_PROGRESS, cdda_pos);
- if (read_block (ciw, -1, cda->buffers[bufnum], cdda_pos, CDDA_BUFFERS, readblocksize)) {
+ if (read_block (ciw, -1, ciw->cda->buffers[bufnum], cdda_pos, CDDA_BUFFERS, readblocksize)) {
for (i = 0; i < CDDA_BUFFERS; i++) {
- memcpy (ciw->subcode + i * SUB_CHANNEL_SIZE, cda->buffers[bufnum] + readblocksize * i + 2352, SUB_CHANNEL_SIZE);
+ memcpy (ciw->subcode + i * SUB_CHANNEL_SIZE, ciw->cda->buffers[bufnum] + readblocksize * i + 2352, SUB_CHANNEL_SIZE);
}
for (i = 1; i < CDDA_BUFFERS; i++) {
- memmove (cda->buffers[bufnum] + 2352 * i, cda->buffers[bufnum] + readblocksize * i, 2352);
+ memmove (ciw->cda->buffers[bufnum] + 2352 * i, ciw->cda->buffers[bufnum] + readblocksize * i, 2352);
}
ciw->subcodevalid = true;
}
for (i = 0; i < CDDA_BUFFERS; i++) {
if (muteframes > 0) {
- memset (cda->buffers[bufnum] + 2352 * i, 0, 2352);
+ memset (ciw->cda->buffers[bufnum] + 2352 * i, 0, 2352);
muteframes--;
}
if (idleframes > 0) {
idleframes--;
- memset (cda->buffers[bufnum] + 2352 * i, 0, 2352);
+ memset (ciw->cda->buffers[bufnum] + 2352 * i, 0, 2352);
memset (ciw->subcode + i * SUB_CHANNEL_SIZE, 0, SUB_CHANNEL_SIZE);
} else if (cdda_pos < ciw->cdda_start && ciw->cdda_scan == 0) {
- memset (cda->buffers[bufnum] + 2352 * i, 0, 2352);
+ memset (ciw->cda->buffers[bufnum] + 2352 * i, 0, 2352);
}
}
if (idleframes > 0)
}
if (mode) {
- if (cda_bufon[0] == 0 && cda_bufon[1] == 0) {
- cda_bufon[bufnum] = 1;
- ioctl_next_cd_audio_buffer_callback(1 - bufnum);
+ if (ciw->cda_bufon[0] == 0 && ciw->cda_bufon[1] == 0) {
+ ciw->cda_bufon[bufnum] = 1;
+ ioctl_next_cd_audio_buffer_callback(1 - bufnum, ciw);
}
- audio_cda_volume(ciw->cdda_volume[0], ciw->cdda_volume[1]);
- cda_bufon[bufnum] = 1;
+ audio_cda_volume(&ciw->cas, ciw->cdda_volume[0], ciw->cdda_volume[1]);
+ ciw->cda_bufon[bufnum] = 1;
} else {
- cda_bufon[bufnum] = 1;
- cda->setvolume (ciw->cdda_volume[0], ciw->cdda_volume[1]);
- if (!cda->play (bufnum)) {
+ ciw->cda_bufon[bufnum] = 1;
+ ciw->cda->setvolume (ciw->cdda_volume[0], ciw->cdda_volume[1]);
+ if (!ciw->cda->play (bufnum)) {
setstate (ciw, AUDIO_STATUS_PLAY_ERROR, -1);
goto end; // data track?
}
}
}
- if (cda_bufon[0] == 0 && cda_bufon[1] == 0) {
+ if (ciw->cda_bufon[0] == 0 && ciw->cda_bufon[1] == 0) {
while (ciw->cdda_paused && ciw->cdda_play == oldplay)
sleep_millis(10);
}
end:
*outpos = cdda_pos;
if (mode) {
- ioctl_next_cd_audio_buffer_callback(-1);
+ ioctl_next_cd_audio_buffer_callback(-1, ciw);
if (restart)
- audio_cda_new_buffer(NULL, -1, -1, NULL);
+ audio_cda_new_buffer(&ciw->cas, NULL, -1, -1, NULL, ciw);
} else {
- cda->wait (0);
- cda->wait (1);
+ ciw->cda->wait (0);
+ ciw->cda->wait (1);
}
ciw->subcodevalid = false;
cd_audio_mode_changed = false;
- delete cda;
+ delete ciw->cda;
write_log (_T("IOCTL CDDA: thread killed\n"));
return restart;
cda_audio::~cda_audio()
{
- wait (0);
- wait (1);
+ if (active) {
+ wait(0);
+ wait(1);
#if CDADS
- if (dsnotify)
- dsnotify->Release();
- if (dsbuf)
- dsbuf->Release();
- if (ds)
- ds->Release();
- if (notifyevent[0])
- CloseHandle (notifyevent[0]);
- if (notifyevent[1])
- CloseHandle (notifyevent[1]);
+ if (dsnotify)
+ dsnotify->Release();
+ if (dsbuf)
+ dsbuf->Release();
+ if (ds)
+ ds->Release();
+ if (notifyevent[0])
+ CloseHandle(notifyevent[0]);
+ if (notifyevent[1])
+ CloseHandle(notifyevent[1]);
#else
- if (active) {
for (int i = 0; i < 2; i++)
- waveOutUnprepareHeader (wavehandle, &whdr[i], sizeof (WAVEHDR));
- }
- if (wavehandle != NULL)
- waveOutClose (wavehandle);
+ waveOutUnprepareHeader(wavehandle, &whdr[i], sizeof(WAVEHDR));
+ if (wavehandle != NULL)
+ waveOutClose(wavehandle);
#endif
+ }
for (int i = 0; i < 2; i++) {
xfree (buffers[i]);
buffers[i] = NULL;
}
}
-cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate)
+cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate, bool internalmode)
{
active = false;
playing = false;
for (int i = 0; i < 2; i++) {
buffers[i] = xcalloc (uae_u8, num_sectors * ((bufsize + 4095) & ~4095));
}
+ this->num_sectors = num_sectors;
+
+ if (internalmode)
+ return;
WAVEFORMATEX wav;
memset (&wav, 0, sizeof (WAVEFORMATEX));
write_log (_T("IMAGE CDDA: wave open %d\n"), mmr);
return;
}
- this->num_sectors = num_sectors;
for (int i = 0; i < 2; i++) {
memset (&whdr[i], 0, sizeof(WAVEHDR));
whdr[i].dwBufferLength = sectorsize * num_sectors;
public:
uae_u8 *buffers[2];
- cda_audio(int num_sectors, int sectorsize, int samplerate);
+ cda_audio(int num_sectors, int sectorsize, int samplerate, bool internalmode);
~cda_audio();
void setvolume(int left, int right);
bool play(int bufnum);
#define STREAM_STRUCT_SIZE 40
-static bool audio_state_sndboard_uae(int streamid);
+static bool audio_state_sndboard_uae(int streamid, void *params);
extern addrbank uaesndboard_ram_bank;
MEMORY_FUNCTIONS(uaesndboard_ram);
return;
s->play = 0;
data->streammask &= ~(1 << (s - data->stream));
- audio_enable_stream(false, s->streamid, 0, NULL);
+ audio_enable_stream(false, s->streamid, 0, NULL, NULL);
s->streamid = 0;
data->streamcnt--;
}
s->sample[i] = 0;
}
uaesnd_setfreq(s);
- s->streamid = audio_enable_stream(true, -1, MAX_UAE_CHANNELS, audio_state_sndboard_uae);
+ s->streamid = audio_enable_stream(true, -1, MAX_UAE_CHANNELS, audio_state_sndboard_uae, NULL);
if (!s->streamid) {
uaesndboard_stop(data, s);
}
}
}
-static bool audio_state_sndboard_uae(int streamid)
+static bool audio_state_sndboard_uae(int streamid, void *params)
{
struct uaesndboard_data *data = &uaesndboard[0];
struct uaesndboard_stream *s = NULL;
if (data->enabled) {
for (int i = 0; i < MAX_UAE_STREAMS; i++) {
if (data->stream[i].streamid) {
- audio_enable_stream(false, data->stream[i].streamid, 0, NULL);
+ audio_enable_stream(false, data->stream[i].streamid, 0, NULL, NULL);
memset(&data->stream[i], 0, sizeof(struct uaesndboard_stream));
}
}
data->fifo_half |= STATUS_FIFO_PLAY;
}
-static bool audio_state_sndboard_toccata(int streamid)
+static bool audio_state_sndboard_toccata(int streamid, void *params)
{
struct toccata_data *data = &toccata[0];
if (!toccata[0].toccata_active)
data->record_event_counter = 0;
if (data->toccata_active & STATUS_FIFO_PLAY) {
- data->streamid = audio_enable_stream(true, -1, 2, audio_state_sndboard_toccata);
+ data->streamid = audio_enable_stream(true, -1, 2, audio_state_sndboard_toccata, NULL);
}
if (data->toccata_active & STATUS_FIFO_RECORD) {
capture_buffer = xcalloc(uae_u8, capture_buffer_size);
write_log(_T("TOCCATA stop\n"));
data->toccata_active = 0;
sndboard_free_capture();
- audio_enable_stream(false, data->streamid, 0, NULL);
+ audio_enable_stream(false, data->streamid, 0, NULL, NULL);
data->streamid = 0;
xfree(capture_buffer);
capture_buffer = NULL;
codec_stop();
data->toccata_irq = 0;
if (data->streamid > 0)
- audio_enable_stream(false, data->streamid, 0, NULL);
+ audio_enable_stream(false, data->streamid, 0, NULL, NULL);
data->streamid = 0;
sndboard_rethink();
mapped_free(&toccata_bank);
{
write_log(_T("FM801 STOP\n"));
data->play_on = false;
- audio_enable_stream(false, data->streamid, 0, NULL);
+ audio_enable_stream(false, data->streamid, 0, NULL, NULL);
data->streamid = 0;
}
}
}
-static bool audio_state_sndboard_fm801(int streamid)
+static bool audio_state_sndboard_fm801(int streamid, void *params)
{
struct fm801_data *data = &fm801;
write_log(_T("FM801 PLAY: freq=%d ch=%d bits=%d\n"), data->freq, data->ch, data->bits);
- data->streamid = audio_enable_stream(true, -1, data->ch, audio_state_sndboard_fm801);
+ data->streamid = audio_enable_stream(true, -1, data->ch, audio_state_sndboard_fm801, NULL);
}
static void fm801_pause(struct fm801_data *data, bool pause)
static SWVoiceOut *qemu_voice_out;
-static bool audio_state_sndboard_qemu(int streamid)
+static bool audio_state_sndboard_qemu(int streamid, void *params)
{
SWVoiceOut *out = qemu_voice_out;
sw->samplebuf_index = 0;
sw->samplebuf_total = 0;
calculate_volume_qemu();
- audio_enable_stream(false, sw->streamid, 2, NULL);
+ audio_enable_stream(false, sw->streamid, 2, NULL, NULL);
sw->streamid = 0;
if (on) {
- sw->streamid = audio_enable_stream(true, -1, 2, audio_state_sndboard_qemu);
+ sw->streamid = audio_enable_stream(true, -1, 2, audio_state_sndboard_qemu, NULL);
}
}
void AUD_set_active_in(SWVoiceIn *sw, int on)
{
qemu_voice_out = NULL;
if (sw) {
- audio_enable_stream(false, sw->streamid, 0, NULL);
+ audio_enable_stream(false, sw->streamid, 0, NULL, NULL);
sw->streamid = 0;
xfree(sw);
}
xb->delayed_interrupt |= 1 << 2;
}
} else if (write && (portnum == 0x3d1 || portnum == 0x3d3 || portnum == 0x3d5 || portnum == 0x3d7 || portnum == 0x3d8 || portnum == 0x3d9 || portnum == 0x3dd)) {
- // color crt data register
+ // color crt data register
if (!xb->video_initialized) {
set_initial_cpu_turbo(xb);
}
zfile_fwrite(nvrram, 1, xb->cmossize, xb->cmosfile);
}
if (xb->audstream) {
- audio_enable_stream(false, xb->audstream, 0, NULL);
+ audio_enable_stream(false, xb->audstream, 0, NULL, NULL);
}
zfile_fclose(xb->cmosfile);
xfree(xb->amiga_io);
check_floppy_delay();
}
-static bool audio_state_sndboard_x86(int streamid)
+static bool audio_state_sndboard_x86(int streamid, void *param)
{
static int smp[2] = { 0, 0 };
struct x86_bridge *xb = bridges[0];
write_log(_T("x86 sound init\n"));
xb->audeventtime = x86_base_event_clock * CYCLE_UNIT / currprefs.sound_freq + 1;
timer_add(sound_poll, &sound_poll_time, TIMER_ALWAYS_ENABLED, NULL);
- xb->audstream = audio_enable_stream(true, -1, 2, audio_state_sndboard_x86);
+ xb->audstream = audio_enable_stream(true, -1, 2, audio_state_sndboard_x86, NULL);
}
}