]> git.sesse.net Git - vlc/blob - modules/access/cdda/callback.c
First attempt at adding CD-Text.
[vlc] / modules / access / cdda / callback.c
1 /*****************************************************************************
2  * callback.c : Callbacks for CD digital audio input module
3  *****************************************************************************
4  * Copyright (C) 2004 VideoLAN
5  * $Id: callback.c 8606 2004-08-31 18:32:54Z rocky $
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #include "callback.h"
25 #include "cdda.h"
26
27 int
28 E_(CDDADebugCB)   ( vlc_object_t *p_this, const char *psz_name,
29                     vlc_value_t oldval, vlc_value_t val, void *p_data )
30 {
31   cdda_data_t *p_cdda;
32
33   if (NULL == p_cdda_input) return VLC_EGENERIC;
34
35   p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
36
37   if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
38     msg_Dbg( p_cdda_input, "Old debug (x%0x) %d, new debug (x%0x) %d",
39              p_cdda->i_debug, p_cdda->i_debug, val.i_int, val.i_int);
40   }
41   p_cdda->i_debug = val.i_int;
42   return VLC_SUCCESS;
43 }
44
45 /* FIXME: could probably shorten some of the below boilerplate code...
46 */
47 int
48 E_(CDDBEnabledCB)   ( vlc_object_t *p_this, const char *psz_name,
49                       vlc_value_t oldval, vlc_value_t val, void *p_data )
50 {
51   cdda_data_t *p_cdda;
52
53   if (NULL == p_cdda_input) return VLC_EGENERIC;
54
55   p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
56
57 #ifdef HAVE_LIBCDDB
58   if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
59     msg_Dbg( p_cdda_input, "Old CDDB Enabled (x%0x) %d, new (x%0x) %d",
60              p_cdda->b_cddb_enabled, p_cdda->b_cddb_enabled,
61              val.b_bool, val.b_bool);
62   }
63   p_cdda->b_cddb_enabled = val.b_bool;
64 #endif
65   return VLC_SUCCESS;
66 }
67
68 int
69 E_(CDTextEnabledCB)   ( vlc_object_t *p_this, const char *psz_name,
70                         vlc_value_t oldval, vlc_value_t val, void *p_data )
71 {
72   cdda_data_t *p_cdda;
73
74   if (NULL == p_cdda_input) return VLC_EGENERIC;
75
76   p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
77
78   if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
79     msg_Dbg( p_cdda_input, "Old CDText Enabled (x%0x) %d, new (x%0x) %d",
80              p_cdda->b_cdtext_enabled, p_cdda->b_cdtext_enabled,
81              val.b_bool, val.b_bool);
82   }
83   p_cdda->b_cdtext_enabled = val.b_bool;
84   return VLC_SUCCESS;
85 }
86
87 int
88 E_(CDTextPreferCB)   ( vlc_object_t *p_this, const char *psz_name,
89                        vlc_value_t oldval, vlc_value_t val, void *p_data )
90 {
91   cdda_data_t *p_cdda;
92
93   if (NULL == p_cdda_input) return VLC_EGENERIC;
94
95   p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
96
97 #ifdef HAVE_LIBCDDB
98   if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
99     msg_Dbg( p_cdda_input, "Old CDText Prefer (x%0x) %d, new (x%0x) %d",
100              p_cdda->b_cdtext_prefer, p_cdda->b_cdtext_prefer,
101              val.b_bool, val.b_bool);
102   }
103   p_cdda->b_cdtext_prefer = val.b_bool;
104 #endif
105   return VLC_SUCCESS;
106 }
107
108 int
109 E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name,
110                           vlc_value_t oldval, vlc_value_t val, void *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     msg_Dbg( p_cdda_input, "Old blocks per read: %d, new %d",
120              p_cdda->i_blocks_per_read, val.i_int);
121   }
122
123   if (0 == val.i_int) val.i_int = DEFAULT_BLOCKS_PER_READ;
124   if ( val.i_int >= MIN_BLOCKS_PER_READ && val.i_int <= MAX_BLOCKS_PER_READ )
125     p_cdda->i_blocks_per_read = val.i_int;
126   else {
127     msg_Warn( p_cdda_input, 
128               "Number of blocks (%d) has to be between %d and %d. No change.", 
129               val.i_int, MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ );
130   }
131   
132   return VLC_SUCCESS;
133 }