-
Notifications
You must be signed in to change notification settings - Fork 266
[WIP / RFC] New audio backend API #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bsmiles32
wants to merge
2
commits into
mupen64plus:master
Choose a base branch
from
bsmiles32:new_audio_api
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,83 @@ | ||
| /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
| * Mupen64plus - 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 "audio_backend.h" | ||
|
|
||
| #include "api/m64p_types.h" | ||
| #include "ai/ai_controller.h" | ||
|
|
||
| #include <string.h> | ||
|
|
||
| extern struct ai_controller g_ai; | ||
|
|
||
|
|
||
| /* Dummy Audio Backend object */ | ||
| static void set_audio_format_dummy(void* user_data, unsigned int frequency, unsigned int bits) | ||
| { | ||
| } | ||
|
|
||
| static void push_audio_samples_dummy(void* user_data, const void* buffer, size_t size) | ||
| { | ||
| } | ||
|
|
||
| const struct m64p_audio_backend AUDIO_BACKEND_DUMMY = | ||
| { | ||
| NULL, | ||
| set_audio_format_dummy, | ||
| push_audio_samples_dummy | ||
| }; | ||
|
|
||
|
|
||
| /* Global function for use by frontend.c */ | ||
| m64p_error SetAudioInterfaceBackend(unsigned int version, const struct m64p_audio_backend* backend) | ||
| { | ||
| /* check input data */ | ||
| if (backend == NULL) | ||
| return M64ERR_INPUT_ASSERT; | ||
|
|
||
| /* check backend version */ | ||
| if (version != M64P_AUDIO_BACKEND_VERSION) | ||
| return M64ERR_INCOMPATIBLE; | ||
|
|
||
| /* if any of the function pointers are NULL, use the dummy audio backend */ | ||
| if (backend->set_audio_format == NULL || | ||
| backend->push_audio_samples == NULL) | ||
| { | ||
| backend = &AUDIO_BACKEND_DUMMY; | ||
| } | ||
|
|
||
| /* otherwise use the user provided backend */ | ||
| memcpy(&g_ai.backend, backend, sizeof(struct m64p_audio_backend)); | ||
|
|
||
| return M64ERR_SUCCESS; | ||
| } | ||
|
|
||
|
|
||
| /* Thin wrappers to ease usage of backend callbacks - used by ai_controller.c */ | ||
| void set_audio_format(struct m64p_audio_backend* backend, unsigned int frequency, unsigned int bits) | ||
| { | ||
| backend->set_audio_format(backend->user_data, frequency, bits); | ||
| } | ||
|
|
||
| void push_audio_samples(struct m64p_audio_backend* backend, const void* buffer, size_t size) | ||
| { | ||
| backend->push_audio_samples(backend->user_data, buffer, size); | ||
| } |
This file contains hidden or 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,43 @@ | ||
| /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
| * Mupen64plus - 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. * | ||
| * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
|
||
| /* This file contains the definitions for the audio backend functions which | ||
| * will be called from other Core modules. | ||
| */ | ||
|
|
||
| #if !defined(M64P_API_AUDIO_BACKEND_H) | ||
| #define M64P_API_AUDIO_BACKEND_H | ||
|
|
||
| #include "m64p_types.h" | ||
|
|
||
| #include <stddef.h> | ||
|
|
||
| /* Dummy Audio Backend object */ | ||
| extern const struct m64p_audio_backend AUDIO_BACKEND_DUMMY; | ||
|
|
||
| /* Global function for use by frontend.c */ | ||
| m64p_error SetAudioInterfaceBackend(unsigned int version, const struct m64p_audio_backend* backend); | ||
|
|
||
| /* Thin wrappers to ease usage of backend callbacks - used by ai_controller.c */ | ||
| void set_audio_format(struct m64p_audio_backend* backend, unsigned int frequency, unsigned int bits); | ||
| void push_audio_samples(struct m64p_audio_backend* backend, const void* buffer, size_t size); | ||
|
|
||
| #endif /* M64P_API_AUDIO_BACKEND_H */ |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it silly to have a distinct folder
pluginandbackend? As the new backend approach is supposed to take away the concept of plugin, I just ask.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the audio_backend_compat in the plugin folder because it is related to plugins, and will also go away when plugins are dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Sorry for the bad idea. ^^'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry about asking questions even if you think they are "bad idea".
I'm am not perfect and I make mistake very often, so I'm glad someone look at my work and question it. That way if I have overlooked something I can correct it. Otherwise if it's not a mistake on my part, I can justify why I did it that way, so it helps other to understand my work.