Debian Codegraph @

src/settings.c

raw
1 /*
2 * Copyright (C) 2000 Rich Wareham <[email protected]>
3 *
4 * This file is part of libdvdnav, a DVD navigation library.
5 *
6 * libdvdnav is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * libdvdnav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with libdvdnav; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <inttypes.h>
26 #include <limits.h>
27 #include <string.h>
28 #include <sys/time.h>
29 #include "dvdnav/dvdnav.h"
30 #include <dvdread/nav_types.h>
31 #include "vm/decoder.h"
32 #include "vm/vm.h"
33 #include "dvdnav_internal.h"
34
35 /* Characteristics/setting API calls */
36
37 dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int32_t *region) {
38 (*region) = this->vm->state.registers.SPRM[20];
39 return DVDNAV_STATUS_OK;
40 }
41
42 dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int32_t mask) {
43 pthread_mutex_lock(&this->vm_lock);
44 this->vm->state.registers.SPRM[20] = (mask & 0xff);
45 pthread_mutex_unlock(&this->vm_lock);
46 return DVDNAV_STATUS_OK;
47 }
48
49 dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int32_t use_readahead) {
50 this->use_read_ahead = use_readahead;
51 return DVDNAV_STATUS_OK;
52 }
53
54 dvdnav_status_t dvdnav_get_readahead_flag(dvdnav_t *this, int32_t *flag) {
55 (*flag) = this->use_read_ahead;
56 return DVDNAV_STATUS_OK;
57 }
58
59 static dvdnav_status_t set_language_register(dvdnav_t *this, char *code, int reg) {
60 if(!code[0] || !code[1]) {
61 printerr("Passed illegal language code.");
62 return DVDNAV_STATUS_ERR;
63 }
64
65 pthread_mutex_lock(&this->vm_lock);
66 this->vm->state.registers.SPRM[reg] = (code[0] << 8) | code[1];
67 pthread_mutex_unlock(&this->vm_lock);
68 return DVDNAV_STATUS_OK;
69 }
70
71 dvdnav_status_t dvdnav_menu_language_select(dvdnav_t *this, char *code) {
72 return set_language_register(this, code, 0);
73 }
74
75 dvdnav_status_t dvdnav_audio_language_select(dvdnav_t *this, char *code) {
76 return set_language_register(this, code, 16);
77 }
78
79 dvdnav_status_t dvdnav_spu_language_select(dvdnav_t *this, char *code) {
80 return set_language_register(this, code, 18);
81 }
82
83 dvdnav_status_t dvdnav_set_PGC_positioning_flag(dvdnav_t *this, int32_t pgc) {
84 this->pgc_based = pgc;
85 return DVDNAV_STATUS_OK;
86 }
87
88 dvdnav_status_t dvdnav_get_PGC_positioning_flag(dvdnav_t *this, int32_t *flag) {
89 (*flag) = this->pgc_based;
90 return DVDNAV_STATUS_OK;
91 }