Update internal sound resource * Update internal sound resource (wavc/oggc/opusc) with new data * * @name resource.set_sound * * @param path [type:hash|string] The path to the resource * @param buffer [type:string] A lua string containing the binary sound data */
| 2914 | * @param buffer [type:string] A lua string containing the binary sound data |
| 2915 | */ |
| 2916 | static int SetSound(lua_State* L) { |
| 2917 | DM_LUA_STACK_CHECK(L, 0); |
| 2918 | |
| 2919 | // get resource path as hash |
| 2920 | const dmhash_t path_hash = dmScript::CheckHashOrString(L, 1); |
| 2921 | // get the sound buffer |
| 2922 | luaL_checktype(L, 2, LUA_TSTRING); |
| 2923 | size_t buffer_size; |
| 2924 | const char* buffer = lua_tolstring(L, 2, &buffer_size); |
| 2925 | |
| 2926 | dmResource::Result r = dmResource::SetResource(g_ResourceModule.m_Factory, path_hash, (void*) buffer, buffer_size); |
| 2927 | |
| 2928 | if( r != dmResource::RESULT_OK ) { |
| 2929 | return ReportPathError(L, r, path_hash); |
| 2930 | } |
| 2931 | |
| 2932 | return 0; |
| 2933 | } |
| 2934 | |
| 2935 | static uint8_t* CheckBufferOrString(lua_State* L, int index, uint32_t* data_size) |
| 2936 | { |
nothing calls this directly
no test coverage detected