]> Dogcows Code - chaz/yoink/blobdiff - src/moof/sound_bindings.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / sound_bindings.cc
index 9e81aa34a4aa1880f932bcbb373f5419493b8d05..65bcd0160aee8660da003e7090996aa9c561ec3c 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "script.hh"
 #include "sound.hh"
@@ -18,16 +16,26 @@ namespace moof {
 
 static int sound_new(script& script)
 {
-       script::slot name = script[2].require_string("sound name");
-
        std::string str;
-       name.get(str);
-
-       script.push(sound(str));
+       if (script[2].get(str))
+       {
+               sound sound(str);
+
+               for (int i = 3; script[i]; ++i)
+               {
+                       if (script[i].get(str)) sound.queue(str);
+                       else break;
+               }
+
+               script.push(sound);
+               return 1;
+       }
+       
+       script.push(sound());
        return 1;
 }
 
-static int sound_enqueue(script& script)
+static int sound_sample(script& script)
 {
        sound* sound;
        script[1].require_object<moof::sound>("sound").get(sound);
@@ -35,39 +43,45 @@ static int sound_enqueue(script& script)
        std::string name;
        script[2].require_string("sound name").get(name);
 
-       sound->enqueue(name);
+       sound->sample(name);
        return 0;
 }
 
-static int sound_play(script& script)
+static int sound_queue(script& script)
 {
        sound* sound;
        script[1].require_object<moof::sound>("sound").get(sound);
-       sound->play();
+
+       std::string name;
+       for (int i = 2; script[i]; ++i)
+       {
+               if (script[i].get(name)) sound->queue(name);
+               else break;
+       }
        return 0;
 }
 
-static int sound_stop(script& script)
+static int sound_play(script& script)
 {
        sound* sound;
        script[1].require_object<moof::sound>("sound").get(sound);
-       sound->stop();
+       sound->play();
        return 0;
 }
 
-static int sound_pause(script& script)
+static int sound_stop(script& script)
 {
        sound* sound;
        script[1].require_object<moof::sound>("sound").get(sound);
-       sound->pause();
+       sound->stop();
        return 0;
 }
 
-static int sound_rewind(script& script)
+static int sound_pause(script& script)
 {
        sound* sound;
        script[1].require_object<moof::sound>("sound").get(sound);
-       sound->rewind();
+       sound->pause();
        return 0;
 }
 
@@ -87,7 +101,6 @@ static int sound_is_playing(script& script)
        return 1;
 }
 
-
 void sound::import(script& script, const std::string& nspace)
 {
        script.check_stack(4);
@@ -95,13 +108,13 @@ void sound::import(script& script, const std::string& nspace)
        script::slot parent = script.push_table(nspace);
        script::slot meta = script.push_class<sound>(sound_new);
 
-       meta.set_field("enqueue", sound_enqueue);
+       meta.set_field("is_playing", sound_is_playing);
+       meta.set_field("pause", sound_pause);
        meta.set_field("play", sound_play);
+       meta.set_field("queue", sound_queue);
+       meta.set_field("sample", sound_sample);
        meta.set_field("stop", sound_stop);
-       meta.set_field("pause", sound_pause);
-       meta.set_field("rewind", sound_rewind);
        meta.set_field("toggle", sound_toggle);
-       meta.set_field("is_playing", sound_is_playing);
 
        parent.set_field("sound");
        parent.pop();
This page took 0.021036 seconds and 4 git commands to generate.