Exemple #1
0
        /// <summary>
        /// Reads audio data from the audio input buffer.
        /// </summary>
        /// <param name="count">The number of bytes to be read.</param>
        /// <returns>The buffer of audio data captured.</returns>
        /// <exception cref="InvalidOperationException">The current state is not <see cref="AudioIOState.Running"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="count"/> is equal to or less than zero.</exception>
        /// <exception cref="ObjectDisposedException">The AudioCapture has already been disposed of.</exception>
        /// <since_tizen> 3 </since_tizen>
        public byte[] Read(int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count), count,
                                                      $"{ nameof(count) } can't be equal to or less than zero.");
            }
            ValidateState(AudioIOState.Running);

            byte[] buffer = new byte[count];

            AudioInput.Read(_handle, buffer, count).ThrowIfFailed("Failed to read.");

            return(buffer);
        }