Ejemplo n.º 1
0
        async Task <bool> SendAudioLoop(Stream stm, ChunkList cl, ManifestManager cache)
        {
            bool result = true;

            ChunkBuffer cc;

            while (cl.ChunksQueue.TryDequeue(out cc) == true)
            //foreach (var cc in cl.ChunksQueue)
            //                for (int Index = (int)cl.OutputChunks; Index < (int)cl.InputChunks; Index++)
            {
                //              var cc = cl.ChunksList.Values.ElementAt(Index);
                if ((cc != null) && (cc.GetLength() > 0))
                {
                    ulong res = cc.GetLength();

                    if (res > 0)
                    {
                        if (await SendBuffer(stm, cc.chunkBuffer, cl.Configuration.GetSourceName()) == true)
                        {
                            // Free buffer
                            cc.chunkBuffer  = null;
                            cl.OutputBytes += res;
                            cl.OutputChunks++;
                            cl.MemorySizeForChunks -= res;
                        }
                        else
                        {
                            result = false;
                            LogMessage(Options.LogLevel.Error, "Error while senfing audio chuncks");
                        }
                    }
                    else
                    {
                        result = false;
                        LogMessage(Options.LogLevel.Error, "Error while sending audio chuncks");
                    }
                }
                else
                {
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        bool SendAudioLoop(Stream stm, ChunkList cl, ManifestManager cache)
        {
            bool result = true;

            ChunkBuffer cc;

            while (cl.ChunksQueue.TryDequeue(out cc) == true)
            //foreach (var cc in cl.ChunksQueue)
//                for (int Index = (int)cl.OutputChunks; Index < (int)cl.InputChunks; Index++)
            {
                //              var cc = cl.ChunksList.Values.ElementAt(Index);
                if ((cc != null) && (cc.GetLength() > 0))
                {
                    ulong res = cc.GetLength();

                    if (res > 0)
                    {
                        if (SendBuffer(stm, cc.chunkBuffer, cl.Configuration.GetSourceName()) == true)
                        {
                            // Free buffer
                            cc.chunkBuffer  = null;
                            cl.OutputBytes += res;
                            cl.OutputChunks++;
                        }
                        else
                        {
                            result = false;
                            System.Diagnostics.Debug.WriteLine("Error while senfing audio chuncks");
                        }
                    }
                    else
                    {
                        result = false;
                        System.Diagnostics.Debug.WriteLine("Error while sending audio chuncks");
                    }
                }
                else
                {
                    break;
                }
            }
            return(result);
        }