annotate settings.c @ 99:c5e47a98c883 src

fix possible unlock on not locked mutex
author mroi
date Wed, 18 Sep 2002 14:26:42 +0000
parents e74cba5129a6
children b6834e6359cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
1 /*
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
2 * Copyright (C) 2000 Rich Wareham <richwareham@users.sourceforge.net>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
3 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
4 * This file is part of libdvdnav, a DVD navigation library.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
5 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
6 * libdvdnav is free software; you can redistribute it and/or modify
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
9 * (at your option) any later version.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
10 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
11 * libdvdnav is distributed in the hope that it will be useful,
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
14 * GNU General Public License for more details.
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
15 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
19 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
20 * $Id$
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
21 *
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
22 */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
23
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
25 #include "config.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
26 #endif
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
27
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
28 #include <dvdnav.h>
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
29 #include "dvdnav_internal.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
30
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
31 #include "vm.h"
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
32
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
33 /* Characteristics/setting API calls */
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
34
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
35 dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int *region) {
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
36 if(!this) {
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
37 printerr("Passed a NULL this pointer");
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
38 return S_ERR;
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
39 }
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
40
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
41 if(!region) {
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
42 printerr("Passed a NULL region pointer");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
43 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
44 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
45
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
46 if(!this->vm) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
47 printerr("VM not yet initialised");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
48 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
49 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
50
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
51 (*region) = this->vm->state.registers.SPRM[20];
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
52
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
53 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
54 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
55
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
56 dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int mask) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
57 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
58 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
59
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
60 if(!this->vm) {
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
61 printerr("VM not yet initialised");
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
62 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
63 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
64
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
65 this->vm->state.registers.SPRM[20] = (mask & 0xff);
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
66
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
67 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
68 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
69
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
70 dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int use_readahead) {
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
71 if(!this)
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
72 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
73
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
74 this->use_read_ahead = use_readahead;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
75
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
76 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
77 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
78
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
79 dvdnav_status_t dvdnav_get_readahead_flag(dvdnav_t *this, int* flag) {
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
80 if(!this) {
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
81 printerr("Passed a NULL this pointer");
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
82 return S_ERR;
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
83 }
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
84
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
85 if(!flag) {
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
86 printerr("Passed a NULL flag pointer");
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
87 return S_ERR;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
88 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
89
22
3c1df0cb3aee Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents: 0
diff changeset
90 (*flag) = this->use_read_ahead;
0
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
91 return S_OK;
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
92 }
3ddf0eaece51 Initial revision
richwareham
parents:
diff changeset
93
44
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
94 static dvdnav_status_t set_language_register(dvdnav_t *this, char *code, int reg) {
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
95 if(!this ) {
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
96 printerr("Passed a NULL this pointer");
44
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
97 return S_ERR;
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
98 }
44
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
99
93
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
100 if(!code) {
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
101 printerr("Passed a NULL code pointer");
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
102 return S_ERR;
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
103 }
e74cba5129a6 Small changes to check for invalid parameters.
jcdutton
parents: 44
diff changeset
104
44
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
105 if(!code[0] || !code[1]) {
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
106 printerr("Passed illegal language code");
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
107 return S_ERR;
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
108 }
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
109
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
110 if(!this->vm) {
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
111 printerr("VM not yet initialised");
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
112 return S_ERR;
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
113 }
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
114
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
115 pthread_mutex_lock(&this->vm_lock);
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
116 this->vm->state.registers.SPRM[reg] = (code[0] << 8) | code[1];
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
117 pthread_mutex_unlock(&this->vm_lock);
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
118 return S_OK;
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
119 }
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
120
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
121 dvdnav_status_t dvdnav_menu_language_select(dvdnav_t *this, char *code) {
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
122 return set_language_register(this, code, 0);
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
123 }
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
124
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
125 dvdnav_status_t dvdnav_audio_language_select(dvdnav_t *this, char *code) {
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
126 return set_language_register(this, code, 16);
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
127 }
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
128
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
129 dvdnav_status_t dvdnav_spu_language_select(dvdnav_t *this, char *code) {
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
130 return set_language_register(this, code, 18);
c50cb59dbb19 Add dvd menu language selection api.
jcdutton
parents: 22
diff changeset
131 }