2016-06-18 14:46:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* audio_stream_mpc.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:45:00 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2016-06-18 14:46:12 +02:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "audio_stream_mpc.h"
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
Error AudioStreamPlaybackMPC::_open_file() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (f) {
|
|
|
|
memdelete(f);
|
2017-03-19 00:36:26 +01:00
|
|
|
f = NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
Error err;
|
2015-01-03 20:52:37 +01:00
|
|
|
//printf("mpc open file %ls\n", file.c_str());
|
2017-03-19 00:36:26 +01:00
|
|
|
f = FileAccess::open(file, FileAccess::READ, &err);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (err) {
|
2017-03-19 00:36:26 +01:00
|
|
|
f = NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2015-01-03 20:52:37 +01:00
|
|
|
//printf("file size is %i\n", f->get_len());
|
|
|
|
//f->seek_end(0);
|
2017-03-19 00:36:26 +01:00
|
|
|
streamlen = f->get_len();
|
2015-01-03 20:52:37 +01:00
|
|
|
//f->seek(0);
|
2017-03-19 00:36:26 +01:00
|
|
|
if (streamlen <= 0) {
|
2014-02-10 02:10:30 +01:00
|
|
|
memdelete(f);
|
2017-03-19 00:36:26 +01:00
|
|
|
f = NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
data_ofs = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
if (preload) {
|
|
|
|
|
|
|
|
data.resize(streamlen);
|
|
|
|
DVector<uint8_t>::Write w = data.write();
|
2017-03-19 00:36:26 +01:00
|
|
|
f->get_buffer(&w[0], streamlen);
|
2014-02-10 02:10:30 +01:00
|
|
|
memdelete(f);
|
2017-03-19 00:36:26 +01:00
|
|
|
f = NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
void AudioStreamPlaybackMPC::_close_file() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (f) {
|
|
|
|
memdelete(f);
|
2017-03-19 00:36:26 +01:00
|
|
|
f = NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
data.resize(0);
|
2017-03-19 00:36:26 +01:00
|
|
|
streamlen = 0;
|
|
|
|
data_ofs = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int AudioStreamPlaybackMPC::_read_file(void *p_dst, int p_bytes) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (f)
|
2017-03-19 00:36:26 +01:00
|
|
|
return f->get_buffer((uint8_t *)p_dst, p_bytes);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
DVector<uint8_t>::Read r = data.read();
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_bytes + data_ofs > streamlen) {
|
|
|
|
p_bytes = streamlen - data_ofs;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
copymem(p_dst, &r[data_ofs], p_bytes);
|
2014-02-10 02:10:30 +01:00
|
|
|
//print_line("read file: "+itos(p_bytes));
|
2017-03-19 00:36:26 +01:00
|
|
|
data_ofs += p_bytes;
|
2014-02-10 02:10:30 +01:00
|
|
|
return p_bytes;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool AudioStreamPlaybackMPC::_seek_file(int p_pos) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_pos < 0 || p_pos > streamlen)
|
2014-02-10 02:10:30 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (f) {
|
|
|
|
f->seek(p_pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//print_line("read file to: "+itos(p_pos));
|
2017-03-19 00:36:26 +01:00
|
|
|
data_ofs = p_pos;
|
2014-02-10 02:10:30 +01:00
|
|
|
return true;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
int AudioStreamPlaybackMPC::_tell_file() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (f)
|
|
|
|
return f->get_pos();
|
|
|
|
|
|
|
|
//print_line("tell file, get: "+itos(data_ofs));
|
|
|
|
return data_ofs;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int AudioStreamPlaybackMPC::_sizeof_file() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//print_line("sizeof file, get: "+itos(streamlen));
|
|
|
|
return streamlen;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool AudioStreamPlaybackMPC::_canseek_file() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//print_line("canseek file, get true");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
mpc_int32_t AudioStreamPlaybackMPC::_mpc_read(mpc_reader *p_reader, void *p_dst, mpc_int32_t p_bytes) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
AudioStreamPlaybackMPC *smpc = (AudioStreamPlaybackMPC *)p_reader->data;
|
|
|
|
return smpc->_read_file(p_dst, p_bytes);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
mpc_bool_t AudioStreamPlaybackMPC::_mpc_seek(mpc_reader *p_reader, mpc_int32_t p_offset) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
AudioStreamPlaybackMPC *smpc = (AudioStreamPlaybackMPC *)p_reader->data;
|
2014-02-10 02:10:30 +01:00
|
|
|
return smpc->_seek_file(p_offset);
|
|
|
|
}
|
2015-09-09 23:50:52 +02:00
|
|
|
mpc_int32_t AudioStreamPlaybackMPC::_mpc_tell(mpc_reader *p_reader) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
AudioStreamPlaybackMPC *smpc = (AudioStreamPlaybackMPC *)p_reader->data;
|
2014-02-10 02:10:30 +01:00
|
|
|
return smpc->_tell_file();
|
|
|
|
}
|
2015-09-09 23:50:52 +02:00
|
|
|
mpc_int32_t AudioStreamPlaybackMPC::_mpc_get_size(mpc_reader *p_reader) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
AudioStreamPlaybackMPC *smpc = (AudioStreamPlaybackMPC *)p_reader->data;
|
2014-02-10 02:10:30 +01:00
|
|
|
return smpc->_sizeof_file();
|
|
|
|
}
|
2015-09-09 23:50:52 +02:00
|
|
|
mpc_bool_t AudioStreamPlaybackMPC::_mpc_canseek(mpc_reader *p_reader) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
AudioStreamPlaybackMPC *smpc = (AudioStreamPlaybackMPC *)p_reader->data;
|
2014-02-10 02:10:30 +01:00
|
|
|
return smpc->_canseek_file();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int AudioStreamPlaybackMPC::mix(int16_t *p_bufer, int p_frames) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (!active || paused)
|
2015-09-09 23:50:52 +02:00
|
|
|
return 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int todo = p_frames;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
while (todo > MPC_DECODER_BUFFER_LENGTH / si.channels) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
mpc_frame_info frame;
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
frame.buffer = sample_buffer;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
mpc_status err = mpc_demux_decode(demux, &frame);
|
2017-03-19 00:36:26 +01:00
|
|
|
if (frame.bits != -1) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
int16_t *dst_buff = p_bufer;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
#ifdef MPC_FIXED_POINT
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < frame.samples * si.channels; i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
int tmp = sample_buffer[i] >> MPC_FIXED_POINT_FRACTPART;
|
|
|
|
if (tmp > ((1 << 15) - 1)) tmp = ((1 << 15) - 1);
|
|
|
|
if (tmp < -(1 << 15)) tmp = -(1 << 15);
|
|
|
|
dst_buff[i] = tmp;
|
|
|
|
}
|
|
|
|
#else
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < frame.samples * si.channels; i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int tmp = Math::fast_ftoi(sample_buffer[i] * 32767.0);
|
2014-02-10 02:10:30 +01:00
|
|
|
if (tmp > ((1 << 15) - 1)) tmp = ((1 << 15) - 1);
|
|
|
|
if (tmp < -(1 << 15)) tmp = -(1 << 15);
|
|
|
|
dst_buff[i] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int frames = frame.samples;
|
2017-03-19 00:36:26 +01:00
|
|
|
p_bufer += si.channels * frames;
|
|
|
|
todo -= frames;
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
if (err != MPC_STATUS_OK) {
|
|
|
|
|
|
|
|
stop();
|
2015-09-09 23:50:52 +02:00
|
|
|
ERR_PRINT("Error decoding MPC");
|
|
|
|
break;
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
//finished
|
|
|
|
if (!loop) {
|
|
|
|
stop();
|
2015-09-09 23:50:52 +02:00
|
|
|
break;
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
loops++;
|
|
|
|
mpc_demux_exit(demux);
|
|
|
|
_seek_file(0);
|
|
|
|
demux = mpc_demux_init(&reader);
|
|
|
|
//do loop somehow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-09 23:50:52 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return p_frames - todo;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
Error AudioStreamPlaybackMPC::_reload() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND_V(demux != NULL, ERR_FILE_ALREADY_IN_USE);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Error err = _open_file();
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND_V(err != OK, ERR_CANT_OPEN);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
demux = mpc_demux_init(&reader);
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND_V(!demux, ERR_CANT_CREATE);
|
|
|
|
mpc_demux_get_info(demux, &si);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void AudioStreamPlaybackMPC::set_file(const String &p_file) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file = p_file;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
Error err = _open_file();
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND(err != OK);
|
2015-09-09 23:50:52 +02:00
|
|
|
demux = mpc_demux_init(&reader);
|
|
|
|
ERR_FAIL_COND(!demux);
|
2017-03-19 00:36:26 +01:00
|
|
|
mpc_demux_get_info(demux, &si);
|
|
|
|
stream_min_size = MPC_DECODER_BUFFER_LENGTH * 2 / si.channels;
|
|
|
|
stream_rate = si.sample_freq;
|
|
|
|
stream_channels = si.channels;
|
2015-09-09 23:50:52 +02:00
|
|
|
|
|
|
|
mpc_demux_exit(demux);
|
2017-03-19 00:36:26 +01:00
|
|
|
demux = NULL;
|
2015-09-09 23:50:52 +02:00
|
|
|
_close_file();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
String AudioStreamPlaybackMPC::get_file() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
void AudioStreamPlaybackMPC::play(float p_offset) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (active)
|
|
|
|
stop();
|
2017-03-19 00:36:26 +01:00
|
|
|
active = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Error err = _open_file();
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND(err != OK);
|
|
|
|
if (_reload() != OK)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
active = true;
|
|
|
|
loops = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void AudioStreamPlaybackMPC::stop() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (!active)
|
|
|
|
return;
|
|
|
|
if (demux) {
|
|
|
|
mpc_demux_exit(demux);
|
2017-03-19 00:36:26 +01:00
|
|
|
demux = NULL;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
_close_file();
|
2017-03-19 00:36:26 +01:00
|
|
|
active = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
bool AudioStreamPlaybackMPC::is_playing() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
return active;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void AudioStreamPlaybackMPC::set_loop(bool p_enable) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
loop = p_enable;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
bool AudioStreamPlaybackMPC::has_loop() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return loop;
|
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
float AudioStreamPlaybackMPC::get_length() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
String AudioStreamPlaybackMPC::get_stream_name() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
int AudioStreamPlaybackMPC::get_loop_count() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
float AudioStreamPlaybackMPC::get_pos() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-09-09 23:50:52 +02:00
|
|
|
void AudioStreamPlaybackMPC::seek_pos(float p_time) {
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
void AudioStreamPlaybackMPC::_bind_methods() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("set_file", "name"), &AudioStreamPlaybackMPC::set_file);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_file"), &AudioStreamPlaybackMPC::get_file);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_FILE, "mpc"), _SCS("set_file"), _SCS("get_file"));
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
AudioStreamPlaybackMPC::AudioStreamPlaybackMPC() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
preload = false;
|
|
|
|
f = NULL;
|
|
|
|
streamlen = 0;
|
|
|
|
data_ofs = 0;
|
|
|
|
active = false;
|
|
|
|
paused = false;
|
|
|
|
loop = false;
|
|
|
|
demux = NULL;
|
|
|
|
reader.data = this;
|
|
|
|
reader.read = _mpc_read;
|
|
|
|
reader.seek = _mpc_seek;
|
|
|
|
reader.tell = _mpc_tell;
|
|
|
|
reader.get_size = _mpc_get_size;
|
|
|
|
reader.canseek = _mpc_canseek;
|
|
|
|
loops = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2015-09-09 23:50:52 +02:00
|
|
|
AudioStreamPlaybackMPC::~AudioStreamPlaybackMPC() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
stop();
|
|
|
|
|
|
|
|
if (f)
|
|
|
|
memdelete(f);
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
RES ResourceFormatLoaderAudioStreamMPC::load(const String &p_path, const String &p_original_path, Error *r_error) {
|
2015-08-24 01:15:56 +02:00
|
|
|
if (r_error)
|
2017-03-19 00:36:26 +01:00
|
|
|
*r_error = OK; //streamed so it will always work..
|
2014-02-10 02:10:30 +01:00
|
|
|
AudioStreamMPC *mpc_stream = memnew(AudioStreamMPC);
|
|
|
|
mpc_stream->set_file(p_path);
|
|
|
|
return Ref<AudioStreamMPC>(mpc_stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResourceFormatLoaderAudioStreamMPC::get_recognized_extensions(List<String> *p_extensions) const {
|
|
|
|
|
|
|
|
p_extensions->push_back("mpc");
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
bool ResourceFormatLoaderAudioStreamMPC::handles_type(const String &p_type) const {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return (p_type == "AudioStream") || (p_type == "AudioStreamMPC");
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
String ResourceFormatLoaderAudioStreamMPC::get_resource_type(const String &p_path) const {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_path.extension().to_lower() == "mpc")
|
2014-02-10 02:10:30 +01:00
|
|
|
return "AudioStreamMPC";
|
|
|
|
return "";
|
|
|
|
}
|