feisty meow concerns codebase 2.140
playsound.cpp
Go to the documentation of this file.
1/*****************************************************************************\
2* *
3* Name : playsound *
4* Author : Chris Koeritz *
5* *
6* Purpose: *
7* *
8* A program intended to be as simple as possible and to play only WAV *
9* files on the win32 platform. It was decided that this was needed because *
10* windows media player suddenly became political and started complaining *
11* when other programs were registered to play different sound types. *
12* All this does is play WAV files. That's it. *
13* *
14*******************************************************************************
15* Copyright (c) 2000-$now By Author. This program is free software; you can *
16* redistribute it and/or modify it under the terms of the GNU General Public *
17* License as published by the Free Software Foundation; either version 2 of *
18* the License or (at your option) any later version. This is online at: *
19* http://www.fsf.org/copyleft/gpl.html *
20* Please send any updates to: fred@gruntose.com *
21\*****************************************************************************/
22
24#include <basis/astring.h>
28
29#ifdef __WIN32__
30 #include <mmsystem.h>
31#endif
32
33using namespace basis;
34using namespace loggers;
35using namespace structures;
36
38//hmmm: this needs to arise from obscurity too?
39
40int main(int argc, char *argv[])
41{
43 if (argc < 2) {
44 out.log(astring(argv[0]) + " usage:", ALWAYS_PRINT);
45 out.log(astring("This program takes one or more parameters which are interpreted"), ALWAYS_PRINT);
46 out.log(astring("as the names of sound files."), ALWAYS_PRINT);
47 return 12;
48 }
49 for (int i = 1; i < argc; i++) {
50 astring sound_file = argv[i];
51out.log(a_sprintf("soundfile %d: %s", i, sound_file.s()), ALWAYS_PRINT);
52 if (sound_file.ends(".mp3")) {
53 out.log(astring("skipping MP3 file ") + sound_file, ALWAYS_PRINT);
54 continue;
55 }
56#ifdef __WIN32__
57 if (!PlaySound(to_unicode_temp(sound_file), NULL_POINTER, SND_FILENAME))
58 out.log(astring("failed to play ") + sound_file, ALWAYS_PRINT);
59#else
60 out.log(astring("this program is a NO-OP, ignoring ") + sound_file, ALWAYS_PRINT);
61#endif
62 }
63 return 0;
64}
65
66#ifdef __BUILD_STATIC_APPLICATION__
67 // static dependencies found by buildor_gen_deps.sh:
68 #include <algorithms/sorts.cpp>
71 #include <basis/astring.cpp>
73 #include <basis/environment.cpp>
74 #include <basis/guards.cpp>
75 #include <basis/mutex.cpp>
95 #include <timely/earth_time.cpp>
96 #include <timely/time_stamp.cpp>
97#endif // __BUILD_STATIC_APPLICATION__
98
a_sprintf is a specialization of astring that provides printf style support.
Definition astring.h:440
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
Definition astring.h:113
bool ends(const astring &maybe_suffix) const
returns true if this string ends with "maybe_suffix".
Definition astring.h:187
virtual basis::outcome log(const basis::base_string &info, int filter)
sends the string "info" to the standard output device.
#define NULL_POINTER
The value representing a pointer to nothing.
Definition definitions.h:32
The guards collection helps in testing preconditions and reporting errors.
Definition array.h:30
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.
Definition amorph.h:55
int main(int argc, char *argv[])
HOOPLE_STARTUP_CODE;.
Definition playsound.cpp:40
Support for unicode builds.
Aids in achievement of platform independence.