~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/music/allegro_m.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: allegro_m.cpp 14632 2008-11-25 23:21:58Z rubidium $ */
 
2
 
 
3
/** @file allegro_m.cpp Playing music via allegro. */
 
4
 
 
5
#ifdef WITH_ALLEGRO
 
6
 
 
7
#include "../stdafx.h"
 
8
#include "../debug.h"
 
9
#include "allegro_m.h"
 
10
#include <allegro.h>
 
11
 
 
12
static FMusicDriver_Allegro iFMusicDriver_Allegro;
 
13
static MIDI *_midi = NULL;
 
14
 
 
15
/** There are multiple modules that might be using Allegro and
 
16
 * Allegro can only be initiated once. */
 
17
extern int _allegro_instance_count;
 
18
 
 
19
const char *MusicDriver_Allegro::Start(const char * const *param)
 
20
{
 
21
        if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) return NULL;
 
22
        _allegro_instance_count++;
 
23
 
 
24
        /* Initialise the sound */
 
25
        if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) return NULL;
 
26
 
 
27
        /* Okay, there's no soundcard */
 
28
        if (midi_card == MIDI_NONE) {
 
29
                DEBUG(driver, 0, "allegro: no midi card found");
 
30
        }
 
31
 
 
32
        return NULL;
 
33
}
 
34
 
 
35
void MusicDriver_Allegro::Stop()
 
36
{
 
37
        if (_midi != NULL) destroy_midi(_midi);
 
38
        _midi = NULL;
 
39
 
 
40
        if (--_allegro_instance_count == 0) allegro_exit();
 
41
}
 
42
 
 
43
void MusicDriver_Allegro::PlaySong(const char *filename)
 
44
{
 
45
        if (_midi != NULL) destroy_midi(_midi);
 
46
        _midi = load_midi(filename);
 
47
        play_midi(_midi, false);
 
48
}
 
49
 
 
50
void MusicDriver_Allegro::StopSong()
 
51
{
 
52
        stop_midi();
 
53
}
 
54
 
 
55
bool MusicDriver_Allegro::IsSongPlaying()
 
56
{
 
57
        return midi_pos >= 0;
 
58
}
 
59
 
 
60
void MusicDriver_Allegro::SetVolume(byte vol)
 
61
{
 
62
        set_volume(-1, vol);
 
63
}
 
64
 
 
65
#endif /* WITH_ALLEGRO */