source: roaraudio/roard/output.c @ 4243:2ab21e14c42a

Last change on this file since 4243:2ab21e14c42a was 4243:2ab21e14c42a, checked in by phi, 14 years ago

replaced *ROAR_MLOCK() with modern roar_mm_m*lock*()

File size: 2.2 KB
Line 
1//output.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010
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/* TODO: do this within the memlock part
55#ifdef ROAR_HAVE_MLOCK
56 ROAR_MLOCK(buf, size);
57#endif
58*/
59
60 output_buffer_reinit();
61
62 return 0;
63}
64
65int output_buffer_reinit (void) {
66
67 if ( g_output_buffer != NULL )
68  memset(g_output_buffer, 0, g_output_buffer_len);
69
70 return 0;
71}
72
73int output_buffer_free   (void) {
74 ROAR_DBG("output_buffer_init(*): freeing output buffer at %p", g_output_buffer);
75
76 if ( g_output_buffer != NULL )
77  roar_mm_free(g_output_buffer);
78
79 g_output_buffer     = NULL;
80 g_output_buffer_len = 0;
81
82 return 0;
83}
84
85int output_buffer_flush  (DRIVER_USERDATA_T inst, int driver) {
86 ROAR_DBG("output_buffer_init(*): flushing output buffer");
87
88 return driver_write(inst, driver, g_output_buffer, g_output_buffer_len);
89}
90
91//ll
Note: See TracBrowser for help on using the repository browser.