RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 1.39
diff -u -r1.39 imuse.cpp
|
|
|
323 | 323 | friend struct Player; |
324 | 324 | private: |
325 | 325 | IMuseDriver * _driver; |
| 326 | OSystem *_system; |
326 | 327 | |
327 | 328 | byte **_base_sounds; |
328 | 329 | |
329 | | byte _locked; |
| 330 | void *_locked; |
330 | 331 | byte _hardware_type; |
331 | 332 | |
332 | 333 | private: |
… |
… |
|
759 | 760 | |
760 | 761 | void IMuseInternal::lock() |
761 | 762 | { |
762 | | _locked++; |
| 763 | _system->lock_mutex (_locked); |
763 | 764 | } |
764 | 765 | |
765 | 766 | void IMuseInternal::unlock() |
766 | 767 | { |
767 | | _locked--; |
| 768 | _system->unlock_mutex (_locked); |
768 | 769 | } |
769 | 770 | |
770 | 771 | byte *IMuseInternal::findTag(int sound, char *tag, int index) |
… |
… |
|
868 | 869 | return false; |
869 | 870 | } |
870 | 871 | } |
| 872 | |
| 873 | lock(); |
871 | 874 | player = allocate_player(128); |
872 | | if (!player) |
| 875 | if (!player) { |
| 876 | unlock(); |
873 | 877 | return false; |
| 878 | } |
874 | 879 | |
875 | 880 | player->clear(); |
876 | | return player->start_sound(sound); |
| 881 | bool ret = player->start_sound(sound); |
| 882 | unlock(); |
| 883 | return ret; |
877 | 884 | } |
878 | 885 | |
879 | 886 | |
… |
… |
|
955 | 962 | |
956 | 963 | for (i = ARRAYSIZE(_players); i != 0; i--, player++) { |
957 | 964 | if (player->_active && player->_id == sound) { |
| 965 | lock(); |
958 | 966 | player->clear(); |
| 967 | unlock(); |
959 | 968 | r = 0; |
960 | 969 | } |
961 | 970 | } |
… |
… |
|
967 | 976 | Player *player = _players; |
968 | 977 | int i; |
969 | 978 | |
| 979 | lock(); |
970 | 980 | for (i = ARRAYSIZE(_players); i != 0; i--, player++) { |
971 | 981 | if (player->_active) |
972 | 982 | player->clear(); |
973 | 983 | } |
| 984 | unlock(); |
974 | 985 | return 0; |
975 | 986 | } |
976 | 987 | |
977 | 988 | void IMuseInternal::on_timer() |
978 | 989 | { |
979 | | if (_locked || _paused) |
| 990 | if (_paused) |
980 | 991 | return; |
981 | 992 | |
982 | 993 | lock(); |
… |
… |
|
1190 | 1201 | // sound now?" So if the sound is about to fade out, |
1191 | 1202 | // shut it down and pretend it wasn't playing. |
1192 | 1203 | if (player->is_fading_out()) { |
| 1204 | lock(); |
1193 | 1205 | player->clear(); |
| 1206 | unlock(); |
1194 | 1207 | continue; |
1195 | 1208 | } |
1196 | 1209 | return 1; |
… |
… |
|
1350 | 1363 | vol = vol * _music_volume / 128; |
1351 | 1364 | |
1352 | 1365 | _master_volume = vol; |
| 1366 | lock(); |
1353 | 1367 | for (int i = 0; i != 8; i++) |
1354 | 1368 | _channel_volume_eff[i] = (_channel_volume[i] + 1) * vol >> 7; |
1355 | 1369 | update_volumes(); |
1356 | 1370 | |
| 1371 | unlock(); |
1357 | 1372 | return 0; |
1358 | 1373 | } |
1359 | 1374 | |
… |
… |
|
1378 | 1393 | delete _driver; |
1379 | 1394 | _driver = NULL; |
1380 | 1395 | } |
| 1396 | _system->delete_mutex (_locked); |
1381 | 1397 | return 0; |
1382 | 1398 | /* not implemented */ |
1383 | 1399 | } |
… |
… |
|
1439 | 1455 | |
1440 | 1456 | for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) { |
1441 | 1457 | if (player->_active && player->_id == (uint16)b) { |
| 1458 | lock(); |
1442 | 1459 | player->fade_vol(e, f); |
| 1460 | unlock(); |
1443 | 1461 | return 0; |
1444 | 1462 | } |
1445 | 1463 | } |
… |
… |
|
1449 | 1467 | Player *player; |
1450 | 1468 | for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) { |
1451 | 1469 | if (player->_active && player->_id == (uint16)b) { |
| 1470 | lock(); |
1452 | 1471 | player->jump(player->_track_index + 1, 0, 0); |
| 1472 | unlock(); |
1453 | 1473 | return 0; |
1454 | 1474 | } |
1455 | 1475 | } |
… |
… |
|
1485 | 1505 | } |
1486 | 1506 | } |
1487 | 1507 | |
| 1508 | int32 ret = -1; |
| 1509 | lock(); |
| 1510 | |
1488 | 1511 | switch (cmd) { |
1489 | 1512 | case 0: |
1490 | | return player->get_param(c, d); |
| 1513 | ret = player->get_param(c, d); break; |
1491 | 1514 | case 1: |
1492 | 1515 | player->set_priority(c); |
1493 | | return 0; |
| 1516 | ret = 0; break; |
1494 | 1517 | case 2: |
1495 | | return player->set_vol(c); |
| 1518 | ret = player->set_vol(c); break; |
1496 | 1519 | case 3: |
1497 | 1520 | player->set_pan(c); |
1498 | | return 0; |
| 1521 | ret = 0; break; |
1499 | 1522 | case 4: |
1500 | | return player->set_transpose(c, d); |
| 1523 | ret = player->set_transpose(c, d); break; |
1501 | 1524 | case 5: |
1502 | 1525 | player->set_detune(c); |
1503 | | return 0; |
| 1526 | ret = 0; break; |
1504 | 1527 | case 6: |
1505 | 1528 | player->set_speed(c); |
1506 | | return 0; |
| 1529 | ret = 0; break; |
1507 | 1530 | case 7: |
1508 | | return player->jump(c, d, e) ? 0 : -1; |
| 1531 | ret = player->jump(c, d, e) ? 0 : -1; break; |
1509 | 1532 | case 8: |
1510 | | return player->scan(c, d, e); |
| 1533 | ret = player->scan(c, d, e); break; |
1511 | 1534 | case 9: |
1512 | | return player->set_loop(c, d, e, f, g) ? 0 : -1; |
| 1535 | ret = player->set_loop(c, d, e, f, g) ? 0 : -1; break; |
1513 | 1536 | case 10: |
1514 | 1537 | player->clear_loop(); |
1515 | | return 0; |
| 1538 | ret = 0; break; |
1516 | 1539 | case 11: |
1517 | 1540 | ((Part *)player)->set_onoff(d != 0); |
1518 | | return 0; |
| 1541 | ret = 0; break; |
1519 | 1542 | case 12: |
1520 | | return player->_hook.set(c, d, e); |
| 1543 | ret = player->_hook.set(c, d, e); break; |
1521 | 1544 | case 13: |
1522 | | return player->fade_vol(c, d); |
| 1545 | ret = player->fade_vol(c, d); break; |
1523 | 1546 | case 14: |
1524 | | return enqueue_trigger(b, c); |
| 1547 | ret = enqueue_trigger(b, c); break; |
1525 | 1548 | case 15: |
1526 | | return enqueue_command(b, c, d, e, f, g, h); |
| 1549 | ret = enqueue_command(b, c, d, e, f, g, h); break; |
1527 | 1550 | case 16: |
1528 | | return clear_queue(); |
| 1551 | ret = clear_queue(); break; |
1529 | 1552 | case 19: |
1530 | | return player->get_param(c, d); |
| 1553 | ret = player->get_param(c, d); break; |
1531 | 1554 | case 20: |
1532 | | return player->_hook.set(c, d, e); |
| 1555 | ret = player->_hook.set(c, d, e); break; |
1533 | 1556 | case 21: |
1534 | | return -1; |
| 1557 | ret = -1; break; |
1535 | 1558 | case 22: |
1536 | 1559 | ((Part *)player)->set_vol(d); |
1537 | | return 0; |
| 1560 | ret = 0; break; |
1538 | 1561 | case 23: |
1539 | | return query_queue(b); |
| 1562 | ret = query_queue(b); break; |
1540 | 1563 | case 24: |
1541 | | return 0; |
| 1564 | ret = 0; break; |
1542 | 1565 | default: |
1543 | 1566 | warning("IMuseInternal::do_command default midi command %d", cmd); |
1544 | | return -1; |
| 1567 | ret = -1; |
1545 | 1568 | } |
| 1569 | |
| 1570 | unlock(); |
| 1571 | return ret; |
1546 | 1572 | } |
1547 | 1573 | |
1548 | 1574 | return -1; |
… |
… |
|
1713 | 1739 | driv = new IMuseGM(midi); |
1714 | 1740 | } |
1715 | 1741 | |
| 1742 | _system = syst; |
1716 | 1743 | _driver = driv; |
1717 | 1744 | _hardware_type = driv->get_hardware_type(); |
1718 | 1745 | _game_tempo = driv->get_base_tempo(); |
1719 | 1746 | |
| 1747 | _locked = _system->create_mutex(); |
1720 | 1748 | driv->init(this, syst); |
1721 | 1749 | |
1722 | 1750 | _master_volume = 127; |
… |
… |
|
3011 | 3039 | MKEND() |
3012 | 3040 | }; |
3013 | 3041 | |
| 3042 | lock(); |
| 3043 | |
3014 | 3044 | if (!ser->isSaving()) { |
3015 | 3045 | stop_all_sounds(); |
3016 | 3046 | } |
3017 | 3047 | #ifdef _WIN32_WCE // Don't break savegames made with andys' build |
3018 | | if (!ser->isSaving() && ser->checkEOFLoadStream()) |
| 3048 | if (!ser->isSaving() && ser->checkEOFLoadStream()) { |
| 3049 | unlock(); |
3019 | 3050 | return 0; |
| 3051 | } |
3020 | 3052 | #endif |
3021 | 3053 | |
3022 | 3054 | ser->_ref_me = this; |
… |
… |
|
3037 | 3069 | _driver->update_pris(); |
3038 | 3070 | } |
3039 | 3071 | |
| 3072 | unlock(); |
3040 | 3073 | return 0; |
3041 | 3074 | } |
3042 | 3075 | |