mirror of
https://github.com/LIV2/WinUAE.git
synced 2025-12-06 00:12:52 +00:00
Remove external CD audio playback path.
This commit is contained in:
parent
ab65865854
commit
d6bbc0ddd1
@ -1935,7 +1935,6 @@ static int sound_prefs_changed (void)
|
||||
|| changed_prefs.sound_volume_board != currprefs.sound_volume_board
|
||||
|| changed_prefs.sound_stereo_swap_paula != currprefs.sound_stereo_swap_paula
|
||||
|| changed_prefs.sound_stereo_swap_ahi != currprefs.sound_stereo_swap_ahi
|
||||
|| changed_prefs.sound_cdaudio != currprefs.sound_cdaudio
|
||||
|| changed_prefs.sound_filter != currprefs.sound_filter
|
||||
|| changed_prefs.sound_filter_type != currprefs.sound_filter_type)
|
||||
return -1;
|
||||
@ -2023,7 +2022,6 @@ void set_audio (void)
|
||||
currprefs.sound_volume_master = changed_prefs.sound_volume_master;
|
||||
currprefs.sound_volume_board = changed_prefs.sound_volume_board;
|
||||
currprefs.sound_volume_cd = changed_prefs.sound_volume_cd;
|
||||
currprefs.sound_cdaudio = changed_prefs.sound_cdaudio;
|
||||
currprefs.sound_stereo_swap_paula = changed_prefs.sound_stereo_swap_paula;
|
||||
currprefs.sound_stereo_swap_ahi = changed_prefs.sound_stereo_swap_ahi;
|
||||
|
||||
|
||||
@ -472,7 +472,6 @@ static bool cdda_play_func2 (struct cdunit *cdu, int *outpos)
|
||||
int silentframes = 0;
|
||||
bool foundsub;
|
||||
int oldtrack = -1;
|
||||
int mode = currprefs.sound_cdaudio;
|
||||
bool restart = false;
|
||||
bool first = true;
|
||||
|
||||
@ -486,7 +485,7 @@ static bool cdda_play_func2 (struct cdunit *cdu, int *outpos)
|
||||
cdu->cda_bufon[0] = cdu->cda_bufon[1] = 0;
|
||||
bufnum = 0;
|
||||
|
||||
cdu->cda = new cda_audio (CDDA_BUFFERS, 2352, 44100, mode != 0);
|
||||
cdu->cda = new cda_audio (CDDA_BUFFERS, 2352, 44100);
|
||||
|
||||
while (cdu->cdda_play > 0) {
|
||||
|
||||
@ -576,16 +575,12 @@ static bool cdda_play_func2 (struct cdunit *cdu, int *outpos)
|
||||
}
|
||||
}
|
||||
|
||||
if (mode) {
|
||||
while (cdu->cda_bufon[bufnum] && cdu->cdda_play > 0) {
|
||||
if (cd_audio_mode_changed) {
|
||||
restart = true;
|
||||
goto end;
|
||||
}
|
||||
sleep_millis(10);
|
||||
while (cdu->cda_bufon[bufnum] && cdu->cdda_play > 0) {
|
||||
if (cd_audio_mode_changed) {
|
||||
restart = true;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
cdu->cda->wait(bufnum);
|
||||
sleep_millis(10);
|
||||
}
|
||||
|
||||
cdu->cda_bufon[bufnum] = 0;
|
||||
@ -685,22 +680,12 @@ static bool cdda_play_func2 (struct cdunit *cdu, int *outpos)
|
||||
if (idleframes <= 0)
|
||||
cdu->cd_last_pos = cdda_pos;
|
||||
|
||||
if (mode) {
|
||||
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->cas, cdu->cdda_volume[0], cdu->cdda_volume[1]);
|
||||
if (cdu->cda_bufon[0] == 0 && cdu->cda_bufon[1] == 0) {
|
||||
cdu->cda_bufon[bufnum] = 1;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
next_cd_audio_buffer_callback(1 - bufnum, cdu);
|
||||
}
|
||||
audio_cda_volume(&cdu->cas, cdu->cdda_volume[0], cdu->cdda_volume[1]);
|
||||
cdu->cda_bufon[bufnum] = 1;
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
@ -731,14 +716,9 @@ static bool cdda_play_func2 (struct cdunit *cdu, int *outpos)
|
||||
|
||||
end:
|
||||
*outpos = cdda_pos;
|
||||
if (mode) {
|
||||
next_cd_audio_buffer_callback(-1, cdu);
|
||||
if (restart)
|
||||
audio_cda_new_buffer(&cdu->cas, NULL, -1, -1, NULL, NULL);
|
||||
} else {
|
||||
cdu->cda->wait (0);
|
||||
cdu->cda->wait (1);
|
||||
}
|
||||
next_cd_audio_buffer_callback(-1, cdu);
|
||||
if (restart)
|
||||
audio_cda_new_buffer(&cdu->cas, NULL, -1, -1, NULL, NULL);
|
||||
|
||||
while (cdimage_unpack_active == 1)
|
||||
sleep_millis(10);
|
||||
|
||||
42
cd32_fmv.cpp
42
cd32_fmv.cpp
@ -224,7 +224,6 @@ static uae_u16 cl450_threshold;
|
||||
static int cl450_buffer_offset;
|
||||
static int cl450_buffer_empty_cnt;
|
||||
static int libmpeg_offset;
|
||||
static bool audio_mode;
|
||||
static uae_sem_t play_sem;
|
||||
static volatile bool fmv_bufon[2];
|
||||
static float fmv_syncadjust;
|
||||
@ -394,11 +393,7 @@ static void l64111_setvolume(void)
|
||||
return;
|
||||
write_log(_T("L64111 mute %d\n"), volume ? 0 : 1);
|
||||
if (cda) {
|
||||
if (audio_mode) {
|
||||
audio_cda_volume(&cas, volume, volume);
|
||||
} else {
|
||||
cda->setvolume(volume, volume);
|
||||
}
|
||||
audio_cda_volume(&cas, volume, volume);
|
||||
}
|
||||
}
|
||||
|
||||
@ -989,7 +984,6 @@ static void cl450_newcmd(void)
|
||||
{
|
||||
case CL_Play:
|
||||
cl450_play = 1;
|
||||
audio_mode = currprefs.sound_cdaudio;
|
||||
write_log(_T("CL450 PLAY\n"));
|
||||
break;
|
||||
case CL_Pause:
|
||||
@ -1055,7 +1049,6 @@ static void cl450_newcmd(void)
|
||||
case CL_Reset:
|
||||
write_log(_T("CL450 Reset\n"));
|
||||
cl450_reset_cmd();
|
||||
audio_mode = currprefs.sound_cdaudio;
|
||||
break;
|
||||
case CL_FlushBitStream:
|
||||
write_log(_T("CL450 CL_FlushBitStream\n"));
|
||||
@ -1407,13 +1400,10 @@ static void cd32_fmv_audio_handler(void)
|
||||
if (cd_audio_mode_changed || (cl450_play && !cda)) {
|
||||
cd_audio_mode_changed = false;
|
||||
if (cl450_play) {
|
||||
if (audio_mode) {
|
||||
audio_cda_new_buffer(&cas, NULL, -1, -1, NULL, NULL);
|
||||
}
|
||||
audio_mode = currprefs.sound_cdaudio;
|
||||
audio_cda_new_buffer(&cas, NULL, -1, -1, NULL, NULL);
|
||||
fmv_bufon[0] = fmv_bufon[1] = 0;
|
||||
delete cda;
|
||||
cda = new cda_audio(PCM_SECTORS, KJMP2_SAMPLES_PER_FRAME * 4, 44100, audio_mode != 0);
|
||||
cda = new cda_audio(PCM_SECTORS, KJMP2_SAMPLES_PER_FRAME * 4, 44100);
|
||||
l64111_setvolume();
|
||||
}
|
||||
}
|
||||
@ -1429,13 +1419,8 @@ static void cd32_fmv_audio_handler(void)
|
||||
|
||||
if (!cda || !(l64111_regs[A_CONTROL1] & 1))
|
||||
return;
|
||||
if (audio_mode) {
|
||||
play0 = fmv_bufon[0];
|
||||
play1 = fmv_bufon[1];
|
||||
} else {
|
||||
play0 = cda->isplaying(0);
|
||||
play1 = cda->isplaying(1);
|
||||
}
|
||||
play0 = fmv_bufon[0];
|
||||
play1 = fmv_bufon[1];
|
||||
needsectors = PCM_SECTORS;
|
||||
if (!play0 && !play1) {
|
||||
needsectors *= 2;
|
||||
@ -1459,15 +1444,11 @@ static void cd32_fmv_audio_handler(void)
|
||||
memcpy(cda->buffers[bufnum] + i * KJMP2_SAMPLES_PER_FRAME * 4, pcmaudio[offset2].pcm, KJMP2_SAMPLES_PER_FRAME * 4);
|
||||
pcmaudio[offset2].ready = false;
|
||||
}
|
||||
if (audio_mode) {
|
||||
if (!play0 && !play1) {
|
||||
fmv_bufon[bufnum] = 1;
|
||||
fmv_next_cd_audio_buffer_callback(1 - bufnum, NULL);
|
||||
}
|
||||
if (!play0 && !play1) {
|
||||
fmv_bufon[bufnum] = 1;
|
||||
} else {
|
||||
cda->play(bufnum);
|
||||
fmv_next_cd_audio_buffer_callback(1 - bufnum, NULL);
|
||||
}
|
||||
fmv_bufon[bufnum] = 1;
|
||||
offset += PCM_SECTORS;
|
||||
offset &= l64111_cb_mask;
|
||||
l64111_regs[A_CB_READ] = offset;
|
||||
@ -1541,12 +1522,7 @@ static void cd32_fmv_free(void)
|
||||
xfree(videoram);
|
||||
videoram = NULL;
|
||||
if (cda) {
|
||||
if (audio_mode) {
|
||||
fmv_next_cd_audio_buffer_callback(-1, NULL);
|
||||
} else {
|
||||
cda->wait(0);
|
||||
cda->wait(1);
|
||||
}
|
||||
fmv_next_cd_audio_buffer_callback(-1, NULL);
|
||||
delete cda;
|
||||
}
|
||||
cda = NULL;
|
||||
|
||||
@ -2077,7 +2077,6 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
|
||||
if (p->sound_volume_genlock >= 0)
|
||||
cfgfile_write (f, _T("sound_volume_genlock"), _T("%d"), p->sound_volume_genlock);
|
||||
cfgfile_write_bool (f, _T("sound_auto"), p->sound_auto);
|
||||
cfgfile_write_bool (f, _T("sound_cdaudio"), p->sound_cdaudio);
|
||||
cfgfile_write_bool (f, _T("sound_stereo_swap_paula"), p->sound_stereo_swap_paula);
|
||||
cfgfile_write_bool (f, _T("sound_stereo_swap_ahi"), p->sound_stereo_swap_ahi);
|
||||
cfgfile_dwrite_bool(f, _T("sound_volcnt"), p->sound_volcnt);
|
||||
@ -3478,7 +3477,6 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
|
||||
|| cfgfile_yesno(option, value, _T("floppy3wp"), &p->floppyslots[3].forcedwriteprotect)
|
||||
|| cfgfile_yesno(option, value, _T("sampler_stereo"), &p->sampler_stereo)
|
||||
|| cfgfile_yesno(option, value, _T("sound_auto"), &p->sound_auto)
|
||||
|| cfgfile_yesno(option, value, _T("sound_cdaudio"), &p->sound_cdaudio)
|
||||
|| cfgfile_yesno(option, value, _T("sound_volcnt"), &p->sound_volcnt)
|
||||
|| cfgfile_yesno(option, value, _T("sound_stereo_swap_paula"), &p->sound_stereo_swap_paula)
|
||||
|| cfgfile_yesno(option, value, _T("sound_stereo_swap_ahi"), &p->sound_stereo_swap_ahi)
|
||||
@ -7973,7 +7971,6 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
|
||||
p->sound_filter = FILTER_SOUND_EMUL;
|
||||
p->sound_filter_type = 0;
|
||||
p->sound_auto = 1;
|
||||
p->sound_cdaudio = false;
|
||||
p->sampler_stereo = false;
|
||||
p->sampler_buffer = 0;
|
||||
p->sampler_freq = 0;
|
||||
|
||||
@ -528,7 +528,6 @@ struct uae_prefs {
|
||||
bool sound_stereo_swap_paula;
|
||||
bool sound_stereo_swap_ahi;
|
||||
bool sound_auto;
|
||||
bool sound_cdaudio;
|
||||
bool sound_volcnt;
|
||||
|
||||
int sampler_freq;
|
||||
|
||||
@ -30,34 +30,13 @@
|
||||
|
||||
cda_audio::~cda_audio()
|
||||
{
|
||||
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]);
|
||||
#else
|
||||
for (int i = 0; i < 2; i++)
|
||||
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, bool internalmode)
|
||||
cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate)
|
||||
{
|
||||
active = false;
|
||||
playing = false;
|
||||
@ -70,109 +49,6 @@ cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate, bool inter
|
||||
}
|
||||
this->num_sectors = num_sectors;
|
||||
|
||||
if (internalmode)
|
||||
return;
|
||||
|
||||
WAVEFORMATEX wav;
|
||||
memset (&wav, 0, sizeof (WAVEFORMATEX));
|
||||
|
||||
wav.cbSize = 0;
|
||||
wav.nChannels = 2;
|
||||
wav.nSamplesPerSec = samplerate;
|
||||
wav.wBitsPerSample = 16;
|
||||
wav.nBlockAlign = wav.wBitsPerSample / 8 * wav.nChannels;
|
||||
wav.nAvgBytesPerSec = wav.nBlockAlign * wav.nSamplesPerSec;
|
||||
wav.wFormatTag = WAVE_FORMAT_PCM;
|
||||
|
||||
#if CDADS
|
||||
LPDIRECTSOUNDBUFFER pdsb;
|
||||
WAVEFORMATEXTENSIBLE wavfmt;
|
||||
DSBUFFERDESC desc;
|
||||
HRESULT hr;
|
||||
|
||||
dsnotify = NULL;
|
||||
dsbuf = NULL;
|
||||
ds = NULL;
|
||||
notifyevent[0] = notifyevent[1] = NULL;
|
||||
|
||||
hr = DirectSoundCreate8 (&sound_devices[currprefs.win32_soundcard].guid, &ds, NULL);
|
||||
if (FAILED (hr)) {
|
||||
write_log (_T("CDA: DirectSoundCreate8() failure: %s\n"), DXError (hr));
|
||||
return;
|
||||
}
|
||||
|
||||
hr = ds->SetCooperativeLevel (hMainWnd, DSSCL_PRIORITY);
|
||||
if (FAILED (hr)) {
|
||||
write_log (_T("CDA: Can't set cooperativelevel: %s\n"), DXError (hr));
|
||||
return;
|
||||
}
|
||||
|
||||
wavfmt.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
||||
wavfmt.Format.nChannels = 2;
|
||||
wavfmt.Format.nSamplesPerSec = 44100;
|
||||
wavfmt.Format.wBitsPerSample = 16;
|
||||
wavfmt.Format.nBlockAlign = wavfmt.Format.wBitsPerSample / 8 * wavfmt.Format.nChannels;
|
||||
wavfmt.Format.nAvgBytesPerSec = wavfmt.Format.nBlockAlign * wavfmt.Format.nSamplesPerSec;
|
||||
wavfmt.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
wavfmt.Samples.wValidBitsPerSample = 16;
|
||||
wavfmt.Format.cbSize = sizeof (WAVEFORMATEXTENSIBLE) - sizeof (WAVEFORMATEX);
|
||||
|
||||
memset (&desc, 0, sizeof desc);
|
||||
desc.dwSize = sizeof desc;
|
||||
desc.dwBufferBytes = 2 * bufsize;
|
||||
desc.lpwfxFormat = &wavfmt.Format;
|
||||
desc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
|
||||
desc.dwFlags |= DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_CTRLVOLUME;
|
||||
desc.guid3DAlgorithm = GUID_NULL;
|
||||
|
||||
hr = ds->CreateSoundBuffer (&desc, &pdsb, NULL);
|
||||
if (FAILED (hr)) {
|
||||
write_log (_T("CDA: IDirectSound_CreateSoundBuffer %s\n"), DXError (hr));
|
||||
return;
|
||||
}
|
||||
hr = pdsb->QueryInterface (IID_IDirectSoundBuffer8, (LPVOID*)&dsbuf);
|
||||
IDirectSound_Release (pdsb);
|
||||
if (FAILED (hr)) {
|
||||
write_log (_T("CDA: Secondary QueryInterface() failure: %s\n"), DXError (hr));
|
||||
return;
|
||||
}
|
||||
hr = dsbuf->QueryInterface (IID_IDirectSoundNotify, (LPVOID*)&dsnotify);
|
||||
if (FAILED (hr)) {
|
||||
write_log (_T("CDA: IID_IDirectSoundNotify QueryInterface() failure: %s\n"), DXError (hr));
|
||||
return;
|
||||
}
|
||||
|
||||
notifyevent[0] = CreateEvent (NULL, TRUE, FALSE, NULL);
|
||||
notifyevent[1] = CreateEvent (NULL, TRUE, FALSE, NULL);
|
||||
DSBPOSITIONNOTIFY nf[2];
|
||||
nf[0].dwOffset = bufsize / num_sectors;
|
||||
nf[1].dwOffset = bufsize + bufsize / num_sectors;
|
||||
nf[0].hEventNotify = notifyevent[0];
|
||||
nf[1].hEventNotify = notifyevent[1];
|
||||
hr = dsnotify->SetNotificationPositions(2, nf);
|
||||
|
||||
active = true;
|
||||
#else
|
||||
MMRESULT mmr;
|
||||
mmr = waveOutOpen (&wavehandle, WAVE_MAPPER, &wav, 0, 0, WAVE_ALLOWSYNC | WAVE_FORMAT_DIRECT);
|
||||
if (mmr != MMSYSERR_NOERROR) {
|
||||
write_log (_T("IMAGE CDDA: wave open %d\n"), mmr);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
memset (&whdr[i], 0, sizeof(WAVEHDR));
|
||||
whdr[i].dwBufferLength = sectorsize * num_sectors;
|
||||
whdr[i].lpData = (LPSTR)buffers[i];
|
||||
mmr = waveOutPrepareHeader (wavehandle, &whdr[i], sizeof (WAVEHDR));
|
||||
if (mmr != MMSYSERR_NOERROR) {
|
||||
write_log (_T("IMAGE CDDA: waveOutPrepareHeader %d:%d\n"), i, mmr);
|
||||
return;
|
||||
}
|
||||
whdr[i].dwFlags |= WHDR_DONE;
|
||||
}
|
||||
active = true;
|
||||
playing = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void cda_audio::setvolume(int left, int right)
|
||||
@ -186,79 +62,7 @@ void cda_audio::setvolume(int left, int right)
|
||||
if (volume[j] >= 32768)
|
||||
volume[j] = 32768;
|
||||
}
|
||||
#if CDADS
|
||||
LONG vol = DSBVOLUME_MIN;
|
||||
int volume = master * left / 32768;
|
||||
if (volume < 100)
|
||||
vol = (LONG)((DSBVOLUME_MIN / 2) + (-DSBVOLUME_MIN / 2) * log (1 + (2.718281828 - 1) * (1 - volume / 100.0)));
|
||||
HRESULT hr = dsbuf->SetVolume(vol);
|
||||
if (FAILED (hr))
|
||||
write_log (_T("CDA: SetVolume(%d) failed: %s\n"), vol, DXError (hr));
|
||||
#endif
|
||||
}
|
||||
bool cda_audio::play(int bufnum)
|
||||
{
|
||||
if (!active)
|
||||
return false;
|
||||
#if CDADS
|
||||
DWORD status;
|
||||
HRESULT hr = dsbuf->GetStatus (&status);
|
||||
if (FAILED (hr)) {
|
||||
write_log (_T("CDA: GetStatus() failed: %s\n"), DXError (hr));
|
||||
return false;
|
||||
}
|
||||
if (status & DSBSTATUS_BUFFERLOST) {
|
||||
write_log (_T("CDA: bufferlost\n"));
|
||||
return false;
|
||||
}
|
||||
if ((status & (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)) != (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)) {
|
||||
dsbuf->SetCurrentPosition((1 - bufnum) * bufsize);
|
||||
dsbuf->Play(0, 0, DSBPLAY_LOOPING);
|
||||
playing = true;
|
||||
}
|
||||
PVOID ptr;
|
||||
DWORD len;
|
||||
if (SUCCEEDED(dsbuf->Lock(bufnum * bufsize, bufsize, &ptr, &len, NULL, NULL, 0))) {
|
||||
memcpy (ptr, buffers[bufnum], bufsize);
|
||||
dsbuf->Unlock(ptr, len, NULL, NULL);
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
uae_s16 *p = (uae_s16*)(buffers[bufnum]);
|
||||
if (volume[0] != 32768 || volume[1] != 32768) {
|
||||
for (int i = 0; i < num_sectors * sectorsize / 4; i++) {
|
||||
p[i * 2 + 0] = p[i * 2 + 0] * volume[0] / 32768;
|
||||
p[i * 2 + 1] = p[i * 2 + 1] * volume[1] / 32768;
|
||||
}
|
||||
}
|
||||
MMRESULT mmr = waveOutWrite (wavehandle, &whdr[bufnum], sizeof (WAVEHDR));
|
||||
if (mmr != MMSYSERR_NOERROR) {
|
||||
write_log (_T("IMAGE CDDA: waveOutWrite %d\n"), mmr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
void cda_audio::wait(int bufnum)
|
||||
{
|
||||
if (!active || !playing)
|
||||
return;
|
||||
#if CDADS
|
||||
WaitForSingleObject (notifyevent[bufnum], INFINITE);
|
||||
ResetEvent (notifyevent[bufnum]);
|
||||
#else
|
||||
while (!(whdr[bufnum].dwFlags & WHDR_DONE))
|
||||
Sleep (10);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cda_audio::isplaying(int bufnum)
|
||||
{
|
||||
if (!active || !playing)
|
||||
return false;
|
||||
return (whdr[bufnum].dwFlags & WHDR_DONE) == 0;
|
||||
}
|
||||
|
||||
|
||||
static uae_sem_t play_sem;
|
||||
|
||||
@ -356,7 +160,6 @@ static bool cdda_play2(struct cda_play *ciw, int *outpos)
|
||||
int idleframes;
|
||||
int muteframes;
|
||||
int readblocksize = 2352 + 96;
|
||||
int mode = currprefs.sound_cdaudio;
|
||||
bool restart = false;
|
||||
|
||||
while (ciw->cdda_play == 0)
|
||||
@ -368,20 +171,16 @@ static bool cdda_play2(struct cda_play *ciw, int *outpos)
|
||||
buffered = 0;
|
||||
|
||||
memset(&ciw->cas, 0, sizeof(struct cd_audio_state));
|
||||
ciw->cda = new cda_audio(CDDA_BUFFERS, 2352, 44100, mode != 0);
|
||||
ciw->cda = new cda_audio(CDDA_BUFFERS, 2352, 44100);
|
||||
|
||||
while (ciw->cdda_play > 0) {
|
||||
|
||||
if (mode) {
|
||||
while (ciw->cda_bufon[bufnum] && ciw->cdda_play > 0) {
|
||||
if (cd_audio_mode_changed) {
|
||||
restart = true;
|
||||
goto end;
|
||||
}
|
||||
sleep_millis(10);
|
||||
while (ciw->cda_bufon[bufnum] && ciw->cdda_play > 0) {
|
||||
if (cd_audio_mode_changed) {
|
||||
restart = true;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
ciw->cda->wait(bufnum);
|
||||
sleep_millis(10);
|
||||
}
|
||||
if (ciw->cdda_play <= 0)
|
||||
goto end;
|
||||
@ -518,21 +317,12 @@ static bool cdda_play2(struct cda_play *ciw, int *outpos)
|
||||
uae_sem_post(&ciw->sub_sem2);
|
||||
}
|
||||
|
||||
if (mode) {
|
||||
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->cas, ciw->cdda_volume[0], ciw->cdda_volume[1]);
|
||||
if (ciw->cda_bufon[0] == 0 && ciw->cda_bufon[1] == 0) {
|
||||
ciw->cda_bufon[bufnum] = 1;
|
||||
} else {
|
||||
ciw->cda_bufon[bufnum] = 1;
|
||||
ciw->cda->setvolume(ciw->cdda_volume[0], ciw->cdda_volume[1]);
|
||||
if (!ciw->cda->play(bufnum)) {
|
||||
ciw_cdda_setstate(ciw, AUDIO_STATUS_PLAY_ERROR, -1);
|
||||
goto end; // data track?
|
||||
}
|
||||
ioctl_next_cd_audio_buffer_callback(1 - bufnum, ciw);
|
||||
}
|
||||
audio_cda_volume(&ciw->cas, ciw->cdda_volume[0], ciw->cdda_volume[1]);
|
||||
ciw->cda_bufon[bufnum] = 1;
|
||||
|
||||
if (ciw->cdda_scan) {
|
||||
cdda_pos += ciw->cdda_scan * CDDA_BUFFERS;
|
||||
@ -572,14 +362,9 @@ static bool cdda_play2(struct cda_play *ciw, int *outpos)
|
||||
|
||||
end:
|
||||
*outpos = cdda_pos;
|
||||
if (mode) {
|
||||
ioctl_next_cd_audio_buffer_callback(-1, ciw);
|
||||
if (restart)
|
||||
audio_cda_new_buffer(&ciw->cas, NULL, -1, -1, NULL, ciw);
|
||||
} else {
|
||||
ciw->cda->wait(0);
|
||||
ciw->cda->wait(1);
|
||||
}
|
||||
ioctl_next_cd_audio_buffer_callback(-1, ciw);
|
||||
if (restart)
|
||||
audio_cda_new_buffer(&ciw->cas, NULL, -1, -1, NULL, ciw);
|
||||
|
||||
ciw->subcodevalid = false;
|
||||
cd_audio_mode_changed = false;
|
||||
|
||||
@ -12,30 +12,18 @@ class cda_audio
|
||||
{
|
||||
private:
|
||||
int bufsize;
|
||||
#ifdef _WIN32
|
||||
HWAVEOUT wavehandle;
|
||||
WAVEHDR whdr[2];
|
||||
int num_sectors;
|
||||
int sectorsize;
|
||||
int volume[2];
|
||||
LPDIRECTSOUND8 ds;
|
||||
LPDIRECTSOUNDBUFFER8 dsbuf;
|
||||
LPDIRECTSOUNDNOTIFY dsnotify;
|
||||
HANDLE notifyevent[2];
|
||||
#endif
|
||||
bool playing;
|
||||
bool active;
|
||||
|
||||
public:
|
||||
uae_u8 *buffers[2];
|
||||
|
||||
cda_audio(int num_sectors, int sectorsize, int samplerate, bool internalmode);
|
||||
cda_audio(int num_sectors, int sectorsize, int samplerate);
|
||||
~cda_audio();
|
||||
void setvolume(int left, int right);
|
||||
bool play(int bufnum);
|
||||
void wait(void);
|
||||
void wait(int bufnum);
|
||||
bool isplaying(int bufnum);
|
||||
};
|
||||
|
||||
#define CDDA_BUFFERS 14
|
||||
|
||||
@ -1074,9 +1074,7 @@
|
||||
#define IDC_FILTERKEEPASPECT 1709
|
||||
#define IDC_CS_RTC 1710
|
||||
#define IDC_FILTERKEEPAUTOSCALEASPECT 1710
|
||||
#define IDC_SOUND_CDPAULAMIX 1710
|
||||
#define IDC_CS_CIAA_TOD1 1711
|
||||
#define IDC_SOUND_CDPAULAMIX2 1711
|
||||
#define IDC_SOUND_VOLCNT 1711
|
||||
#define IDC_CS_CIAA_TOD2 1712
|
||||
#define IDC_CS_EXT 1712
|
||||
|
||||
@ -435,7 +435,6 @@ BEGIN
|
||||
CONTROL "Disabled, but emulated",IDC_SOUND1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,58,107,10
|
||||
CONTROL "Enabled",IDC_SOUND2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,72,108,10
|
||||
CONTROL "Automatic switching",IDC_SOUND_AUTO,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,13,90,108,10
|
||||
CONTROL "Include CD and FMV audio",IDC_SOUND_CDPAULAMIX,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,13,103,108,10
|
||||
CONTROL "Volume Counter mode",IDC_SOUND_VOLCNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | NOT WS_VISIBLE | WS_GROUP | WS_TABSTOP,13,123,108,10
|
||||
GROUPBOX "Volume",IDC_STATIC,139,28,255,69
|
||||
RTEXT "Master",IDC_STATIC,160,47,51,10,SS_CENTERIMAGE
|
||||
|
||||
@ -13665,7 +13665,6 @@ static void values_to_sounddlg (HWND hDlg)
|
||||
CheckRadioButton (hDlg, IDC_SOUND0, IDC_SOUND2, which_button);
|
||||
|
||||
CheckDlgButton (hDlg, IDC_SOUND_AUTO, workprefs.sound_auto);
|
||||
CheckDlgButton(hDlg, IDC_SOUND_CDPAULAMIX, workprefs.sound_cdaudio);
|
||||
CheckDlgButton(hDlg, IDC_SOUND_VOLCNT, workprefs.sound_volcnt);
|
||||
|
||||
if (workprefs.sound_maxbsiz < SOUND_BUFFER_MULTIPLIER)
|
||||
@ -13749,7 +13748,6 @@ static void values_from_sounddlg (HWND hDlg)
|
||||
: ischecked (hDlg, IDC_SOUND1) ? 1 : 3);
|
||||
|
||||
workprefs.sound_auto = ischecked (hDlg, IDC_SOUND_AUTO);
|
||||
workprefs.sound_cdaudio = ischecked(hDlg, IDC_SOUND_CDPAULAMIX);
|
||||
workprefs.sound_volcnt = ischecked(hDlg, IDC_SOUND_VOLCNT);
|
||||
|
||||
idx = xSendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_GETCURSEL, 0, 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user