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 
23 #include <basis/utf_conversion.h>
24 #include <basis/astring.h>
26 #include <loggers/console_logger.h>
28 
29 #ifdef __WIN32__
30  #include <mmsystem.h>
31 #endif
32 
33 using namespace basis;
34 using namespace loggers;
35 using namespace structures;
36 
38 //hmmm: this needs to arise from obscurity too?
39 
40 int main(int argc, char *argv[])
41 {
42  console_logger out;
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];
51 out.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:
69  #include <basis/astring.cpp>
70  #include <basis/common_outcomes.cpp>
71  #include <basis/environment.cpp>
72  #include <basis/guards.cpp>
73  #include <basis/mutex.cpp>
74  #include <basis/utf_conversion.cpp>
81  #include <filesystem/byte_filer.cpp>
82  #include <filesystem/directory.cpp>
83  #include <filesystem/filename.cpp>
86  #include <structures/checksums.cpp>
92  #include <textual/parser_bits.cpp>
93  #include <timely/earth_time.cpp>
94  #include <timely/time_stamp.cpp>
95 #endif // __BUILD_STATIC_APPLICATION__
96 
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.