//output.c: /* * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011 * * This file is part of roard a part of RoarAudio, * a cross-platform sound system for both, home and professional use. * See README for details. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 * as published by the Free Software Foundation. * * RoarAudio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "roard.h" int output_buffer_init (struct roar_audio_info * info) { size_t size; void * buf; g_output_buffer = NULL; g_input_buffer = NULL; g_output_buffer_len = 0; size = ROAR_OUTPUT_CALC_OUTBUFSIZE(info); ROAR_DBG("output_buffer_init(*): output buffer size is %i", size); if ( (buf = roar_mm_malloc(size)) == NULL ) return -1; g_output_buffer = buf; g_output_buffer_len = size; if ( (buf = roar_mm_malloc(size)) == NULL ) { g_output_buffer = NULL; g_output_buffer_len = 0; roar_mm_free(g_output_buffer); return -1; } g_input_buffer = buf; ROAR_DBG("output_buffer_init(*): output buffer is at %p", buf); memlock_register(MEMLOCK_LOW, g_output_buffer, size); memlock_register(MEMLOCK_LOW, g_input_buffer, size); output_buffer_reinit(); return 0; } int output_buffer_reinit (void) { if ( g_output_buffer != NULL ) memset(g_output_buffer, 0, g_output_buffer_len); return 0; } int output_buffer_free (void) { ROAR_DBG("output_buffer_init(*): freeing output buffer at %p", g_output_buffer); if ( g_output_buffer != NULL ) roar_mm_free(g_output_buffer); if ( g_input_buffer != NULL ) roar_mm_free(g_input_buffer); g_output_buffer = NULL; g_input_buffer = NULL; g_output_buffer_len = 0; return 0; } //ll