Changeset 1853:345470a7b87b in roaraudio for roard
- Timestamp:
- 05/23/09 11:01:50 (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/include/midi.h
r1852 r1853 75 75 76 76 77 int g_console; 78 int g_midi_cb_stream; 79 80 uint32_t g_midi_cb_stoptime; 81 int g_midi_cb_playing; 77 struct { 78 int console; 79 int stream; 80 uint32_t stoptime; 81 int playing; 82 } g_midi_cb; 82 83 83 84 struct { -
roard/midi.c
r1851 r1853 202 202 }; 203 203 204 g_ console= -1;205 g_midi_cb _stream = -1;206 g_midi_cb _stoptime = 0;207 g_midi_cb _playing = 0;204 g_midi_cb.console = -1; 205 g_midi_cb.stream = -1; 206 g_midi_cb.stoptime = 0; 207 g_midi_cb.playing = 0; 208 208 209 209 for (i = 0; files[i] != NULL; i++) { 210 if ( (g_ console = open(files[i], O_WRONLY|O_NOCTTY, 0)) != -1 )210 if ( (g_midi_cb.console = open(files[i], O_WRONLY|O_NOCTTY, 0)) != -1 ) 211 211 break; 212 212 } 213 213 214 if ( g_ console == -1 )215 return -1; 216 217 if ( (g_midi_cb _stream = streams_new()) == -1 ) {214 if ( g_midi_cb.console == -1 ) 215 return -1; 216 217 if ( (g_midi_cb.stream = streams_new()) == -1 ) { 218 218 ROAR_WARN("Error while initializing MIDI subsystem component CB"); 219 219 midi_cb_free(); … … 221 221 } 222 222 223 midi_vio_set_dummy(g_midi_cb _stream);224 225 streams_get(g_midi_cb _stream, &ss);223 midi_vio_set_dummy(g_midi_cb.stream); 224 225 streams_get(g_midi_cb.stream, &ss); 226 226 s = ROAR_STREAM(ss); 227 227 … … 237 237 s->info.bits = 8; 238 238 239 if ( streams_set_dir(g_midi_cb _stream, ROAR_DIR_BRIDGE, 1) == -1 ) {239 if ( streams_set_dir(g_midi_cb.stream, ROAR_DIR_BRIDGE, 1) == -1 ) { 240 240 ROAR_WARN("Error while initializing MIDI subsystem component CB"); 241 241 midi_cb_free(); … … 243 243 } 244 244 245 streams_set_name(g_midi_cb _stream, "Console speaker bridge");246 247 streams_set_flag(g_midi_cb _stream, ROAR_FLAG_OUTPUT);248 streams_set_flag(g_midi_cb _stream, ROAR_FLAG_PRIMARY);249 streams_set_flag(g_midi_cb _stream, ROAR_FLAG_HWMIXER);245 streams_set_name(g_midi_cb.stream, "Console speaker bridge"); 246 247 streams_set_flag(g_midi_cb.stream, ROAR_FLAG_OUTPUT); 248 streams_set_flag(g_midi_cb.stream, ROAR_FLAG_PRIMARY); 249 streams_set_flag(g_midi_cb.stream, ROAR_FLAG_HWMIXER); 250 250 251 251 return 0; 252 252 #else 253 g_ console= -1;254 g_midi_cb _stream = -1;253 g_midi_cb.console = -1; 254 g_midi_cb.stream = -1; 255 255 256 256 return -1; … … 263 263 midi_cb_stop(); 264 264 265 if ( g_midi_cb _stream != -1 )266 streams_delete(g_midi_cb _stream);267 268 if ( g_ console != -1 )269 close(g_ console);265 if ( g_midi_cb.stream != -1 ) 266 streams_delete(g_midi_cb.stream); 267 268 if ( g_midi_cb.console != -1 ) 269 close(g_midi_cb.console); 270 270 271 271 return 0; … … 282 282 #define MIDI_CB_OVERRIDE 1 283 283 */ 284 if ( g_midi_cb _playing && override != MIDI_CB_OVERRIDE )285 return -1; 286 287 g_midi_cb _stoptime = ROAR_MATH_OVERFLOW_ADD(g_pos, samples_per_sec*t);284 if ( g_midi_cb.playing && override != MIDI_CB_OVERRIDE ) 285 return -1; 286 287 g_midi_cb.stoptime = ROAR_MATH_OVERFLOW_ADD(g_pos, samples_per_sec*t); 288 288 midi_cb_start(freq); 289 g_midi_cb _playing = 1;289 g_midi_cb.playing = 1; 290 290 291 291 return 0; … … 293 293 294 294 int midi_cb_update (void) { 295 if ( !g_midi_cb _playing )295 if ( !g_midi_cb.playing ) 296 296 return 0; 297 297 298 if ( g_midi_cb _stoptime <= g_pos )298 if ( g_midi_cb.stoptime <= g_pos ) 299 299 midi_cb_stop(); 300 300 … … 305 305 // On linux this uses ioctl KIOCSOUND 306 306 #ifdef __linux__ 307 if ( g_ console == -1 )308 return -1; 309 310 if ( ioctl(g_ console, KIOCSOUND, freq == 0 ? 0 : (int)(1193180.0/freq)) == -1 )307 if ( g_midi_cb.console == -1 ) 308 return -1; 309 310 if ( ioctl(g_midi_cb.console, KIOCSOUND, freq == 0 ? 0 : (int)(1193180.0/freq)) == -1 ) 311 311 return -1; 312 312 … … 319 319 int midi_cb_stop (void) { 320 320 #ifdef __linux__ 321 g_midi_cb _playing = 0;321 g_midi_cb.playing = 0; 322 322 return midi_cb_start(0); 323 323 #else
Note: See TracChangeset
for help on using the changeset viewer.