HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height, UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume) { struct wined3d_volume *object; HRESULT hr; TRACE("device %p, width %u, height %u, depth %u, usage %#x, format %s, pool %s\n", device, width, height, depth, usage, debug_d3dformat(format_id), debug_d3dpool(pool)); TRACE("parent %p, parent_ops %p, volume %p.\n", parent, parent_ops, volume); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); if (!object) { *volume = NULL; return WINED3DERR_OUTOFVIDEOMEMORY; } hr = volume_init(object, device, width, height, depth, level, usage, format_id, pool, parent, parent_ops); if (FAILED(hr)) { WARN("Failed to initialize volume, returning %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); return hr; } TRACE("Created volume %p.\n", object); *volume = object; return WINED3D_OK; }
/* * Called in the early (PREINIT) stage, when we immediately need some writable * filesystem. */ static int start(int argc, char *argv[1]) { struct volume *root; struct volume *data = volume_find("rootfs_data"); if (!getenv("PREINIT")) return -1; if (!data) { root = volume_find("rootfs"); volume_init(root); ULOG_NOTE("mounting /dev/root\n"); mount("/dev/root", "/", NULL, MS_NOATIME | MS_REMOUNT, 0); } /* * Before trying to mount and use "rootfs_data" let's check if there is * extroot configured. Following call will handle reading config from * the "rootfs_data" on its own. */ extroot_prefix = ""; if (!mount_extroot()) { ULOG_NOTE("switched to extroot\n"); return 0; } /* There isn't extroot, so just try to mount "rootfs_data" */ switch (volume_identify(data)) { case FS_NONE: ULOG_WARN("no usable overlay filesystem found, using tmpfs overlay\n"); return ramoverlay(); case FS_DEADCODE: /* * Filesystem isn't ready yet and we are in the preinit, so we * can't afford waiting for it. Use tmpfs for now and handle it * properly in the "done" call. */ ULOG_NOTE("jffs2 not ready yet, using temporary tmpfs overlay\n"); return ramoverlay(); case FS_JFFS2: case FS_UBIFS: mount_overlay(data); break; case FS_SNAPSHOT: mount_snapshot(data); break; } return 0; }
static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; VolumeContext *vol = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; vol->sample_fmt = inlink->format; vol->channels = av_get_channel_layout_nb_channels(inlink->channel_layout); vol->planes = av_sample_fmt_is_planar(inlink->format) ? vol->channels : 1; volume_init(vol); return 0; }
HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc, unsigned int level, struct wined3d_volume **volume) { struct wined3d_device_parent *device_parent = container->resource.device->device_parent; const struct wined3d_parent_ops *parent_ops; struct wined3d_volume *object; void *parent; HRESULT hr; TRACE("container %p, width %u, height %u, depth %u, level %u, format %s, " "usage %#x, pool %s, volume %p.\n", container, desc->width, desc->height, desc->depth, level, debug_d3dformat(desc->format), desc->usage, debug_d3dpool(desc->pool), volume); if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; if (FAILED(hr = volume_init(object, container, desc, level))) { WARN("Failed to initialize volume, returning %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); return hr; } if (FAILED(hr = device_parent->ops->volume_created(device_parent, wined3d_texture_get_parent(container), object, &parent, &parent_ops))) { WARN("Failed to create volume parent, hr %#x.\n", hr); wined3d_volume_destroy(object); return hr; } TRACE("Created volume %p, parent %p, parent_ops %p.\n", object, parent, parent_ops); object->resource.parent = parent; object->resource.parent_ops = parent_ops; *volume = object; return WINED3D_OK; }
int main(int argc, char **argv) { struct volume *v; int ch, yes = 0, reset = 0; while ((ch = getopt(argc, argv, "yr")) != -1) { switch(ch) { case 'y': yes = 1; break; case 'r': reset = 1; break; } } if (!yes && ask_user()) return -1; /* * TODO: Currently this only checks if kernel supports OverlayFS. We * should check if there is a mount point using it with rootfs_data * as upperdir. */ if (find_filesystem("overlay")) { ULOG_ERR("overlayfs not supported by kernel\n"); return -1; } v = volume_find("rootfs_data"); if (!v) { ULOG_ERR("MTD partition 'rootfs_data' not found\n"); return -1; } volume_init(v); if (!strcmp(*argv, "jffs2mark")) return jffs2_mark(v); return jffs2_reset(v, reset); }
static int start(int argc, char *argv[1]) { struct volume *v = volume_find("rootfs_data"); if (!getenv("PREINIT")) return -1; if (!v) { v = volume_find("rootfs"); volume_init(v); fprintf(stderr, "mounting /dev/root\n"); mount("/dev/root", "/", NULL, MS_NOATIME | MS_REMOUNT, 0); return 0; } extroot_prefix = ""; if (!mount_extroot()) { fprintf(stderr, "fs-state: switched to extroot\n"); return 0; } switch (volume_identify(v)) { case FS_NONE: case FS_DEADCODE: return ramoverlay(); case FS_JFFS2: case FS_UBIFS: mount_overlay(); break; case FS_SNAPSHOT: mount_snapshot(); break; } return 0; }
int main(int argc, char *argv[]) { struct options options; clock_t start; bool create_db; GError *error = NULL; bool success; daemonize_close_stdin(); #ifdef HAVE_LOCALE_H /* initialize locale */ setlocale(LC_CTYPE,""); #endif g_set_application_name("Music Player Daemon"); /* enable GLib's thread safety code */ g_thread_init(NULL); winsock_init(); idle_init(); dirvec_init(); songvec_init(); tag_pool_init(); config_global_init(); success = parse_cmdline(argc, argv, &options, &error); if (!success) { g_warning("%s", error->message); g_error_free(error); return EXIT_FAILURE; } glue_daemonize_init(&options); stats_global_init(); tag_lib_init(); log_init(options.verbose, options.log_stderr); success = listen_global_init(&error); if (!success) { g_warning("%s", error->message); g_error_free(error); return EXIT_FAILURE; } daemonize_set_user(); main_task = g_thread_self(); main_loop = g_main_loop_new(NULL, FALSE); main_cond = g_cond_new(); event_pipe_init(); event_pipe_register(PIPE_EVENT_IDLE, idle_event_emitted); path_global_init(); glue_mapper_init(); initPermissions(); playlist_global_init(); spl_global_init(); #ifdef ENABLE_ARCHIVE archive_plugin_init_all(); #endif decoder_plugin_init_all(); update_global_init(); create_db = !glue_db_init_and_load(); glue_sticker_init(); command_init(); initialize_decoder_and_player(); volume_init(); initAudioConfig(); audio_output_all_init(); client_manager_init(); replay_gain_global_init(); if (!input_stream_global_init(&error)) { g_warning("%s", error->message); g_error_free(error); return EXIT_FAILURE; } playlist_list_global_init(); daemonize(options.daemon); setup_log_output(options.log_stderr); initSigHandlers(); initZeroconf(); player_create(); if (create_db) { /* the database failed to load: recreate the database */ unsigned job = update_enqueue(NULL, true); if (job == 0) g_error("directory update failed"); } glue_state_file_init(); success = config_get_bool(CONF_AUTO_UPDATE, false); #ifdef ENABLE_INOTIFY if (success && mapper_has_music_directory()) mpd_inotify_init(); #else if (success) g_warning("inotify: auto_update was disabled. enable during compilation phase"); #endif config_global_check(); /* enable all audio outputs (if not already done by playlist_state_restore() */ pc_update_audio(); /* run the main loop */ g_main_loop_run(main_loop); /* cleanup */ g_main_loop_unref(main_loop); #ifdef ENABLE_INOTIFY mpd_inotify_finish(); #endif state_file_finish(); pc_kill(); finishZeroconf(); client_manager_deinit(); listen_global_finish(); playlist_global_finish(); start = clock(); db_finish(); g_debug("db_finish took %f seconds", ((float)(clock()-start))/CLOCKS_PER_SEC); #ifdef ENABLE_SQLITE sticker_global_finish(); #endif g_cond_free(main_cond); event_pipe_deinit(); playlist_list_global_finish(); input_stream_global_finish(); audio_output_all_finish(); volume_finish(); mapper_finish(); path_global_finish(); finishPermissions(); pc_deinit(); command_finish(); update_global_finish(); decoder_plugin_deinit_all(); #ifdef ENABLE_ARCHIVE archive_plugin_deinit_all(); #endif config_global_finish(); tag_pool_deinit(); songvec_deinit(); dirvec_deinit(); idle_deinit(); stats_global_finish(); daemonize_finish(); #ifdef WIN32 WSACleanup(); #endif close_log_files(); return EXIT_SUCCESS; }
static int filter_frame(AVFilterLink *inlink, AVFrame *buf) { VolumeContext *vol = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; int nb_samples = buf->nb_samples; AVFrame *out_buf; AVFrameSideData *sd = av_frame_get_side_data(buf, AV_FRAME_DATA_REPLAYGAIN); int ret; if (sd && vol->replaygain != REPLAYGAIN_IGNORE) { if (vol->replaygain != REPLAYGAIN_DROP) { AVReplayGain *replaygain = (AVReplayGain*)sd->data; int32_t gain = 100000; uint32_t peak = 100000; float g, p; if (vol->replaygain == REPLAYGAIN_TRACK && replaygain->track_gain != INT32_MIN) { gain = replaygain->track_gain; if (replaygain->track_peak != 0) peak = replaygain->track_peak; } else if (replaygain->album_gain != INT32_MIN) { gain = replaygain->album_gain; if (replaygain->album_peak != 0) peak = replaygain->album_peak; } else { av_log(inlink->dst, AV_LOG_WARNING, "Both ReplayGain gain " "values are unknown.\n"); } g = gain / 100000.0f; p = peak / 100000.0f; av_log(inlink->dst, AV_LOG_VERBOSE, "Using gain %f dB from replaygain side data.\n", g); vol->volume = pow(10, (g + vol->replaygain_preamp) / 20); if (vol->replaygain_noclip) vol->volume = FFMIN(vol->volume, 1.0 / p); vol->volume_i = (int)(vol->volume * 256 + 0.5); volume_init(vol); } av_frame_remove_side_data(buf, AV_FRAME_DATA_REPLAYGAIN); } if (vol->volume == 1.0 || vol->volume_i == 256) return ff_filter_frame(outlink, buf); /* do volume scaling in-place if input buffer is writable */ if (av_frame_is_writable(buf)) { out_buf = buf; } else { out_buf = ff_get_audio_buffer(inlink, nb_samples); if (!out_buf) return AVERROR(ENOMEM); ret = av_frame_copy_props(out_buf, buf); if (ret < 0) { av_frame_free(&out_buf); av_frame_free(&buf); return ret; } } if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) { int p, plane_samples; if (av_sample_fmt_is_planar(buf->format)) plane_samples = FFALIGN(nb_samples, vol->samples_align); else plane_samples = FFALIGN(nb_samples * vol->channels, vol->samples_align); if (vol->precision == PRECISION_FIXED) { for (p = 0; p < vol->planes; p++) { vol->scale_samples(out_buf->extended_data[p], buf->extended_data[p], plane_samples, vol->volume_i); } } else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) { for (p = 0; p < vol->planes; p++) { vol->fdsp.vector_fmul_scalar((float *)out_buf->extended_data[p], (const float *)buf->extended_data[p], vol->volume, plane_samples); } } else { for (p = 0; p < vol->planes; p++) { vol->fdsp.vector_dmul_scalar((double *)out_buf->extended_data[p], (const double *)buf->extended_data[p], vol->volume, plane_samples); } } } emms_c(); if (buf != out_buf) av_frame_free(&buf); return ff_filter_frame(outlink, out_buf); }