Esempio n. 1
0
        public int playList(int _list, string soundDir)
        {
            _soundDir = soundDir;
            lock (sound_lists)
            {
                if (current_list_id != -1)
                {
                    /* playing */
                    int next = (current_list_id + 1) % MAX_LISTS;

                    if (sound_lists[next] != null)
                    {
                        SoundList list =
                            (SoundList)CRunTime.getRegisteredObject(sound_lists[next].Value);

                        if ((list.flags & SoundList.SOUND_LIST_NO_FREE) == 0)
                        {
                            listFree(sound_lists[next].Value);
                        }
                    }

                    sound_lists[next] = new int?(_list);

                    return(0);
                }
            }

            /* not playing */
            sound_lists[0] = new int?(_list);
            playNextList();

            return(0);
        }
Esempio n. 2
0
        private void playNextList()
        {
            lock (sound_lists)
            {
                current_list_id = (current_list_id + 1) % MAX_LISTS;

                if (sound_lists[current_list_id] == null)
                {
                    /* nothing to play */
                    current_list_id = -1;
                }
            }
            if (current_list_id == -1)
            {
                return;
            }

            current_list_item = 0;
            current_list      = (SoundList)CRunTime.getRegisteredObject(sound_lists[current_list_id].Value);
            if ((current_list.streams == null) || (current_list.streams.Length != current_list.count))
            {
                current_list.streams = new Stream[current_list.count];
            }
            for (int i = 0; i < current_list.count; i++)
            {
                try
                {
                    if (_soundDir.Equals(""))
                    {
                        current_list.streams[i] = App.GetResourceStream(new Uri(current_list.list[i], UriKind.Relative)).Stream;
                    }
                    else
                    { // This is a downloaded
                        lock (sound_lists)
                        {
                            if (Syscalls.FileExists(_soundDir + "/" + current_list.list[i]))
                            {
                                current_list.streams[i] = Syscalls.GetFileStream(_soundDir + "/" + current_list.list[i], FileMode.Open);
                            }
                            else
                            {
                                Logger.log("Could not find sound file : " + _soundDir + "/" + current_list.list[i]);
                                UIWorker.addUIEventLog("Could not find sound file : " + _soundDir + "/" + current_list.list[i]);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.log("Error creating sound stream:" + current_list.list[i] + "excp :  " + e);
                    UIWorker.addUIEventLog("Error creating sound stream:" + current_list.list[i] + "excp :  " + e);
                }
            }

            playNextItem();
        }
Esempio n. 3
0
        public int listAdd(int _list, string name)
        {
            SoundList list = (SoundList)CRunTime.getRegisteredObject(_list);

            if (list.count == SoundList.MAX_SOUND_LIST)
            {
                return(-1);
            }
            list.list[list.count] = name + ".wav";
            list.count++;
            return(list.count - 1);
        }
Esempio n. 4
0
    public static Object deRegisterObject(int handle)
    {
        Object lout = CRunTime.getRegisteredObject(handle);

        if (handle == 0)
        {
            return(lout);
        }

        if (CRunTime.firstFree > handle)
        {
            CRunTime.firstFree = handle;
        }
        CRunTime.objectRepository[handle] = null;

        return(lout);
    }
Esempio n. 5
0
        public int listCount(int _list)
        {
            SoundList list = (SoundList)CRunTime.getRegisteredObject(_list);

            return(list.count);
        }
Esempio n. 6
0
 public static void printType(int handle)
 {
     Object obj = CRunTime.getRegisteredObject(handle);
     Logger.log("Type is " + obj);
 }