Skip to content

Commit 6a4815f

Browse files
fixme: sound stuff
1 parent f8a3ccd commit 6a4815f

2 files changed

Lines changed: 3 additions & 62 deletions

File tree

code/sound/ds.cpp

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef struct audio_context {
5151
size_t render_buffer_size;
5252

5353
int frame_size;
54-
} oal_info;
54+
} audio_context;
5555

5656
static audio_context Audio{};
5757

@@ -525,37 +525,6 @@ static bool ds_init_loopback(std::string &Device)
525525
return true;
526526
}
527527

528-
static bool ds_init_physical(std::string &Device, const int sample_rate)
529-
{
530-
ALCint attrList[] = { ALC_FREQUENCY, sample_rate, 0 };
531-
532-
if ( !openal_init_device(&Device, nullptr) ) {
533-
mprintf(("\n ERROR: Unable to find suitable playback device!\n\n"));
534-
return false;
535-
}
536-
537-
Audio.device = alcOpenDevice(reinterpret_cast<const ALCchar*>(Device.c_str()));
538-
539-
if (Audio.device == nullptr) {
540-
mprintf((" Failed to open playback_device (%s) returning error (%s)\n", Device.c_str(), openal_error_string(1)));
541-
return false;
542-
}
543-
544-
Audio.context = alcCreateContext(Audio.device, attrList);
545-
546-
if (Audio.context == nullptr) {
547-
mprintf((" Failed to create context for playback_device (%s) with attrList = { 0x%x, %d, %d } returning error (%s)\n",
548-
Device.c_str(), attrList[0], attrList[1], attrList[2], openal_error_string(1)));
549-
return false;
550-
}
551-
552-
alcMakeContextCurrent(Audio.context);
553-
554-
alcGetError(Audio.device);
555-
556-
return true;
557-
}
558-
559528
/**
560529
* Sound initialisation
561530
* @return -1 if init failed, 0 if init success
@@ -595,14 +564,9 @@ int ds_init()
595564

596565
if ( !ds_init_loopback(playback_device) ) {
597566
ds_close();
567+
mprintf(("... OpenAL failed to initialize!\n"));
598568

599-
if ( !ds_init_physical(playback_device, sample_rate) ) {
600-
ds_close();
601-
602-
mprintf(("... OpenAL failed to initialize!\n"));
603-
604-
return -1;
605-
}
569+
return -1;
606570
}
607571

608572
mprintf((" OpenAL Vendor : %s\n", alGetString(AL_VENDOR)));

code/sound/openal.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -567,22 +567,6 @@ bool openal_init_device(SCP_string *playback, SCP_string *capture)
567567
}
568568

569569
static void get_version_info(OpenALInformation* info) {
570-
// initialize default setup first, for version check...
571-
ALCdevice *device = alcOpenDevice(NULL);
572-
573-
if (device == NULL) {
574-
return;
575-
}
576-
577-
ALCcontext *context = alcCreateContext(device, NULL);
578-
579-
if (context == NULL) {
580-
alcCloseDevice(device);
581-
return;
582-
}
583-
584-
alcMakeContextCurrent(context);
585-
586570
// version check (for 1.0 or 1.1)
587571
ALCint AL_minor_version = 0;
588572
ALCint AL_major_version = 0;
@@ -591,13 +575,6 @@ static void get_version_info(OpenALInformation* info) {
591575

592576
info->version_major = static_cast<uint32_t>(AL_major_version);
593577
info->version_minor = static_cast<uint32_t>(AL_minor_version);
594-
595-
alcGetError(device);
596-
597-
// close default device
598-
alcMakeContextCurrent(NULL);
599-
alcDestroyContext(context);
600-
alcCloseDevice(device);
601578
}
602579

603580
static bool device_supports_efx(const char* device_name) {

0 commit comments

Comments
 (0)