Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  TestAudioBuffers.cpp

  Sprache: C
 

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */


#include <stdint.h>
#include "AudioBufferUtils.h"
#include "gtest/gtest.h"
#include <vector>

const uint32_t FRAMES = 256;

void test_for_number_of_channels(const uint32_t channels) {
  const uint32_t samples = channels * FRAMES;

  mozilla::AudioCallbackBufferWrapper<float> mBuffer(channels);
  mozilla::SpillBuffer<float128> b(channels);
  std::vector<float> fromCallback(samples, 0.0);
  std::vector<float> other(samples, 1.0);
  mozilla::AudioChunk chunk;
  chunk.mBufferFormat = mozilla::AUDIO_FORMAT_FLOAT32;
  chunk.mChannelData.SetLength(channels);
  for (uint32_t i = 0; i < channels; ++i) {
    chunk.mChannelData[i] = other.data() + i * channels;
  }

  // Set the buffer in the wrapper from the callback
  mBuffer.SetBuffer(fromCallback.data(), FRAMES);

  // Fill the SpillBuffer with data.
  chunk.mDuration = 15;
  ASSERT_TRUE(b.Fill(chunk) == 15);
  chunk.mDuration = 17;
  ASSERT_TRUE(b.Fill(chunk) == 17);
  for (uint32_t i = 0; i < 32 * channels; i++) {
    other[i] = 0.0;
  }

  // Empty it in the AudioCallbackBufferWrapper
  ASSERT_TRUE(b.Empty(mBuffer) == 32);

  // Check available return something reasonnable
  ASSERT_TRUE(mBuffer.Available() == FRAMES - 32);

  // Fill the buffer with the rest of the data
  mBuffer.WriteFrames(other.data() + 32 * channels, FRAMES - 32);

  // Check the buffer is now full
  ASSERT_TRUE(mBuffer.Available() == 0);

  for (uint32_t i = 0; i < samples; i++) {
    ASSERT_TRUE(fromCallback[i] == 1.0)
    << "Difference at " << i << " (" << fromCallback[i] << " != " << 1.0
    << ")\n";
  }

  chunk.mDuration = FRAMES;
  ASSERT_TRUE(b.Fill(chunk) == 128);
  ASSERT_TRUE(b.Fill(chunk) == 0);
  ASSERT_TRUE(b.Empty(mBuffer) == 0);
}

TEST(AudioBuffers, Test)
{
  for (uint32_t ch = 1; ch <= 8; ++ch) {
    test_for_number_of_channels(ch);
  }
}

Messung V0.5 in Prozent
C=93 H=89 G=90

¤ Dauer der Verarbeitung: 0.16 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik