2020-05-08 20:32:29 +00:00
|
|
|
/*
|
|
|
|
DingusPPC - The Experimental PowerPC Macintosh emulator
|
2023-04-23 19:38:48 +00:00
|
|
|
Copyright (C) 2018-23 divingkatae and maximum
|
2020-05-08 20:32:29 +00:00
|
|
|
(theweirdo) spatium
|
|
|
|
|
|
|
|
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
|
|
|
|
|
|
|
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 3 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-10-23 18:17:47 +00:00
|
|
|
#include <devices/common/dmacore.h>
|
|
|
|
#include <devices/sound/soundserver.h>
|
|
|
|
#include <endianswap.h>
|
|
|
|
|
2021-09-15 22:46:38 +00:00
|
|
|
#include <loguru.hpp>
|
2020-05-15 00:36:40 +00:00
|
|
|
#include <cubeb/cubeb.h>
|
2020-05-18 00:51:56 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <objbase.h>
|
|
|
|
#endif
|
2020-05-08 20:32:29 +00:00
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
enum {
|
|
|
|
SND_SERVER_DOWN = 0,
|
|
|
|
SND_API_READY,
|
|
|
|
SND_SERVER_UP,
|
|
|
|
SND_STREAM_OPENED,
|
|
|
|
SND_STREAM_CLOSED
|
|
|
|
};
|
|
|
|
|
|
|
|
class SoundServer::Impl {
|
|
|
|
public:
|
|
|
|
int status; /* server status */
|
|
|
|
cubeb *cubeb_ctx;
|
|
|
|
|
|
|
|
cubeb_stream *out_stream;
|
|
|
|
};
|
|
|
|
|
|
|
|
SoundServer::SoundServer(): impl(std::make_unique<Impl>())
|
|
|
|
{
|
|
|
|
supports_types(HWCompType::SND_SERVER);
|
|
|
|
this->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
SoundServer::~SoundServer()
|
|
|
|
{
|
|
|
|
this->shutdown();
|
|
|
|
}
|
|
|
|
|
2020-05-15 00:36:40 +00:00
|
|
|
int SoundServer::start()
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
2020-05-18 00:51:56 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
CoInitialize(nullptr);
|
|
|
|
#endif
|
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
impl->status = SND_SERVER_DOWN;
|
2020-05-15 00:36:40 +00:00
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
res = cubeb_init(&impl->cubeb_ctx, "Dingus sound server", NULL);
|
2020-05-15 00:36:40 +00:00
|
|
|
if (res != CUBEB_OK) {
|
|
|
|
LOG_F(ERROR, "Could not initialize Cubeb library");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
LOG_F(INFO, "Connected to backend: %s", cubeb_get_backend_id(impl->cubeb_ctx));
|
2020-05-15 00:36:40 +00:00
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
impl->status = SND_API_READY;
|
2020-05-15 00:36:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SoundServer::shutdown()
|
|
|
|
{
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
switch (impl->status) {
|
2022-07-17 03:50:32 +00:00
|
|
|
case SND_STREAM_OPENED:
|
|
|
|
close_out_stream();
|
|
|
|
/* fall through */
|
2023-10-18 14:18:54 +00:00
|
|
|
case SND_STREAM_CLOSED:
|
|
|
|
/* fall through */
|
2020-05-15 00:36:40 +00:00
|
|
|
case SND_SERVER_UP:
|
|
|
|
/* fall through */
|
|
|
|
case SND_API_READY:
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
cubeb_destroy(impl->cubeb_ctx);
|
2020-05-15 00:36:40 +00:00
|
|
|
}
|
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
impl->status = SND_SERVER_DOWN;
|
2020-05-15 00:36:40 +00:00
|
|
|
|
|
|
|
LOG_F(INFO, "Sound Server shut down.");
|
|
|
|
}
|
|
|
|
|
2021-10-04 21:46:19 +00:00
|
|
|
long sound_out_callback(cubeb_stream *stream, void *user_data,
|
|
|
|
void const *input_buffer, void *output_buffer,
|
|
|
|
long req_frames)
|
|
|
|
{
|
|
|
|
uint8_t *p_in;
|
|
|
|
int16_t* in_buf, * out_buf;
|
|
|
|
uint32_t got_len;
|
|
|
|
long frames, out_frames;
|
|
|
|
DmaOutChannel *dma_ch = static_cast<DmaOutChannel*>(user_data); /* C API baby! */
|
|
|
|
|
|
|
|
if (!dma_ch->is_active()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
out_buf = (int16_t*)output_buffer;
|
|
|
|
|
|
|
|
out_frames = 0;
|
|
|
|
|
|
|
|
while (req_frames > 0) {
|
2022-12-21 11:20:39 +00:00
|
|
|
if (!dma_ch->pull_data((uint32_t)req_frames << 2, &got_len, &p_in)) {
|
2021-10-04 21:46:19 +00:00
|
|
|
frames = got_len >> 2;
|
|
|
|
|
|
|
|
in_buf = (int16_t*)p_in;
|
|
|
|
|
2022-12-21 11:20:39 +00:00
|
|
|
for (int i = (int)frames; i > 0; i--) {
|
2021-10-04 21:46:19 +00:00
|
|
|
out_buf[0] = BYTESWAP_16(in_buf[0]);
|
|
|
|
out_buf[1] = BYTESWAP_16(in_buf[1]);
|
|
|
|
in_buf += 2;
|
|
|
|
out_buf += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
req_frames -= frames;
|
|
|
|
out_frames += frames;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return out_frames;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void status_callback(cubeb_stream *stream, void *user_data, cubeb_state state)
|
|
|
|
{
|
|
|
|
LOG_F(9, "Cubeb status callback fired, status = %d", state);
|
|
|
|
}
|
2020-05-15 00:36:40 +00:00
|
|
|
|
2021-10-04 21:46:19 +00:00
|
|
|
int SoundServer::open_out_stream(uint32_t sample_rate, void *user_data)
|
2020-05-15 00:36:40 +00:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
uint32_t latency_frames;
|
|
|
|
cubeb_stream_params params;
|
|
|
|
|
|
|
|
params.format = CUBEB_SAMPLE_S16NE;
|
|
|
|
params.rate = sample_rate;
|
|
|
|
params.channels = 2;
|
|
|
|
params.layout = CUBEB_LAYOUT_STEREO;
|
|
|
|
params.prefs = CUBEB_STREAM_PREF_NONE;
|
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
res = cubeb_get_min_latency(impl->cubeb_ctx, ¶ms, &latency_frames);
|
2020-05-15 00:36:40 +00:00
|
|
|
if (res != CUBEB_OK) {
|
|
|
|
LOG_F(ERROR, "Could not get minimum latency, error: %d", res);
|
|
|
|
return -1;
|
|
|
|
} else {
|
2023-04-23 19:38:48 +00:00
|
|
|
LOG_F(9, "Minimum sound latency: %d frames", latency_frames);
|
2020-05-15 00:36:40 +00:00
|
|
|
}
|
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
res = cubeb_stream_init(impl->cubeb_ctx, &impl->out_stream, "SndOut stream",
|
2020-05-15 00:36:40 +00:00
|
|
|
NULL, NULL, NULL, ¶ms, latency_frames,
|
2021-10-04 21:46:19 +00:00
|
|
|
sound_out_callback, status_callback, user_data);
|
2020-05-15 00:36:40 +00:00
|
|
|
if (res != CUBEB_OK) {
|
|
|
|
LOG_F(ERROR, "Could not open sound output stream, error: %d", res);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-04-23 19:38:48 +00:00
|
|
|
LOG_F(9, "Sound output stream opened.");
|
2020-05-15 00:36:40 +00:00
|
|
|
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
impl->status = SND_STREAM_OPENED;
|
2022-07-17 03:50:32 +00:00
|
|
|
|
2020-05-15 00:36:40 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SoundServer::start_out_stream()
|
|
|
|
{
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
return cubeb_stream_start(impl->out_stream);
|
2020-05-15 00:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SoundServer::close_out_stream()
|
|
|
|
{
|
Make Emscripten build not depend on SDL2 or cubeb
While Emscripten has an SDL compabtility layer, it assumes that the
code is executing in the main browser process (and thus has access to
them DOM). The Infinite Mac project runs emulators in a worker thread
(for better performance) and has a custom API for the display, sound,
input, etc. Similarly, it does not need the cross-platform sound support
from cubeb, there there is a sound API as well.
This commit makes SDL (*_sdl.cpp) and cubeb-based (*_cubeb.cpp) code be
skipped when targeting Emscripten, and instead *_js.cpp files are used
instead (this is the cross-platform convention used by Chromium[^1], and
could be extended for other targets).
For hostevents.cpp and soundserver.cpp the entire file was replaced,
whereas for videoctrl.cpp there was enough shared logic that it was
kept, and the platform-specific bits were moved behind a Display class
that can have per-platform implementations. For cases where we need
additional private fields in the platform-specific classes, we use
a PIMPL pattern.
The *_js.cpp files with implementations are not included in this
commit, since they are closely tied to the Infinite Mac project, and
will live in its fork of DingusPPC.
[^1]: https://www.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development/
2023-09-04 00:59:35 +00:00
|
|
|
cubeb_stream_stop(impl->out_stream);
|
|
|
|
cubeb_stream_destroy(impl->out_stream);
|
|
|
|
impl->status = SND_STREAM_CLOSED;
|
2023-04-23 19:38:48 +00:00
|
|
|
LOG_F(9, "Sound output stream closed.");
|
2020-05-15 00:36:40 +00:00
|
|
|
}
|