File: audiooptions.c

package info (click to toggle)
gavl 1.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 14,912 kB
  • sloc: ansic: 437,319; sh: 10,487; makefile: 238
file content (133 lines) | stat: -rw-r--r-- 3,541 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*****************************************************************
 * gavl - a general purpose audio/video processing library
 *
 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
 * gmerlin-general@lists.sourceforge.net
 * http://gmerlin.sourceforge.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
 * *****************************************************************/

#include <stdlib.h> /* calloc, free */
#include <string.h> 

#ifdef DEBUG
#include <stdio.h>  
#endif

#include "gavl.h"
#include "config.h"
#include "audio.h"
#include <accel.h>

#define SET_INT(p) opt->p = p

void gavl_audio_options_set_quality(gavl_audio_options_t * opt, int quality)
  {
  SET_INT(quality);
  }

void gavl_audio_options_set_dither_mode(gavl_audio_options_t * opt, gavl_audio_dither_mode_t dither_mode)
  {
  SET_INT(dither_mode);
  }

void gavl_audio_options_set_resample_mode(gavl_audio_options_t * opt, gavl_resample_mode_t resample_mode)
  {
  SET_INT(resample_mode);
  }

void gavl_audio_options_set_accel_flags(gavl_audio_options_t * opt,
                                        int accel_flags)
  {
  SET_INT(accel_flags);
  }

void gavl_audio_options_set_conversion_flags(gavl_audio_options_t * opt,
                                             int conversion_flags)
  {
  SET_INT(conversion_flags);
  }

#undef SET_INT

int gavl_audio_options_get_accel_flags(gavl_audio_options_t * opt)
  {
  return opt->accel_flags;
  }

int gavl_audio_options_get_conversion_flags(gavl_audio_options_t * opt)
  {
  return opt->conversion_flags;
  }

int gavl_audio_options_get_quality(gavl_audio_options_t * opt)
  {
  return opt->quality;
  }

gavl_audio_dither_mode_t
gavl_audio_options_get_dither_mode(gavl_audio_options_t * opt)
  {
  return opt->dither_mode;
  }

gavl_resample_mode_t
gavl_audio_options_get_resample_mode(gavl_audio_options_t * opt)
  {
  return opt->resample_mode;
  }

void gavl_audio_options_set_defaults(gavl_audio_options_t * opt)
  {
  memset(opt, 0, sizeof(*opt));
  
  opt->conversion_flags =
    GAVL_AUDIO_FRONT_TO_REAR_COPY |
    GAVL_AUDIO_STEREO_TO_MONO_MIX |
    GAVL_AUDIO_NORMALIZE_MIX_MATRIX;
  
  opt->accel_flags = gavl_accel_supported();
  opt->quality = GAVL_QUALITY_DEFAULT;
  gavl_init_memcpy();
  }

gavl_audio_options_t * gavl_audio_options_create()
  {
  gavl_audio_options_t * ret = calloc(1, sizeof(*ret));
  gavl_audio_options_set_defaults(ret);
  return ret;
  }

void gavl_audio_options_copy(gavl_audio_options_t * dst,
                             const gavl_audio_options_t * src)
  {
  memcpy(dst, src, sizeof(*dst));
  }

void gavl_audio_options_destroy(gavl_audio_options_t * opt)
  {
  free(opt);
  }

void gavl_audio_options_set_mix_matrix(gavl_audio_options_t * opt,
                                       const double ** matrix)
  {
  opt->mix_matrix = matrix;
  }
  
const double ** gavl_audio_options_get_mix_matrix(gavl_audio_options_t * opt)
  {
  return opt->mix_matrix;
  }