split i_oalmusic.h into two files, do not link OPL with OpenAL

This commit is contained in:
Roman Fomin 2023-04-29 10:19:42 +07:00
parent 6e9bcda879
commit 4463f86dea
10 changed files with 44 additions and 19 deletions

View File

@ -12,4 +12,4 @@ target_woof_settings(opl)
target_include_directories(opl
INTERFACE "."
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../" "../src/")
target_link_libraries(opl SDL2::SDL2 OpenAL::OpenAL)
target_link_libraries(opl SDL2::SDL2)

View File

@ -147,7 +147,7 @@ static void FillBuffer(uint8_t *buffer, unsigned int nsamples)
// Callback function to fill a new sound buffer:
static uint32_t OPL_Callback(byte *buffer, uint32_t buffer_samples)
static uint32_t OPL_Callback(uint8_t *buffer, uint32_t buffer_samples)
{
unsigned int filled;

View File

@ -34,6 +34,7 @@ set(WOOF_SOURCES
i_glob.c i_glob.h
i_main.c
i_oalmusic.c i_oalmusic.h
i_oalstream.h
i_oplmusic.c
i_sndfile.c i_sndfile.h
i_sound.c i_sound.h

View File

@ -50,7 +50,7 @@ static fluid_player_t *player = NULL;
static char **soundfonts;
static int soundfonts_num;
static uint32_t FL_Callback(byte *buffer, uint32_t buffer_samples)
static uint32_t FL_Callback(uint8_t *buffer, uint32_t buffer_samples)
{
int result;

View File

@ -15,6 +15,7 @@
//
#include "i_oalmusic.h"
#include "i_oalstream.h"
#include <stdlib.h>
#include <string.h>

View File

@ -17,19 +17,9 @@
#ifndef __I_OALMUSIC__
#define __I_OALMUSIC__
#include "doomtype.h"
#include "al.h"
#include <stdint.h>
typedef struct
{
boolean (*I_OpenStream)(void *data, ALsizei size, ALenum *format,
ALsizei *freq, ALsizei *frame_size);
uint32_t (*I_FillStream)(byte *data, uint32_t frames);
void (*I_RestartStream)(void);
void (*I_CloseStream)(void);
} stream_module_t;
typedef uint32_t (*callback_func_t)(byte *buffer, uint32_t buffer_samples);
typedef uint32_t (*callback_func_t)(uint8_t *buffer, uint32_t buffer_samples);
void I_OAL_HookMusic(callback_func_t callback_func);
void I_OAL_SetGain(float gain);

32
src/i_oalstream.h Normal file
View File

@ -0,0 +1,32 @@
//
// Copyright(C) 2023 Roman Fomin
//
// 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.
//
// DESCRIPTION:
//
#ifndef __I_OALSTREAM__
#define __I_OALSTREAM__
#include "doomtype.h"
#include "al.h"
typedef struct
{
boolean (*I_OpenStream)(void *data, ALsizei size, ALenum *format,
ALsizei *freq, ALsizei *frame_size);
uint32_t (*I_FillStream)(byte *data, uint32_t frames);
void (*I_RestartStream)(void);
void (*I_CloseStream)(void);
} stream_module_t;
#endif

View File

@ -24,7 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include "i_oalmusic.h"
#include "i_oalstream.h"
#include "m_swap.h"
#include "memio.h"
@ -434,6 +434,7 @@ static boolean OpenFile(sndfile_t *file, void *data, sf_count_t size)
if (!file->sndfile)
{
printf("SndFile: %s\n", sf_strerror(file->sndfile));
return false;
}
@ -512,7 +513,7 @@ static boolean OpenFile(sndfile_t *file, void *data, sf_count_t size)
if (format == AL_NONE)
{
fprintf(stderr, "Unsupported channel count: %d\n", file->sfinfo.channels);
fprintf(stderr, "SndFile: Unsupported channel count %d.\n", file->sfinfo.channels);
CloseFile(file);
return false;
}

View File

@ -815,7 +815,7 @@ void *I_RegisterSong(void *data, int size)
midi_player_module->I_ShutdownMusic();
}
// Try to open file with libsndfile and libmodplug.
// Try to open file with SndFile or XMP.
active_module = &music_oal_module;
}

View File

@ -17,8 +17,8 @@
#include <xmp.h>
#include "doomtype.h"
#include "i_oalstream.h"
#include "i_sound.h"
#include "i_oalmusic.h"
static xmp_context context;