]> git.sesse.net Git - vlc/blob - modules/access/cdda/callback.c
Allow size of blocks reads to be specified/adjusted
[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 int
46 E_(CDDBEnabledCB)   ( vlc_object_t *p_this, const char *psz_name,
47                       vlc_value_t oldval, vlc_value_t val, void *p_data )
48 {
49   cdda_data_t *p_cdda;
50
51   if (NULL == p_cdda_input) return VLC_EGENERIC;
52
53   p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
54
55 #ifdef HAVE_LIBCDDB
56   if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
57     msg_Dbg( p_cdda_input, "Old CDDB Enabled (x%0x) %d, new (x%0x) %d",
58              p_cdda->i_cddb_enabled, p_cdda->i_cddb_enabled,
59              val.i_int, val.i_int);
60   }
61   p_cdda->i_cddb_enabled = val.i_int;
62 #endif
63   return VLC_SUCCESS;
64 }
65
66 int
67 E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name,
68                           vlc_value_t oldval, vlc_value_t val, void *p_data )
69 {
70   cdda_data_t *p_cdda;
71
72   if (NULL == p_cdda_input) return VLC_EGENERIC;
73
74   p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
75
76   if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
77     msg_Dbg( p_cdda_input, "Old blocks per read: %d, new %d",
78              p_cdda->i_blocks_per_read, val.i_int);
79   }
80
81   if (0 == val.i_int) val.i_int = DEFAULT_BLOCKS_PER_READ;
82   if ( val.i_int >= MIN_BLOCKS_PER_READ && val.i_int <= MAX_BLOCKS_PER_READ )
83     p_cdda->i_blocks_per_read = val.i_int;
84   else {
85     msg_Warn( p_cdda_input, 
86               "Number of blocks (%d) has to be between %d and %d. No change.", 
87               val.i_int, MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ );
88   }
89   
90   return VLC_SUCCESS;
91 }