]> git.sesse.net Git - vlc/blob - modules/access/cdda/callback.c
7d06c4cf5ff748d07ac8b4d1e7c0344756a84bb5
[vlc] / modules / access / cdda / callback.c
1 /*****************************************************************************
2  * callback.c : Callbacks for CD digital audio input module
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Rocky Bernstein <rocky@panix.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program 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 program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include "callback.h"
25 #include "cdda.h"
26
27 int
28 CDDADebugCB   ( vlc_object_t *p_this, const char *psz_name,
29                     vlc_value_t oldval, vlc_value_t val, void *p_data )
30 {
31     VLC_UNUSED(p_this);
32     VLC_UNUSED(psz_name);
33     VLC_UNUSED(oldval);
34     VLC_UNUSED(p_data);
35     cdda_data_t *p_cdda;
36
37     if (NULL == p_cdda_input) return VLC_EGENERIC;
38
39     p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
40
41     if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
42     {
43         msg_Dbg( p_cdda_input, "old debug (x%0x) %d, new debug (x%0x) %d",
44                  p_cdda->i_debug, p_cdda->i_debug, val.i_int, val.i_int);
45     }
46     p_cdda->i_debug = val.i_int;
47     return VLC_SUCCESS;
48 }
49
50 /* FIXME: could probably shorten some of the below boilerplate code...
51 */
52 int
53 CDDBEnabledCB   ( vlc_object_t *p_this, const char *psz_name,
54                       vlc_value_t oldval, vlc_value_t val, void *p_data )
55 {
56     VLC_UNUSED(p_this);
57     VLC_UNUSED(psz_name);
58     VLC_UNUSED(oldval);
59     VLC_UNUSED(p_data);
60
61     cdda_data_t *p_cdda;
62
63     if (NULL == p_cdda_input) return VLC_EGENERIC;
64
65     p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
66
67 #ifdef HAVE_LIBCDDB
68     if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
69     {
70         msg_Dbg( p_cdda_input, "old CDDB Enabled (x%0x) %d, new (x%0x) %d",
71                  p_cdda->b_cddb_enabled, p_cdda->b_cddb_enabled,
72                  val.b_bool, val.b_bool);
73     }
74     p_cdda->b_cddb_enabled = val.b_bool;
75 #endif
76     return VLC_SUCCESS;
77 }
78
79 int
80 CDTextEnabledCB   ( vlc_object_t *p_this, const char *psz_name,
81                         vlc_value_t oldval, vlc_value_t val, void *p_data )
82 {
83     VLC_UNUSED(p_this);
84     VLC_UNUSED(psz_name);
85     VLC_UNUSED(oldval);
86     VLC_UNUSED(p_data);
87     
88     cdda_data_t *p_cdda;
89
90     if (NULL == p_cdda_input) return VLC_EGENERIC;
91
92     p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
93
94     if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
95     {
96         msg_Dbg( p_cdda_input, "old CDText Enabled %d, new %d",
97                  p_cdda->b_cdtext, val.b_bool);
98     }
99     p_cdda->b_cdtext = val.b_bool;
100     return VLC_SUCCESS;
101 }
102
103 int
104 CDDANavModeCB( vlc_object_t *p_this, const char *psz_name,
105                         vlc_value_t oldval, vlc_value_t val, void *p_data )
106 {
107     VLC_UNUSED(p_this);
108     VLC_UNUSED(psz_name);
109     VLC_UNUSED(oldval);
110     VLC_UNUSED(p_data);
111     
112     cdda_data_t *p_cdda;
113
114     if (NULL == p_cdda_input) return VLC_EGENERIC;
115
116     p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
117
118     if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
119     {
120         msg_Dbg( p_cdda_input,
121          "old Navigation Mode Enabled %d, new %d",
122                  p_cdda->b_nav_mode, val.b_bool);
123     }
124     p_cdda->b_nav_mode = val.b_bool;
125     return VLC_SUCCESS;
126 }
127
128 int
129 CDTextPreferCB   ( vlc_object_t *p_this, const char *psz_name,
130                        vlc_value_t oldval, vlc_value_t val, void *p_data )
131 {
132     VLC_UNUSED(p_this);
133     VLC_UNUSED(psz_name);
134     VLC_UNUSED(oldval);
135     VLC_UNUSED(p_data);
136     
137     cdda_data_t *p_cdda;
138
139     if (NULL == p_cdda_input) return VLC_EGENERIC;
140
141     p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
142
143 #ifdef HAVE_LIBCDDB
144     if ( p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
145     {
146         msg_Dbg( p_cdda_input, "old CDText Prefer (x%0x) %d, new (x%0x) %d",
147                  p_cdda->b_cdtext_prefer, p_cdda->b_cdtext_prefer,
148                  val.b_bool, val.b_bool);
149     }
150     p_cdda->b_cdtext_prefer = val.b_bool;
151 #endif
152     return VLC_SUCCESS;
153 }
154
155 int
156 CDDABlocksPerReadCB ( vlc_object_t *p_this, const char *psz_name,
157                           vlc_value_t oldval, vlc_value_t val, void *p_data )
158 {
159     VLC_UNUSED(p_this);
160     VLC_UNUSED(psz_name);
161     VLC_UNUSED(oldval);
162     VLC_UNUSED(p_data);
163     
164     cdda_data_t *p_cdda;
165
166     if (NULL == p_cdda_input) return VLC_EGENERIC;
167
168     p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
169
170     if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
171     {
172         msg_Dbg( p_cdda_input, "old blocks per read: %d, new %d",
173                  p_cdda->i_blocks_per_read, val.i_int);
174     }
175
176     if (0 == val.i_int) val.i_int = DEFAULT_BLOCKS_PER_READ;
177     if ( val.i_int >= MIN_BLOCKS_PER_READ && val.i_int <= MAX_BLOCKS_PER_READ )
178          p_cdda->i_blocks_per_read = val.i_int;
179     else
180     {
181         msg_Warn( p_cdda_input,
182              "number of blocks (%d) has to be between %d and %d. No change.",
183               val.i_int, MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ );
184     }
185     return VLC_SUCCESS;
186 }