int ff_vaapi_common_end_frame(MpegEncContext *s) { struct vaapi_context * const vactx = s->avctx->hwaccel_context; int ret = -1; av_dlog(s->avctx, "ff_vaapi_common_end_frame()\n"); if (commit_slices(vactx) < 0) goto done; if (vactx->n_slice_buf_ids > 0) { if (render_picture(vactx, ff_vaapi_get_surface_id(s->current_picture_ptr)) < 0) goto done; ff_draw_horiz_band(s, 0, s->avctx->height); } ret = 0; done: destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1); destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1); destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1); destroy_buffers(vactx->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids); av_freep(&vactx->slice_buf_ids); av_freep(&vactx->slice_params); vactx->n_slice_buf_ids = 0; vactx->slice_buf_ids_alloc = 0; vactx->slice_count = 0; vactx->slice_params_alloc = 0; return ret; }
void ff_vaapi_common_end_frame(AVCodecContext *avctx) { struct vaapi_context * const vactx = avctx->hwaccel_context; destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1); destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1); destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1); destroy_buffers(vactx->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids); av_freep(&vactx->slice_buf_ids); av_freep(&vactx->slice_params); vactx->n_slice_buf_ids = 0; vactx->slice_buf_ids_alloc = 0; vactx->slice_count = 0; vactx->slice_params_alloc = 0; }
HRESULT sound_direct_sound::create_buffers(DWORD size, WAVEFORMATEX &format) { assert(m_dsound); assert(!m_primary_buffer); assert(!m_stream_buffer); HRESULT result; // create the primary buffer result = m_primary_buffer.create(m_dsound); if (result != DS_OK) { osd_printf_error("Error creating primary DirectSound buffer: %08x\n", (unsigned)result); goto error; } // attempt to set the primary format result = m_primary_buffer.set_format(format); if (result != DS_OK) { osd_printf_error("Error setting primary DirectSound buffer format: %08x\n", (unsigned)result); goto error; } // log the primary format WAVEFORMATEX primary_format; result = m_primary_buffer.get_format(primary_format); if (result != DS_OK) { osd_printf_error("Error getting primary DirectSound buffer format: %08x\n", (unsigned)result); goto error; } osd_printf_verbose( "DirectSound: Primary buffer: %d Hz, %d bits, %d channels\n", (int)primary_format.nSamplesPerSec, (int)primary_format.wBitsPerSample, (int)primary_format.nChannels); // create the stream buffer result = m_stream_buffer.create(m_dsound, size, format); if (result != DS_OK) { osd_printf_error("Error creating DirectSound stream buffer: %08x\n", (unsigned)result); goto error; } // clear the buffer result = m_stream_buffer.clear(); if (result != DS_OK) { osd_printf_error("Error locking DirectSound stream buffer: %08x\n", (unsigned)result); goto error; } return DS_OK; // error handling error: destroy_buffers(); return result; }
CMidiInputFilterer::~CMidiInputFilterer() { if( m_created_buffers ) { destroy_buffers(); } }
void ff_vaapi_common_end_frame(AVCodecContext *avctx) { FFVAContext * const vactx = ff_vaapi_get_context(avctx); ff_dlog(avctx, "ff_vaapi_common_end_frame()\n"); destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1); destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1); destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1); destroy_buffers(vactx->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids); av_freep(&vactx->slice_buf_ids); av_freep(&vactx->slice_params); vactx->n_slice_buf_ids = 0; vactx->slice_buf_ids_alloc = 0; vactx->slice_count = 0; vactx->slice_params_alloc = 0; }
void nandsim_swap_destroy(struct chip_swap *swap) { if (swap == NULL) return; destroy_block_state(swap); destroy_buffers(swap); swap_file_close(swap); free(swap, M_NANDSIM); }
void sound_direct_sound::exit() { // kill the buffers and dsound destroy_buffers(); dsound_kill(); // print out over/underflow stats if (m_buffer_overflows || m_buffer_underflows) { osd_printf_verbose( "Sound: buffer overflows=%u underflows=%u\n", m_buffer_overflows, m_buffer_underflows); } LOG(("Sound buffer: overflows=%u underflows=%u\n", m_buffer_overflows, m_buffer_underflows)); }
/* Before freeing the module, invalidate all of the protected buffers! */ static void __exit rd_cleanup (void) { int i; for (i = 0 ; i < NUM_RAMDISKS; i++) { struct block_device *bdev = rd_bdev[i]; rd_bdev[i] = NULL; if (bdev) blkdev_put(bdev, BDEV_FILE); destroy_buffers(MKDEV(MAJOR_NR, i)); } devfs_unregister (devfs_handle); unregister_blkdev( MAJOR_NR, "ramdisk" ); hardsect_size[MAJOR_NR] = NULL; blksize_size[MAJOR_NR] = NULL; blk_size[MAJOR_NR] = NULL; }
HRESULT sound_direct_sound::dsound_init() { assert(!m_dsound); HRESULT result; // create the DirectSound object result = DirectSoundCreate(nullptr, &m_dsound, nullptr); if (result != DS_OK) { osd_printf_error("Error creating DirectSound: %08x\n", (unsigned)result); goto error; } // get the capabilities DSCAPS dsound_caps; dsound_caps.dwSize = sizeof(dsound_caps); result = m_dsound->GetCaps(&dsound_caps); if (result != DS_OK) { osd_printf_error("Error getting DirectSound capabilities: %08x\n", (unsigned)result); goto error; } // set the cooperative level { #ifdef SDLMAME_WIN32 SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version); SDL_GetWindowWMInfo(osd_common_t::s_window_list.front()->platform_window<SDL_Window*>(), &wminfo); HWND const window = wminfo.info.win.window; #else // SDLMAME_WIN32 HWND const window = osd_common_t::s_window_list.front()->platform_window<HWND>(); #endif // SDLMAME_WIN32 result = m_dsound->SetCooperativeLevel(window, DSSCL_PRIORITY); } if (result != DS_OK) { osd_printf_error("Error setting DirectSound cooperative level: %08x\n", (unsigned)result); goto error; } { // make a format description for what we want WAVEFORMATEX stream_format; stream_format.wBitsPerSample = 16; stream_format.wFormatTag = WAVE_FORMAT_PCM; stream_format.nChannels = 2; stream_format.nSamplesPerSec = sample_rate(); stream_format.nBlockAlign = stream_format.wBitsPerSample * stream_format.nChannels / 8; stream_format.nAvgBytesPerSec = stream_format.nSamplesPerSec * stream_format.nBlockAlign; // compute the buffer size based on the output sample rate DWORD stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * m_audio_latency / 10; stream_buffer_size = std::max(DWORD(1024), (stream_buffer_size / 1024) * 1024); LOG(("stream_buffer_size = %u\n", (unsigned)stream_buffer_size)); // create the buffers m_bytes_per_sample = stream_format.nBlockAlign; m_stream_buffer_in = 0; result = create_buffers(stream_buffer_size, stream_format); if (result != DS_OK) goto error; } // start playing result = m_stream_buffer.play_looping(); if (result != DS_OK) { osd_printf_error("Error playing: %08x\n", (UINT32)result); goto error; } return DS_OK; // error handling error: destroy_buffers(); dsound_kill(); return result; }
int vaapi_exit(void) { VAAPIContext * const vaapi = vaapi_get_context(); unsigned int i; if (!vaapi) return 0; #if USE_GLX if (display_type() == DISPLAY_GLX) vaapi_glx_destroy_surface(); #endif destroy_buffers(vaapi->display, &vaapi->pic_param_buf_id, 1); destroy_buffers(vaapi->display, &vaapi->iq_matrix_buf_id, 1); destroy_buffers(vaapi->display, &vaapi->bitplane_buf_id, 1); destroy_buffers(vaapi->display, vaapi->slice_buf_ids, vaapi->n_slice_buf_ids); if (vaapi->subpic_flags) { free(vaapi->subpic_flags); vaapi->subpic_flags = NULL; } if (vaapi->subpic_formats) { free(vaapi->subpic_formats); vaapi->subpic_formats = NULL; vaapi->n_subpic_formats = 0; } if (vaapi->image_formats) { free(vaapi->image_formats); vaapi->image_formats = NULL; vaapi->n_image_formats = 0; } if (vaapi->entrypoints) { free(vaapi->entrypoints); vaapi->entrypoints = NULL; vaapi->n_entrypoints = 0; } if (vaapi->profiles) { free(vaapi->profiles); vaapi->profiles = NULL; vaapi->n_profiles = 0; } if (vaapi->slice_params) { free(vaapi->slice_params); vaapi->slice_params = NULL; vaapi->slice_params_alloc = 0; vaapi->n_slice_params = 0; } if (vaapi->slice_buf_ids) { free(vaapi->slice_buf_ids); vaapi->slice_buf_ids = NULL; vaapi->n_slice_buf_ids = 0; } if (vaapi->subpic_image.image_id != VA_INVALID_ID) { vaDestroyImage(vaapi->display, vaapi->subpic_image.image_id); vaapi->subpic_image.image_id = VA_INVALID_ID; } for (i = 0; i < ARRAY_ELEMS(vaapi->subpic_ids); i++) { if (vaapi->subpic_ids[i] != VA_INVALID_ID) { vaDestroySubpicture(vaapi->display, vaapi->subpic_ids[i]); vaapi->subpic_ids[i] = VA_INVALID_ID; } } if (vaapi->surface_id) { vaDestroySurfaces(vaapi->display, &vaapi->surface_id, 1); vaapi->surface_id = 0; } if (vaapi->context_id) { vaDestroyContext(vaapi->display, vaapi->context_id); vaapi->context_id = 0; } if (vaapi->config_id) { vaDestroyConfig(vaapi->display, vaapi->config_id); vaapi->config_id = 0; } if (vaapi->display) { vaTerminate(vaapi->display); vaapi->display = NULL; } free(vaapi_context); return 0; }
int __init change_root(kdev_t new_root_dev,const char *put_old) { kdev_t old_root_dev; struct vfsmount *vfsmnt; struct dentry *old_root,*old_pwd,*dir_d = NULL; int error; old_root = current->fs->root; old_pwd = current->fs->pwd; old_root_dev = ROOT_DEV; if (!fs_may_mount(new_root_dev)) { printk(KERN_CRIT "New root is busy. Staying in initrd.\n"); return -EBUSY; } ROOT_DEV = new_root_dev; mount_root(); dput(old_root); dput(old_pwd); #if 1 shrink_dcache(); printk("change_root: old root has d_count=%d\n", old_root->d_count); #endif /* * Get the new mount directory */ dir_d = lookup_dentry(put_old, NULL, 1); if (IS_ERR(dir_d)) { error = PTR_ERR(dir_d); } else if (!dir_d->d_inode) { dput(dir_d); error = -ENOENT; } else { error = 0; } if (!error && dir_d->d_covers != dir_d) { dput(dir_d); error = -EBUSY; } if (!error && !S_ISDIR(dir_d->d_inode->i_mode)) { dput(dir_d); error = -ENOTDIR; } if (error) { int umount_error; printk(KERN_NOTICE "Trying to unmount old root ... "); umount_error = do_umount(old_root_dev,1, 0); if (!umount_error) { printk("okay\n"); /* special: the old device driver is going to be a ramdisk and the point of this call is to free its protected memory (even if dirty). */ destroy_buffers(old_root_dev); return 0; } printk(KERN_ERR "error %d\n",umount_error); return error; } remove_vfsmnt(old_root_dev); vfsmnt = add_vfsmnt(old_root->d_sb, "/dev/root.old", put_old); if (vfsmnt) { d_mount(dir_d,old_root); return 0; } printk(KERN_CRIT "Trouble: add_vfsmnt failed\n"); return -ENOMEM; }