-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement infrastructure for audio backends integration.
Main features of this infrastructure are: - backends compiled into the ui are selected at compile time via a HAVE_XXX_BACKEND macro / Makefile variable. This allow frontend maintainer to select which audio backend is adapted for their platform and avoid potential unwanted dependencies. - audio backend selection at runtime is done using the --audio parameter. This allow the user to choose which audio backend (among those available) to use. - it is possible to list available audio backends on the command line (--audio list).
- Loading branch information
Showing
9 changed files
with
336 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Mupen64plus-ui-console - audio_backend_factory.c * | ||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * | ||
* Copyright (C) 2015 Bobby Smiles * | ||
* * | ||
* 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. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#include "backend_factory.h" | ||
|
||
#include "backends/audio/dummy_audio_backend.h" | ||
|
||
#ifdef HAVE_SDL_AUDIO_BACKEND | ||
#include "backends/audio/sdl_audio_backend.h" | ||
#endif | ||
|
||
#include <string.h> | ||
|
||
|
||
const struct backend_factory* const audio_backend_factories[] = | ||
{ | ||
&dummy_audio_backend_factory, | ||
#ifdef HAVE_SDL_AUDIO_BACKEND | ||
&sdl_audio_backend_factory, | ||
#endif | ||
NULL /* end of array sentinel */ | ||
}; | ||
|
||
const struct backend_factory* get_backend_factory(const struct backend_factory* const* factories, const char* name) | ||
{ | ||
if (factories != NULL && name != NULL) | ||
{ | ||
while((*factories) != NULL) | ||
{ | ||
if (strcmp(name, (*factories)->name) == 0) | ||
{ | ||
return *factories; | ||
} | ||
|
||
++factories; | ||
} | ||
} | ||
|
||
return NULL; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Mupen64plus-ui-console - backend_factory.h * | ||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * | ||
* Copyright (C) 2015 Bobby Smiles * | ||
* * | ||
* 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. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#ifndef M64P_BACKEND_FACTORY_H | ||
#define M64P_BACKEND_FACTORY_H | ||
|
||
#include "m64p_types.h" | ||
|
||
struct backend_factory | ||
{ | ||
const char* name; | ||
m64p_error (*init)(struct m64p_audio_backend* backend); | ||
void (*release)(struct m64p_audio_backend* backend); | ||
}; | ||
|
||
const struct backend_factory* | ||
get_backend_factory(const struct backend_factory* const* factories, const char* name); | ||
|
||
extern const struct backend_factory* const audio_backend_factories[]; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Mupen64plus-ui-console - dummy_audio_backend.c * | ||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * | ||
* Copyright (C) 2015 Bobby Smiles * | ||
* * | ||
* 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. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#include "dummy_audio_backend.h" | ||
|
||
#include "m64p_types.h" | ||
|
||
#include <string.h> | ||
|
||
/* dummy audio backend factory implementation */ | ||
static m64p_error init(struct m64p_audio_backend* backend) | ||
{ | ||
/* set to NULL all members to trigger dummy audio backend behavior in the core */ | ||
memset(backend, 0, sizeof(*backend)); | ||
return M64ERR_SUCCESS; | ||
} | ||
|
||
static void release(struct m64p_audio_backend* backend) | ||
{ | ||
} | ||
|
||
|
||
const struct backend_factory dummy_audio_backend_factory = | ||
{ | ||
"dummy", init, release | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Mupen64plus-ui-console - dummy_audio_backend.h * | ||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * | ||
* Copyright (C) 2015 Bobby Smiles * | ||
* * | ||
* 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. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#ifndef M64P_DUMMY_AUDIO_BACKEND_H | ||
#define M64P_DUMMY_AUDIO_BACKEND_H | ||
|
||
#include "backend_factory.h" | ||
|
||
const struct backend_factory dummy_audio_backend_factory; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Mupen64plus-ui-console - sdl_audio_backend.c * | ||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * | ||
* Copyright (C) 2015 Bobby Smiles * | ||
* * | ||
* 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. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#include "sdl_audio_backend.h" | ||
|
||
#include "m64p_types.h" | ||
#include "main.h" | ||
|
||
static void set_audio_format(void* user_data, unsigned int frequency, unsigned int bits) | ||
{ | ||
/* TODO implement set audio format */ | ||
DebugMessage(M64MSG_WARNING, "SDL audio backend set format: %dHz %d bits", frequency, bits); | ||
|
||
} | ||
|
||
static void push_audio_samples(void* user_data, const void* buffer, size_t size) | ||
{ | ||
/* TODO implement push audio samples */ | ||
DebugMessage(M64MSG_WARNING, "SDL audio backend push samples: @%p 0x%x bytes", buffer, size); | ||
} | ||
|
||
static m64p_error init(struct m64p_audio_backend* backend) | ||
{ | ||
/* TODO open SDL audio subsystem */ | ||
|
||
/* fill backend structure */ | ||
backend->user_data = NULL; | ||
backend->set_audio_format = set_audio_format; | ||
backend->push_audio_samples = push_audio_samples; | ||
|
||
return M64ERR_SUCCESS; | ||
} | ||
|
||
static void release(struct m64p_audio_backend* backend) | ||
{ | ||
/* TODO close SDL audio subsystem */ | ||
} | ||
|
||
/* SDL audio backend descriptor */ | ||
const struct backend_factory sdl_audio_backend_factory = { "sdl", init, release }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Mupen64plus-ui-console - sdl_audio_backend.h * | ||
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * | ||
* Copyright (C) 2015 Bobby Smiles * | ||
* * | ||
* 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. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
#ifndef M64P_AUDIO_BACKENDS_SDL_AUDIO_BACKEND_H | ||
#define M64P_AUDIO_BACKENDS_SDL_AUDIO_BACKEND_H | ||
|
||
#include "backend_factory.h" | ||
|
||
const struct backend_factory sdl_audio_backend_factory; | ||
|
||
#endif |
Oops, something went wrong.