add last backwards-compatible version

This commit is contained in:
2021-12-14 00:33:46 -07:00
parent 68b10d413b
commit b0dd3f07f3
335 changed files with 4746 additions and 19627 deletions

View File

@@ -1,17 +1,5 @@
#include "foobar2000.h"
GUID album_art_extractor::get_guid() {
album_art_extractor_v2::ptr v2;
if ( v2 &= this ) return v2->get_guid();
return pfc::guid_null;
}
GUID album_art_editor::get_guid() {
album_art_editor_v2::ptr v2;
if ( v2 &= this ) return v2->get_guid();
return pfc::guid_null;
}
bool album_art_extractor_instance::query(const GUID & what, album_art_data::ptr & out, abort_callback & abort) {
try { out = query(what, abort); return true; } catch (exception_album_art_not_found) { return false; }
}
@@ -20,23 +8,9 @@ bool album_art_extractor_instance::have_entry(const GUID & what, abort_callback
try { query(what, abort); return true; } catch(exception_album_art_not_found) { return false; }
}
void album_art_editor_instance::remove_all_() {
album_art_editor_instance_v2::ptr v2;
if ( v2 &= this ) {
v2->remove_all();
} else {
for( size_t walk = 0; walk < album_art_ids::num_types(); ++ walk ) {
try {
this->remove( album_art_ids::query_type( walk ) );
} catch(exception_io_data) {}
catch(exception_album_art_not_found) {}
}
}
}
bool album_art_editor::g_get_interface(service_ptr_t<album_art_editor> & out,const char * path) {
service_enum_t<album_art_editor> e; ptr ptr;
auto ext = pfc::string_extension(path);
pfc::string_extension ext(path);
while(e.next(ptr)) {
if (ptr->is_our_path(path,ext)) { out = ptr; return true; }
}
@@ -48,18 +22,6 @@ bool album_art_editor::g_is_supported_path(const char * path) {
}
album_art_editor_instance_ptr album_art_editor::g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) {
#ifdef FOOBAR2000_DESKTOP
{
input_manager_v2::ptr m;
if (fb2k::std_api_try_get(m)) {
album_art_editor_instance::ptr ret;
ret ^= m->open_v2(album_art_editor_instance::class_guid, p_filehint, p_path, false, nullptr, p_abort);
return ret;
}
}
#endif
album_art_editor::ptr obj;
if (!g_get_interface(obj, p_path)) throw exception_album_art_unsupported_format();
return obj->open(p_filehint, p_path, p_abort);
@@ -68,7 +30,7 @@ album_art_editor_instance_ptr album_art_editor::g_open(file_ptr p_filehint,const
bool album_art_extractor::g_get_interface(service_ptr_t<album_art_extractor> & out,const char * path) {
service_enum_t<album_art_extractor> e; ptr ptr;
auto ext = pfc::string_extension(path);
pfc::string_extension ext(path);
while(e.next(ptr)) {
if (ptr->is_our_path(path,ext)) { out = ptr; return true; }
}
@@ -79,17 +41,6 @@ bool album_art_extractor::g_is_supported_path(const char * path) {
ptr ptr; return g_get_interface(ptr,path);
}
album_art_extractor_instance_ptr album_art_extractor::g_open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) {
#ifdef FOOBAR2000_DESKTOP
{
input_manager_v2::ptr m;
if (fb2k::std_api_try_get(m)) {
album_art_extractor_instance::ptr ret;
ret ^= m->open_v2(album_art_extractor_instance::class_guid, p_filehint, p_path, false, nullptr, p_abort);
return ret;
}
}
#endif
album_art_extractor::ptr obj;
if (!g_get_interface(obj, p_path)) throw exception_album_art_unsupported_format();
return obj->open(p_filehint, p_path, p_abort);
@@ -120,66 +71,4 @@ now_playing_album_art_notify * now_playing_album_art_notify_manager::add(std::fu
obj->f = f;
add(obj);
return obj;
}
namespace {
struct aa_t {
GUID type; const char * name;
};
static const GUID guids[] = {
album_art_ids::cover_front,
album_art_ids::cover_back,
album_art_ids::artist,
album_art_ids::disc,
album_art_ids::icon,
};
static const char * const names[] = {
"front cover",
"back cover",
"artist",
"disc",
"icon"
};
static const char * const names2[] = {
"Front Cover",
"Back Cover",
"Artist",
"Disc",
"Icon"
};
}
size_t album_art_ids::num_types() {
PFC_STATIC_ASSERT( PFC_TABSIZE( guids ) == PFC_TABSIZE( names ) );
PFC_STATIC_ASSERT( PFC_TABSIZE( guids ) == PFC_TABSIZE( names2 ) );
return PFC_TABSIZE( guids );
}
GUID album_art_ids::query_type(size_t idx) {
PFC_ASSERT( idx < PFC_TABSIZE( guids ) );
return guids[idx];
}
const char * album_art_ids::query_name(size_t idx) {
PFC_ASSERT( idx < PFC_TABSIZE( names ) );
return names[idx];
}
const char * album_art_ids::name_of(const GUID & id) {
for( size_t w = 0; w < num_types(); ++w ) {
if ( query_type(w) == id ) return query_name(w);
}
return nullptr;
}
const char * album_art_ids::query_capitalized_name( size_t idx ) {
PFC_ASSERT( idx < PFC_TABSIZE( names2 ) );
return names2[idx];
}
const char * album_art_ids::capitalized_name_of( const GUID & id) {
for( size_t w = 0; w < num_types(); ++w ) {
if ( query_type(w) == id ) return query_capitalized_name(w);
}
return nullptr;
}
}