diff --git a/core/pen/include/os.h b/core/pen/include/os.h index 86cafd42..444f4e4c 100644 --- a/core/pen/include/os.h +++ b/core/pen/include/os.h @@ -44,6 +44,7 @@ namespace pen Str os_get_persistent_data_directory(); Str os_get_cache_data_directory(); void os_create_directory(const Str& dir); + bool os_delete_directory(const Str& filename); void os_open_url(const Str& url); void os_ignore_slient(); void os_enable_background_audio(); @@ -74,5 +75,6 @@ namespace pen void music_enable_remote_control(); void music_set_now_playing(const Str& artist, const Str& album, const Str& track); void music_set_now_playing_artwork(void* data, u32 w, u32 h, u32 bpp, u32 row_pitch); + void music_set_now_playing_position(); } // namespace pen diff --git a/core/pen/source/ios/os.mm b/core/pen/source/ios/os.mm index ef7d5b1a..cfaff10b 100644 --- a/core/pen/source/ios/os.mm +++ b/core/pen/source/ios/os.mm @@ -412,6 +412,16 @@ void os_create_directory(const Str& dir) } } + bool os_delete_directory(const Str& filename) + { + bool ret = false; + @autoreleasepool { + NSFileManager* manager = [NSFileManager defaultManager]; + ret = [manager removeItemAtPath:[NSString stringWithUTF8String:filename.c_str()] error:nil]; + } + return ret; + } + void os_open_url(const Str& url) { @autoreleasepool { @@ -510,4 +520,8 @@ void music_set_now_playing_artwork(void* data, u32 w, u32 h, u32 bpp, u32 row_pi [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mut_info]; } } + + void music_set_now_playing_position() { + + } } diff --git a/core/put/source/audio/audio.h b/core/put/source/audio/audio.h index 4356be5c..fd543195 100644 --- a/core/put/source/audio/audio.h +++ b/core/put/source/audio/audio.h @@ -53,7 +53,8 @@ namespace put struct audio_sound_file_info { - u32 length_ms; + u32 error = 0; + u32 length_ms = 0; }; struct audio_channel_state diff --git a/core/put/source/audio/audio_fmod.cpp b/core/put/source/audio/audio_fmod.cpp index 6d30c2ed..a3f819b5 100644 --- a/core/put/source/audio/audio_fmod.cpp +++ b/core/put/source/audio/audio_fmod.cpp @@ -31,12 +31,10 @@ namespace struct audio_resource_allocation { - void* resource; - u32 num_dsp = 0; - + void* resource; + u32 num_dsp = 0; audio_resource_type type; - - std::atomic assigned_flag; + std::atomic assigned_flag; }; struct resource_state @@ -270,13 +268,14 @@ namespace put FMOD_RESULT result = _sound_system->createSound(resovled_name.c_str(), FMOD_DEFAULT, NULL, (FMOD::Sound**)&_audio_resources[resource_slot].resource); - PEN_ASSERT(result == FMOD_OK); - // populate sound info - FMOD::Sound* new_sound = (FMOD::Sound*)_audio_resources[resource_slot].resource; - - new_sound->getLength(&_sound_file_info[resource_slot].length_ms, FMOD_TIMEUNIT_MS); - + _sound_file_info[resource_slot].error = result; + if(result == FMOD_OK) + { + FMOD::Sound* new_sound = (FMOD::Sound*)_audio_resources[resource_slot].resource; + FMOD_RESULT ms_result = new_sound->getLength(&_sound_file_info[resource_slot].length_ms, FMOD_TIMEUNIT_MS); + PEN_LOG("FMOD TIMEMS %i", ms_result); + } _sound_file_info_ready[resource_slot] = true; return resource_slot; @@ -301,11 +300,15 @@ namespace put FMOD_RESULT result = _sound_system->createSound((const char*)music.pcm_data, FMOD_OPENRAW | FMOD_OPENMEMORY_POINT, &exinfo, (FMOD::Sound**)&_audio_resources[resource_slot].resource); - PEN_ASSERT(result == FMOD_OK); - + // populate sound info - FMOD::Sound* new_sound = (FMOD::Sound*)_audio_resources[resource_slot].resource; - new_sound->getLength(&_sound_file_info[resource_slot].length_ms, FMOD_TIMEUNIT_MS); + _sound_file_info[resource_slot].error = result; + if(result == FMOD_OK) + { + FMOD::Sound* new_sound = (FMOD::Sound*)_audio_resources[resource_slot].resource; + FMOD_RESULT ms_result = new_sound->getLength(&_sound_file_info[resource_slot].length_ms, FMOD_TIMEUNIT_MS); + PEN_LOG("FMOD TIMEMS %i", ms_result); + } _sound_file_info_ready[resource_slot] = true; return resource_slot; @@ -320,10 +323,22 @@ namespace put _audio_resources[resource_slot].assigned_flag |= 0xff; _audio_resources[resource_slot].type = AUDIO_RESOURCE_SOUND; - FMOD_RESULT result = _sound_system->createStream(filename, FMOD_LOOP_NORMAL | FMOD_2D, 0, - (FMOD::Sound**)&_audio_resources[resource_slot].resource); - - PEN_ASSERT(result == FMOD_OK); + FMOD_RESULT result = _sound_system->createStream( + filename, + FMOD_LOOP_OFF | FMOD_2D | FMOD_IGNORETAGS | FMOD_MPEGSEARCH, + 0, + (FMOD::Sound**)&_audio_resources[resource_slot].resource + ); + + // populate sound info + _sound_file_info[resource_slot].error = result; + if(result == FMOD_OK) + { + FMOD::Sound* new_sound = (FMOD::Sound*)_audio_resources[resource_slot].resource; + FMOD_RESULT ms_result = new_sound->getLength(&_sound_file_info[resource_slot].length_ms, FMOD_TIMEUNIT_MS); + PEN_LOG("FMOD TIMEMS %i", ms_result); + } + _sound_file_info_ready[resource_slot] = true; return resource_slot; } @@ -360,8 +375,6 @@ namespace put result = _sound_system->playSound((FMOD::Sound*)_audio_resources[sound_index].resource, 0, false, (FMOD::Channel**)&_audio_resources[resource_slot].resource); - PEN_ASSERT(result == FMOD_OK); - return resource_slot; }