source: roaraudio/roard/output.c @ 4708:c9d40761088a

Last change on this file since 4708:c9d40761088a was 4708:c9d40761088a, checked in by phi, 13 years ago

updated copyright statements

File size: 2.1 KB
Line 
1//output.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
5 *
6 *  This file is part of roard a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "roard.h"
27
28/*
29void         * g_output_buffer;
30unsigned int   g_output_buffer_len;
31*/
32
33int output_buffer_init   (struct roar_audio_info * info) {
34 size_t   size; // = ROAR_OUTPUT_BUFFER_SAMPLES;
35 void   * buf;
36
37/*
38 size *= info->channels;
39 size *= info->bits / 8;
40*/
41
42 size = ROAR_OUTPUT_CALC_OUTBUFSIZE(info);
43
44 ROAR_DBG("output_buffer_init(*): output buffer size is %i", size);
45
46 if ( (buf = roar_mm_malloc(size)) == NULL )
47  return -1;
48
49 g_output_buffer     = buf;
50 g_output_buffer_len = size;
51
52 ROAR_DBG("output_buffer_init(*): output buffer is at %p", buf);
53
54 memlock_register(MEMLOCK_LOW, buf, size);
55
56 output_buffer_reinit();
57
58 return 0;
59}
60
61int output_buffer_reinit (void) {
62
63 if ( g_output_buffer != NULL )
64  memset(g_output_buffer, 0, g_output_buffer_len);
65
66 return 0;
67}
68
69int output_buffer_free   (void) {
70 ROAR_DBG("output_buffer_init(*): freeing output buffer at %p", g_output_buffer);
71
72 if ( g_output_buffer != NULL )
73  roar_mm_free(g_output_buffer);
74
75 g_output_buffer     = NULL;
76 g_output_buffer_len = 0;
77
78 return 0;
79}
80
81int output_buffer_flush  (DRIVER_USERDATA_T inst, int driver) {
82 ROAR_DBG("output_buffer_init(*): flushing output buffer");
83
84 return driver_write(inst, driver, g_output_buffer, g_output_buffer_len);
85}
86
87//ll
Note: See TracBrowser for help on using the repository browser.