audio_stream_load_url() cleanup
This commit is contained in:
parent
21b4ed3be8
commit
a2786951cc
|
@ -7213,7 +7213,7 @@ end
|
|||
|
||||
--- @param url string
|
||||
--- @return BassAudio
|
||||
function audio_stream_loadURL(url)
|
||||
function audio_stream_load_url(url)
|
||||
-- ...
|
||||
end
|
||||
|
||||
|
|
|
@ -4767,10 +4767,10 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [audio_stream_loadURL](#audio_stream_loadURL)
|
||||
## [audio_stream_load_url](#audio_stream_load_url)
|
||||
|
||||
### Lua Example
|
||||
`local BassAudioValue = audio_stream_loadURL(url)`
|
||||
`local BassAudioValue = audio_stream_load_url(url)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
|
@ -4781,7 +4781,7 @@
|
|||
[BassAudio](structs.md#BassAudio)
|
||||
|
||||
### C Prototype
|
||||
`struct BassAudio* audio_stream_loadURL(const char* url);`
|
||||
`struct BassAudio* audio_stream_load_url(const char* url);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -1344,7 +1344,7 @@
|
|||
- [audio_stream_get_tempo](functions-4.md#audio_stream_get_tempo)
|
||||
- [audio_stream_get_volume](functions-4.md#audio_stream_get_volume)
|
||||
- [audio_stream_load](functions-4.md#audio_stream_load)
|
||||
- [audio_stream_loadURL](functions-4.md#audio_stream_loadURL)
|
||||
- [audio_stream_load_url](functions-4.md#audio_stream_load_url)
|
||||
- [audio_stream_pause](functions-4.md#audio_stream_pause)
|
||||
- [audio_stream_play](functions-4.md#audio_stream_play)
|
||||
- [audio_stream_set_frequency](functions-4.md#audio_stream_set_frequency)
|
||||
|
|
|
@ -14857,13 +14857,13 @@ int smlua_func_audio_stream_load(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_audio_stream_loadURL(lua_State* L) {
|
||||
int smlua_func_audio_stream_load_url(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
const char* url = smlua_to_string(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
smlua_push_object(L, LOT_BASSAUDIO, audio_stream_loadURL(url));
|
||||
smlua_push_object(L, LOT_BASSAUDIO, audio_stream_load_url(url));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -17576,7 +17576,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo);
|
||||
smlua_bind_function(L, "audio_stream_get_volume", smlua_func_audio_stream_get_volume);
|
||||
smlua_bind_function(L, "audio_stream_load", smlua_func_audio_stream_load);
|
||||
smlua_bind_function(L, "audio_stream_loadURL", smlua_func_audio_stream_loadURL);
|
||||
smlua_bind_function(L, "audio_stream_load_url", smlua_func_audio_stream_load_url);
|
||||
smlua_bind_function(L, "audio_stream_pause", smlua_func_audio_stream_pause);
|
||||
smlua_bind_function(L, "audio_stream_play", smlua_func_audio_stream_play);
|
||||
smlua_bind_function(L, "audio_stream_set_frequency", smlua_func_audio_stream_set_frequency);
|
||||
|
|
|
@ -250,6 +250,18 @@ struct BassAudio* audio_stream_load(const char* filename) {
|
|||
return audio_load_internal(filename, true);
|
||||
}
|
||||
|
||||
struct BassAudio* audio_stream_load_url(const char* url) {
|
||||
if (url == NULL || strlen(url) == 0) {
|
||||
LOG_LUA_LINE("Failed to load url");
|
||||
return NULL;
|
||||
}
|
||||
HSTREAM stream = BASS_StreamCreateURL(url, 0, 0, NULL, NULL);
|
||||
struct BassAudio* res = malloc(sizeof(struct BassAudio));
|
||||
res->handle = stream;
|
||||
res->rawData = NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
void audio_stream_destroy(struct BassAudio* audio) {
|
||||
if (!audio_sanity_check(audio, true, "destroy")) {
|
||||
return;
|
||||
|
@ -258,7 +270,9 @@ void audio_stream_destroy(struct BassAudio* audio) {
|
|||
bassh_free_stream(audio->handle);
|
||||
audio->handle = 0;
|
||||
audio->loaded = false;
|
||||
free(audio->rawData);
|
||||
if (audio->rawData != NULL) {
|
||||
free(audio->rawData);
|
||||
}
|
||||
audio->rawData = NULL;
|
||||
}
|
||||
|
||||
|
@ -377,7 +391,9 @@ void audio_sample_destroy(struct BassAudio* audio) {
|
|||
bassh_free_stream(audio->handle);
|
||||
audio->handle = 0;
|
||||
audio->loaded = false;
|
||||
free(audio->rawData);
|
||||
if (audio->rawData) {
|
||||
free(audio->rawData);
|
||||
}
|
||||
audio->rawData = NULL;
|
||||
}
|
||||
|
||||
|
@ -423,11 +439,3 @@ void audio_custom_shutdown(void) {
|
|||
}
|
||||
sBassAudioCount = 0;
|
||||
}
|
||||
|
||||
struct BassAudio* audio_stream_loadURL(const char* url) {
|
||||
HSTREAM stream = BASS_StreamCreateURL(url, 0, 0, NULL, NULL);
|
||||
struct BassAudio* res = malloc(sizeof(struct BassAudio));
|
||||
res->handle = stream;
|
||||
res->rawData = NULL;
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ struct BassAudio {
|
|||
};
|
||||
|
||||
struct BassAudio* audio_stream_load(const char* filename);
|
||||
struct BassAudio* audio_stream_load_url(const char* url);
|
||||
void audio_stream_destroy(struct BassAudio* audio);
|
||||
void audio_stream_play(struct BassAudio* audio, bool restart, f32 volume);
|
||||
void audio_stream_pause(struct BassAudio* audio);
|
||||
|
@ -33,8 +34,6 @@ void audio_stream_set_tempo(struct BassAudio* audio, f32 tempo);
|
|||
f32 audio_stream_get_volume(struct BassAudio* audio);
|
||||
void audio_stream_set_volume(struct BassAudio* audio, f32 volume);
|
||||
void audio_stream_set_speed(struct BassAudio* audio, f32 initial_freq, f32 speed, bool pitch);
|
||||
struct BassAudio* audio_stream_loadURL(const char* url);
|
||||
|
||||
|
||||
struct BassAudio* audio_sample_load(const char* filename);
|
||||
void audio_sample_destroy(struct BassAudio* audio);
|
||||
|
|
Loading…
Reference in New Issue