virtual void create_painter(painter_ptr & p_out) { if (p_wnd->get_wnd()) { p_out = new painter_impl(p_wnd.get_ptr()); } }
static void prepare_for_open(service_ptr_t<input_entry> & p_service,service_ptr_t<file> & p_file,const char * p_path,filesystem::t_open_mode p_open_mode,abort_callback & p_abort,bool p_from_redirect) { if (p_file.is_empty()) { service_ptr_t<filesystem> fs; if (filesystem::g_get_interface(fs,p_path)) { if (fs->supports_content_types()) { fs->open(p_file,p_path,p_open_mode,p_abort); } } } if (p_file.is_valid()) { pfc::string8 content_type; if (p_file->get_content_type(content_type)) { if (input_entry::g_find_service_by_content_type(p_service,content_type)) return; } } if (input_entry::g_find_service_by_path(p_service,p_path)) { if (p_from_redirect && p_service->is_redirect()) throw exception_io_unsupported_format(); return; } throw exception_io_unsupported_format(); }
void tag_processor_id3v2::g_remove_ex(tag_write_callback & p_callback,const service_ptr_t<file> & p_file,t_uint64 & p_size_removed,abort_callback & p_abort) { p_file->ensure_seekable(); t_filesize len; len = p_file->get_size(p_abort); if (len == filesize_invalid) throw exception_io_no_length(); p_file->seek(0,p_abort); t_uint64 offset; g_multiskip(p_file,offset,p_abort); if (offset>0 && offset<len) { len-=offset; service_ptr_t<file> temp; if (p_callback.open_temp_file(temp,p_abort)) { file::g_transfer_object(p_file,temp,len,p_abort); } else { if (len > 16*1024*1024) filesystem::g_open_temp(temp,p_abort); else filesystem::g_open_tempmem(temp,p_abort); file::g_transfer_object(p_file,temp,len,p_abort); p_file->seek(0,p_abort); p_file->set_eof(p_abort); temp->seek(0,p_abort); file::g_transfer_object(temp,p_file,len,p_abort); } } p_size_removed = offset; }
virtual void execute() { HWND wnd = p_this->get_wnd(); uie::window_host_ptr p_host = p_this->get_host(); uie::window_ptr(p_this)->destroy_window(); p_host->relinquish_ownership(wnd); }
void seekabilizer::g_seekabilize(service_ptr_t<file> & p_reader,t_size p_buffer_size,abort_callback & p_abort) { if (p_reader.is_valid() && p_reader->is_remote() && p_buffer_size > 0) { service_ptr_t<seekabilizer> instance = new service_impl_t<seekabilizer>(); instance->initialize(p_reader,p_buffer_size,p_abort); p_reader = instance.get_ptr(); } }
static void load_id666(service_ptr_t<file> & p_file, LPID666TAG lpTag, abort_callback & p_abort)//must be seeked to correct spot before calling { t_uint8 szBuf[4]; p_file->read_object( &szBuf, 4, p_abort ); if( ! memcmp( szBuf, xid6_signature, 4 ) ) { t_uint32 tag_size; p_file->read_lendian_t( tag_size, p_abort ); t_filesize offset = p_file->get_position( p_abort ); service_ptr_t< reader_limited > m_file = new service_impl_t< reader_limited >; m_file->init( p_file, offset, offset + tag_size, p_abort ); service_ptr_t<file> p_file = m_file.get_ptr(); try { parse_id666( p_file, lpTag, false, p_abort ); } catch ( const exception_io_data & ) { p_file->seek( 0, p_abort ); memset( lpTag, 0, sizeof( *lpTag ) ); parse_id666( p_file, lpTag, true, p_abort ); } } else throw exception_tag_not_found(); }
void file::g_transfer_file(const service_ptr_t<file> & p_from,const service_ptr_t<file> & p_to,abort_callback & p_abort) { t_filesize length = p_from->get_size_ex(p_abort); p_from->seek(0,p_abort); p_to->seek(0,p_abort); p_to->set_eof(p_abort); if (length > 0) { g_transfer_object(p_from,p_to,length,p_abort); } }
void retag_commit(abort_callback &p_abort) { byte out_module[ASAP_MODULE_MAX]; int out_len = ASAP_SetModuleInfo(&module_info, module, module_len, out_module); if (out_len <= 0) throw exception_io_unsupported_format(); m_file.release(); filesystem::g_open(m_file, filename, filesystem::open_mode_write_new, p_abort); m_file->write(out_module, out_len, p_abort); }
void file::g_transfer_object(service_ptr_t<file> p_src,service_ptr_t<file> p_dst,t_filesize p_bytes,abort_callback & p_abort) { if (p_bytes > 1024) /* don't bother on small objects */ { t_filesize oldsize = p_dst->get_size(p_abort); if (oldsize != filesize_invalid) { t_filesize newpos = p_dst->get_position(p_abort) + p_bytes; if (newpos > oldsize) p_dst->resize(newpos ,p_abort); } } g_transfer_object(pfc::implicit_cast<stream_reader*>(p_src.get_ptr()),pfc::implicit_cast<stream_writer*>(p_dst.get_ptr()),p_bytes,p_abort); }
bool load_feature_list_from_json_file(pfc::list_base_t<feature_handle_ptr> &p_list, const service_ptr_t<file> &p_file, abort_callback &p_abort) { t_filesize size = p_file->get_size(p_abort); pfc::string8 json; { pfc::string_buffer buffer(json, size); p_file->read_object(buffer, size, p_abort); } return load_feature_list_from_json_string(p_list, json); }
void open(service_ptr_t<file> p_filehint, const char *p_path, t_input_open_reason p_reason, abort_callback &p_abort) { if (p_reason == input_open_info_write) { int len = strlen(p_path); if (len < 4 || _stricmp(p_path + len - 4, ".sap") != 0) throw exception_io_unsupported_format(); filename = strdup(p_path); } if (p_filehint.is_empty()) filesystem::g_open(p_filehint, p_path, filesystem::open_mode_read, p_abort); m_file = p_filehint; module_len = m_file->read(module, sizeof(module), p_abort); if (!ASAP_Load(asap, p_path, module, module_len)) throw exception_io_unsupported_format(); }
void spectrum_extension::g_refresh_all() { double p_time = NULL; g_stream->get_absolute_time(p_time); audio_chunk_impl p_chunk; unsigned fft_size = 4096; bool ret = g_stream->get_spectrum_absolute(p_chunk, p_time, fft_size); unsigned n, count = spectrum_extension::g_visualisations.get_count(); for (n=0; n<count; n++) { spectrum_extension * vis_ext = spectrum_extension::g_visualisations[n]; if (ret) vis_ext->refresh(&p_chunk); } }
void config_object_callback::on_watched_object_changed(const service_ptr_t<config_object> & p_object) { GUID guid = p_object->get_guid(); bool boolval = false; unsigned msg = 0; p_object->get_data_bool(boolval); if (guid == standard_config_objects::bool_playlist_stop_after_current) msg = CALLBACK_UWM_PLAYLIST_STOP_AFTER_CURRENT; else if (guid == standard_config_objects::bool_cursor_follows_playback) msg = CALLBACK_UWM_CURSOR_FOLLOW_PLAYBACK; else msg = CALLBACK_UWM_PLAYBACK_FOLLOW_CURSOR; panel_manager::instance().post_msg_to_all(msg, TO_VARIANT_BOOL(boolval)); }
void open( service_ptr_t<file> m_file, const char * p_path, t_input_open_reason p_reason, abort_callback & p_abort ) { if ( p_reason == input_open_info_write ) throw exception_io_data(); input_open_file_helper( m_file, p_path, p_reason, p_abort ); m_stats = m_file->get_stats( p_abort ); t_uint8 * ptr; unsigned size; t_filesize size64 = m_file->get_size_ex( p_abort ); if ( size64 > ( 1 << 24 ) ) throw exception_io_data(); size = (unsigned) size64; file_buffer.set_size( size ); ptr = file_buffer.get_ptr(); m_file->read_object( ptr, size, p_abort ); m_player = ModPlug_Load(ptr, size); if ( !m_player ) throw exception_io_data(); }
void input_open_file_helper(service_ptr_t<file> & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) { if (p_file.is_empty()) { switch(p_reason) { default: uBugCheck(); case input_open_info_read: case input_open_decode: filesystem::g_open(p_file,p_path,filesystem::open_mode_read,p_abort); break; case input_open_info_write: filesystem::g_open(p_file,p_path,filesystem::open_mode_write_existing,p_abort); break; } } else { p_file->reopen(p_abort); } }
void open(service_ptr_t<file> file, const char *path, t_input_open_reason reason, abort_callback &abort) { m_pfile = file; input_open_file_helper(m_pfile, path, reason, abort); m_pfile->ensure_seekable(); m_demuxer = std::make_shared<CAFFile>(m_pfile, abort); m_decoder = IDecoder::create_decoder(m_demuxer, abort); }
void refresh_all_playlist_views() { if (playlist_view::g_get_cache().is_active()) { g_to_global.release(); g_to_global_colour.release(); playlist_view::g_reset_columns(); unsigned m, pcount = playlist_view::list_playlist.get_count(); for (m = 0; m < pcount; m++) { playlist_view * p_playlist = playlist_view::list_playlist.get_item(m); p_playlist->create_header(); if (p_playlist->wnd_header) p_playlist->move_header(); } playlist_view::update_all_windows(); } }
void retag_commit(abort_callback &p_abort) { m_file.release(); filesystem::g_open(m_file, filename, filesystem::open_mode_write_new, p_abort); this->p_abort = &p_abort; ByteWriter bw = { this, static_write }; if (!ASAPWriter_Write(filename, bw, ASAP_GetInfo(asap), module, module_len, FALSE)) throw exception_io_unsupported_format(); }
void open(service_ptr_t<file> p_filehint, const char *p_path, t_input_open_reason p_reason, abort_callback &p_abort) { if (p_reason == input_open_info_write) { int len = strlen(p_path); if (len >= MAX_PATH || !ASAP_CanSetModuleInfo(p_path)) throw exception_io_unsupported_format(); memcpy(filename, p_path, len + 1); } if (p_filehint.is_empty()) filesystem::g_open(p_filehint, p_path, filesystem::open_mode_read, p_abort); m_file = p_filehint; module_len = m_file->read(module, sizeof(module), p_abort); if (!ASAP_GetModuleInfo(&module_info, p_path, module, module_len)) throw exception_io_unsupported_format(); if (p_reason == input_open_decode) if (!ASAP_Load(&asap, p_path, module, module_len)) throw exception_io_unsupported_format(); }
~painter_impl() { HWND wnd = m_wnd->get_wnd(); HDC dc = GetDC(wnd); BitBlt(dc,0,0,m_rect.right,m_rect.bottom,m_dc,0,0,SRCCOPY); SelectObject(m_dc,m_gdiobj); DeleteDC(m_dc); ReleaseDC(wnd,dc); };
void write(const service_ptr_t<file> & p_file,abort_callback & p_abort,const char * p_string,bool is_utf8) { p_file->seek(0,p_abort); p_file->set_eof(p_abort); if (is_utf8) { p_file->write_object(utf8_header,sizeof(utf8_header),p_abort); p_file->write_object(p_string,strlen(p_string),p_abort); } else { #ifdef _WIN32 pfc::stringcvt::string_ansi_from_utf8 bah(p_string); p_file->write_object(bah,bah.length(),p_abort); #else throw exception_io_data(); #endif } }
static void process_fullbuffer(service_ptr_t<file> & p_file,const char * p_path,t_filesize p_fullbuffer,abort_callback & p_abort) { if (p_fullbuffer > 0) { if (p_file.is_empty()) { service_ptr_t<filesystem> fs; if (filesystem::g_get_interface(fs,p_path)) { fs->open(p_file,p_path,filesystem::open_mode_read,p_abort); } } if (p_file.is_valid()) { t_filesize size = p_file->get_size(p_abort); if (size != filesize_invalid && size <= p_fullbuffer) { service_ptr_t<file> l_file_buffered; if (reader_membuffer_mirror::g_create(l_file_buffered,p_file,p_abort)) { p_file = l_file_buffered; } } } } }
void spectrum_extension::g_refresh_all() { double p_time = NULL; g_stream->get_absolute_time(p_time); audio_chunk_impl p_chunk; //unsigned needed_fft_size = 1; //while (unsigned(rc_client.right - rc_client.left)*2 > needed_fft_size) // needed_fft_size <<= 1; unsigned fft_size = 1024;//min(needed_fft_size, 512); bool ret = g_stream->get_spectrum_absolute(p_chunk, p_time, fft_size); unsigned n, count = spectrum_extension::g_visualisations.get_count(); for (n=0; n<count; n++) { spectrum_extension * vis_ext = spectrum_extension::g_visualisations[n]; if (ret) vis_ext->refresh(&p_chunk); } }
bool dsp_rate_entry::instantiate(service_ptr_t<dsp>& p_out, const dsp_preset& p_preset) { bool ret = false; if (p_preset.get_owner() == get_guid()) { t_dsp_rate_params params; params.set_data(p_preset); p_out = reinterpret_cast<dsp*>(new service_impl_t<dsp_rate>(params)); ret = p_out.is_valid(); } return ret; }
void unpacker::g_open(service_ptr_t<file> & p_out,const service_ptr_t<file> & p,abort_callback & p_abort) { service_enum_t<unpacker> e; service_ptr_t<unpacker> ptr; if (e.first(ptr)) do { p->reopen(p_abort); try { ptr->open(p_out,p,p_abort); return; } catch(exception_io_data const &) {} } while(e.next(ptr)); throw exception_io_data(); }
void spectrum_extension::disable() { b_active = false; list_vis.remove_item(this); static_api_ptr_t<play_callback_manager>()->unregister_callback(this); if (static_api_ptr_t<play_control>()->is_playing()) g_deregister_stream(this); if (!list_vis.get_count()) g_stream.release(); p_host.release(); }
void open(service_ptr_t<file> m_file, const char * p_path, t_input_open_reason p_reason, abort_callback & p_abort) { if (p_reason == input_open_info_write) { throw exception_io_data(); } input_open_file_helper(m_file, p_path, p_reason, p_abort); m_stats = m_file->get_stats(p_abort); m_decoder = new dts_decode(); if (!m_decoder->load( m_file, p_abort)) { throw exception_io_data(); } }
static void index_tracks_helper(const char * p_path,const service_ptr_t<file> & p_reader,const t_filestats & p_stats,playlist_loader_callback::t_entry_type p_type,playlist_loader_callback::ptr p_callback, abort_callback & p_abort,bool & p_got_input) { TRACK_CALL_TEXT("index_tracks_helper"); if (p_reader.is_empty() && filesystem::g_is_remote_safe(p_path)) { TRACK_CALL_TEXT("remote"); metadb_handle_ptr handle; p_callback->handle_create(handle,make_playable_location(p_path,0)); p_got_input = true; p_callback->on_entry(handle,p_type,p_stats,true); } else { TRACK_CALL_TEXT("hintable"); service_ptr_t<input_info_reader> instance; input_entry::g_open_for_info_read(instance,p_reader,p_path,p_abort); t_filestats stats = instance->get_file_stats(p_abort); t_uint32 subsong,subsong_count = instance->get_subsong_count(); bool bInfoGetError = false; for(subsong=0;subsong<subsong_count;subsong++) { TRACK_CALL_TEXT("subsong-loop"); p_abort.check(); metadb_handle_ptr handle; t_uint32 index = instance->get_subsong(subsong); p_callback->handle_create(handle,make_playable_location(p_path,index)); p_got_input = true; if (! bInfoGetError && p_callback->want_info(handle,p_type,stats,true) ) { file_info_impl info; try { TRACK_CODE("get_info",instance->get_info(index,info,p_abort)); } catch(std::exception const & e) { bInfoGetError = true; } p_callback->on_entry_info(handle,p_type,stats,info,true); } else { p_callback->on_entry(handle,p_type,stats,true); } } } }
void spectrum_extension::enable( const ui_extension::visualisation_host_ptr & p_vis_host) { p_host = p_vis_host; b_active = true; const unsigned cx_dpi = QueryScreenDPIEx().cx; m_bar_width = MulDiv(cx_dpi, 3, 96); m_bar_gap = MulDiv(cx_dpi, 1, 96); if (list_vis.add_item(this) == 0) { static_api_ptr_t<visualisation_manager>()->create_stream(g_stream, visualisation_manager::KStreamFlagNewFFT); visualisation_stream_v2::ptr p_stream_v2; if (g_stream->service_query_t(p_stream_v2)) p_stream_v2->set_channel_mode(visualisation_stream_v2::channel_mode_mono); } static_api_ptr_t<play_callback_manager>()->register_callback(this, play_callback::flag_on_playback_new_track|play_callback::flag_on_playback_stop|play_callback::flag_on_playback_pause, false); if (static_api_ptr_t<play_control>()->is_playing()) g_register_stream(this); }
void tag_processor::read_id3v2_trailing(const service_ptr_t<file> & p_file,file_info & p_info,abort_callback & p_abort) { file_info_impl id3v2, trailing; bool have_id3v2 = true, have_trailing = true; try { read_id3v2(p_file,id3v2,p_abort); } catch(exception_io_data) { have_id3v2 = false; } if (!have_id3v2 || !p_file->is_remote()) try { read_trailing(p_file,trailing,p_abort); } catch(exception_io_data) { have_trailing = false; } if (!have_id3v2 && !have_trailing) throw exception_tag_not_found(); if (have_id3v2) { p_info._set_tag(id3v2); if (have_trailing) p_info._add_tag(trailing); } else { p_info._set_tag(trailing); } }