diff --git a/BasiliskII/src/SDL/audio_sdl.cpp b/BasiliskII/src/SDL/audio_sdl.cpp index 6bff36c3..835b888c 100644 --- a/BasiliskII/src/SDL/audio_sdl.cpp +++ b/BasiliskII/src/SDL/audio_sdl.cpp @@ -252,7 +252,7 @@ static void stream_func(void *arg, uint8 *stream, int stream_len) silence: memset(stream, silence_byte, stream_len); } #if defined(BINCUE) - MixAudio_bincue(stream, stream_len); + MixAudio_bincue(stream, stream_len, audio_volume); #endif } diff --git a/BasiliskII/src/Unix/bincue_unix.cpp b/BasiliskII/src/Unix/bincue_unix.cpp index 63ed2e73..ac223e50 100644 --- a/BasiliskII/src/Unix/bincue_unix.cpp +++ b/BasiliskII/src/Unix/bincue_unix.cpp @@ -115,6 +115,9 @@ typedef struct { #ifdef OSX_CORE_AUDIO OSXsoundOutput soundoutput; #endif +#ifdef USE_SDL_AUDIO + SDL_AudioStream *stream; +#endif } CDPlayer; // Minute,Second,Frame data type @@ -810,25 +813,49 @@ static uint8 *fill_buffer(int stream_len) #ifdef USE_SDL_AUDIO -void MixAudio_bincue(uint8 *stream, int stream_len) +void MixAudio_bincue(uint8 *stream, int stream_len, int volume) { +// if (audio_enabled && (player.audiostatus == CDROM_AUDIO_PLAY)) { +// uint8 *buf = fill_buffer(stream_len); +// if (buf) +// SDL_MixAudio(stream, buf, stream_len, volume); +// } if (audio_enabled && (player.audiostatus == CDROM_AUDIO_PLAY)) { uint8 *buf = fill_buffer(stream_len); if (buf) - SDL_MixAudio(stream, buf, stream_len, SDL_MIX_MAXVOLUME); + SDL_AudioStreamPut(player.stream, buf, stream_len); + int avail = SDL_AudioStreamAvailable(player.stream); + if (avail >= stream_len) { + uint8 converted[stream_len]; + SDL_AudioStreamGet(player.stream, converted, stream_len); + SDL_MixAudio(stream, converted, stream_len, volume); + } } } void OpenAudio_bincue(int freq, int format, int channels, uint8 silence) { - if (freq == 44100 && format == AUDIO_S16MSB && channels == 2) { +// audio_enabled = true; +// silence_byte = silence; + // audio stream handles converting cd audio to destination output + player.stream = SDL_NewAudioStream(AUDIO_S16LSB, 2, 44100, format, channels, freq); + if (player.stream == NULL) { + D(bug("Failed to open CD player audio stream using SDL!")); + } + else { audio_enabled = true; silence_byte = silence; } - else { - D(bug("unexpected frequency %d , format %d, or channels %d\n", - freq, format, channels)); - } +// audio_enabled = true; +// silence_byte = silence; +// if (freq == 44100 && format == AUDIO_S16MSB && channels == 2) { +// audio_enabled = true; +// silence_byte = silence; +// } +// else { +// D(bug("unexpected frequency %d , format %d, or channels %d\n", +// freq, format, channels)); +// } } #endif diff --git a/BasiliskII/src/Unix/bincue_unix.h b/BasiliskII/src/Unix/bincue_unix.h index dbf5d8b5..3e4722a3 100644 --- a/BasiliskII/src/Unix/bincue_unix.h +++ b/BasiliskII/src/Unix/bincue_unix.h @@ -37,7 +37,7 @@ extern bool CDStop_bincue(void *); #ifdef USE_SDL_AUDIO extern void OpenAudio_bincue(int, int, int, uint8); -extern void MixAudio_bincue(uint8 *, int); +extern void MixAudio_bincue(uint8 *, int, int); #endif #endif diff --git a/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj b/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj index 0c710e54..dc5de2ad 100755 --- a/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj +++ b/SheepShaver/src/MacOSX/SheepShaver_Xcode8.xcodeproj/project.pbxproj @@ -1291,7 +1291,6 @@ _THREAD_SAFE, _REENTRANT, "BINCUE=1", - "OSX_CORE_AUDIO=1", "USE_SDL_AUDIO=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; @@ -1354,7 +1353,6 @@ _THREAD_SAFE, _REENTRANT, "BINCUE=1", - "OSX_CORE_AUDIO=1", "USE_SDL_AUDIO=1", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO;