Added IEnvironment wrappers. Not tested yet.

This commit is contained in:
casey langen 2020-01-27 09:49:40 -08:00
parent b8d0f5a726
commit 6fd4e7d7c0
5 changed files with 141 additions and 2 deletions

View File

@ -389,6 +389,10 @@ namespace musik { namespace core { namespace plugin {
});
}
IEnvironment& Environment() {
return environment;
}
void Deinit() {
/* preferences */
Preferences::SavePluginPreferences();

View File

@ -35,6 +35,7 @@
#pragma once
#include <core/library/ILibrary.h>
#include <core/sdk/IEnvironment.h>
#include <core/sdk/IPlaybackService.h>
#include <core/runtime/IMessage.h>
@ -45,6 +46,8 @@ namespace musik { namespace core { namespace plugin {
musik::core::sdk::IPlaybackService* playback,
musik::core::ILibraryPtr library);
musik::core::sdk::IEnvironment& Environment();
void Deinit();
} } }

View File

@ -35,6 +35,7 @@
#include "musikcore_c.h"
#include <core/debug.h>
#include <core/plugin/Plugins.h>
#include <core/sdk/IResource.h>
#include <core/sdk/IValue.h>
@ -60,6 +61,8 @@
using namespace musik;
using namespace musik::core::sdk;
#define ENV musik::core::plugin::Environment()
#define RESOURCE(x) reinterpret_cast<IResource*>(x.opaque)
#define VALUE(x) reinterpret_cast<IValue*>(x.opaque)
#define MAP(x) reinterpret_cast<IMap*>(x.opaque)
@ -851,3 +854,98 @@ mcsdk_export void mcsdk_debug_warning(const char* tag, const char* message) {
mcsdk_export void mcsdk_debug_error(const char* tag, const char* message) {
debug::error(tag, message);
}
/*
*
* IEnvironment (TODO)
*
*/
mcsdk_export size_t mcsdk_env_get_path(mcsdk_path_type type, char* dst, int size) {
return ENV.GetPath((PathType) type, dst, size);
}
mcsdk_export mcsdk_data_stream mcsdk_env_open_data_stream(const char* uri, mcsdk_stream_open_flags flags) {
return mcsdk_data_stream { ENV.GetDataStream(uri, (OpenFlags) flags) };
}
mcsdk_export mcsdk_decoder mcsdk_env_open_decoder(mcsdk_data_stream stream) {
return mcsdk_decoder { ENV.GetDecoder(DATASTREAM(stream)) };
}
mcsdk_export mcsdk_encoder mcsdk_env_open_encoder(const char* type) {
return mcsdk_encoder { ENV.GetEncoder(type) };
}
mcsdk_export mcsdk_audio_buffer mcsdk_env_create_audio_buffer(size_t samples, size_t rate, size_t channels) {
return mcsdk_audio_buffer { ENV.GetBuffer(samples, rate, channels) };
}
mcsdk_export mcsdk_prefs mcsdk_env_open_preferences(const char* name) {
return mcsdk_prefs { ENV.GetPreferences(name) };
}
mcsdk_export size_t mcsdk_env_get_output_count() {
return ENV.GetOutputCount();
}
mcsdk_export mcsdk_output mcsdk_env_get_output_at_index(size_t index) {
return mcsdk_output { ENV.GetOutputAtIndex(index) };
}
mcsdk_export mcsdk_output mcsdk_env_get_output_with_name(const char* name) {
return mcsdk_output { ENV.GetOutputWithName(name) };
}
mcsdk_export mcsdk_replay_gain_mode mcsdk_env_get_replay_gain_mode() {
return (mcsdk_replay_gain_mode) ENV.GetReplayGainMode();
}
mcsdk_export void mcsdk_env_set_replay_gain_mode(mcsdk_replay_gain_mode mode) {
ENV.SetReplayGainMode((ReplayGainMode) mode);
}
mcsdk_export float mcsdk_env_get_preamp_gain() {
return ENV.GetPreampGain();
}
mcsdk_export void mcsdk_env_set_preamp_gain(float gain) {
ENV.SetPreampGain(gain);
}
mcsdk_export bool mcsdk_env_is_equalizer_enabled() {
return ENV.GetEqualizerEnabled();
}
mcsdk_export void mcsdk_env_set_equalizer_enabled(bool enabled) {
return ENV.SetEqualizerEnabled(enabled);
}
mcsdk_export bool mcsdk_env_get_equalizer_band_values(double target[], size_t count) {
return ENV.GetEqualizerBandValues(target, count);
}
mcsdk_export bool mcsdk_env_set_equalizer_band_values(double values[], size_t count) {
return ENV.SetEqualizerBandValues(values, count);
}
mcsdk_export void mcsdk_env_reload_playback_output() {
ENV.ReloadPlaybackOutput();
}
mcsdk_export void mcsdk_env_set_default_output(mcsdk_output output) {
ENV.SetDefaultOutput(OUTPUT(output));
}
mcsdk_export mcsdk_output mcsdk_env_get_default_output() {
return mcsdk_output { ENV.GetDefaultOutput() };
}
mcsdk_export mcsdk_transport_type mcsdk_env_get_transport_type() {
return (mcsdk_transport_type) ENV.GetTransportType();
}
mcsdk_export void mcsdk_env_set_transport_type(mcsdk_transport_type type) {
ENV.SetTransportType((TransportType) type);
}

View File

@ -549,4 +549,33 @@ mcsdk_export void mcsdk_debug_info(const char* tag, const char* message);
mcsdk_export void mcsdk_debug_warning(const char* tag, const char* message);
mcsdk_export void mcsdk_debug_error(const char* tag, const char* message);
/*
*
* IEnvironment
*
*/
mcsdk_export size_t mcsdk_env_get_path(mcsdk_path_type type, char* dst, int size);
mcsdk_export mcsdk_data_stream mcsdk_env_open_data_stream(const char* uri, mcsdk_stream_open_flags flags);
mcsdk_export mcsdk_decoder mcsdk_env_open_decoder(mcsdk_data_stream stream);
mcsdk_export mcsdk_encoder mcsdk_env_open_encoder(const char* type) ;
mcsdk_export mcsdk_audio_buffer mcsdk_env_create_data_buffer(size_t samples, size_t rate, size_t channels);
mcsdk_export mcsdk_prefs mcsdk_env_open_preferences(const char* name);
mcsdk_export size_t mcsdk_env_get_output_count();
mcsdk_export mcsdk_output mcsdk_env_get_output_at_index(size_t index);
mcsdk_export mcsdk_output mcsdk_env_get_output_with_name(const char* name);
mcsdk_export mcsdk_replay_gain_mode mcsdk_env_get_replay_gain_mode();
mcsdk_export void mcsdk_env_set_replay_gain_mode(mcsdk_replay_gain_mode mode);
mcsdk_export float mcsdk_env_get_preamp_gain();
mcsdk_export void mcsdk_env_set_preamp_gain(float gain);
mcsdk_export bool mcsdk_env_is_equalizer_enabled();
mcsdk_export void mcsdk_env_set_equalizer_enabled(bool enabled);
mcsdk_export bool mcsdk_env_get_equalizer_band_values(double target[], size_t count);
mcsdk_export bool mcsdk_env_set_equalizer_band_values(double values[], size_t count);
mcsdk_export void mcsdk_env_reload_playback_output();
mcsdk_export void mcsdk_env_set_default_output(mcsdk_output output);
mcsdk_export mcsdk_output mcsdk_env_get_default_output();
mcsdk_export mcsdk_transport_type mcsdk_env_get_transport_type();
mcsdk_export void mcsdk_env_set_transport_type(mcsdk_transport_type type);
#endif

View File

@ -24,8 +24,13 @@ int main(int argc, char** argv) {
context->metadata, "a day in the life", mcsdk_no_limit, mcsdk_no_offset);
mcsdk_svc_playback_play(context->playback, tl, 0);
mcsdk_track_list_release(tl);
usleep(1000000 * 5);
printf("playing for 5 seconds...");
for (int i = 0; i < 5; i++) {
usleep(1000000);
printf(" %d\n", i + 1);
}
printf("done playing, shutting down...\n");
mcsdk_context_release(&context);
printf("released\n");
printf("dead\n");
return 0;
}