Added a sinewave audio test source
- Added a test audio sinewave test source that should just play a sine wave of the middle C note. Using unsigned 8 bit mono to test ffmpeg's audio resampler, seems to work pretty good. - Fixed a boolean trap in threading.h for the event_init function, it now uses enum event_type, which can be EVENT_TYPE_MANUAL or EVENT_TYPE_AUTO, to specify whether the event is automatically reset or not. - Changed display names of test sources to something a little less vague. - Removed te whole "if timestamp is 0 just use current system time" when outputting source audio, if you want to use system time you should just use system time yourself. Using 0 as some sort of "indicator" like that just makes things confusing, and prevents you from legitimately using 0 as a timestamp for your audio data.
This commit is contained in:
@@ -38,8 +38,8 @@ struct audio_line {
|
||||
* buffer is depleted, it's destroyed */
|
||||
bool alive;
|
||||
|
||||
struct audio_line **prev_next;
|
||||
struct audio_line *next;
|
||||
struct audio_line **prev_next;
|
||||
struct audio_line *next;
|
||||
};
|
||||
|
||||
static inline void audio_line_destroy_data(struct audio_line *line)
|
||||
@@ -130,7 +130,7 @@ static void mix_audio_lines(struct audio_output *audio, uint64_t audio_time,
|
||||
while (line) {
|
||||
struct audio_line *next = line->next;
|
||||
|
||||
if (line->base_timestamp < prev_time) {
|
||||
if (line->buffer.size && line->base_timestamp < prev_time) {
|
||||
clear_excess_audio_data(line,
|
||||
line->base_timestamp - prev_time);
|
||||
line->base_timestamp = prev_time;
|
||||
@@ -222,7 +222,7 @@ int audio_output_open(audio_t *audio, media_t media, struct audio_info *info)
|
||||
goto fail;
|
||||
if (pthread_mutex_init(&out->line_mutex, &attr) != 0)
|
||||
goto fail;
|
||||
if (event_init(&out->stop_event, true) != 0)
|
||||
if (event_init(&out->stop_event, EVENT_TYPE_MANUAL) != 0)
|
||||
goto fail;
|
||||
if (!ao_add_to_media(out))
|
||||
goto fail;
|
||||
@@ -243,6 +243,7 @@ audio_line_t audio_output_createline(audio_t audio, const char *name)
|
||||
struct audio_line *line = bmalloc(sizeof(struct audio_line));
|
||||
memset(line, 0, sizeof(struct audio_line));
|
||||
line->alive = true;
|
||||
line->audio = audio;
|
||||
|
||||
if (pthread_mutex_init(&line->mutex, NULL) != 0) {
|
||||
blog(LOG_ERROR, "audio_output_createline: Failed to create "
|
||||
@@ -393,8 +394,8 @@ static inline void mul_vol_float(struct audio_line *line, float volume,
|
||||
static void audio_line_place_data(struct audio_line *line,
|
||||
const struct audio_data *data, size_t position)
|
||||
{
|
||||
size_t total_size = data->frames * line->audio->block_size;
|
||||
size_t total_num = data->frames * line->audio->channels;
|
||||
size_t total_size = data->frames * line->audio->block_size;
|
||||
|
||||
da_copy_array(line->volume_buffer, data->data, total_size);
|
||||
|
||||
|
@@ -115,9 +115,9 @@ int video_output_open(video_t *video, media_t media, struct video_info *info)
|
||||
|
||||
if (pthread_mutex_init(&out->data_mutex, NULL) != 0)
|
||||
goto fail;
|
||||
if (event_init(&out->stop_event, true) != 0)
|
||||
if (event_init(&out->stop_event, EVENT_TYPE_MANUAL) != 0)
|
||||
goto fail;
|
||||
if (event_init(&out->update_event, false) != 0)
|
||||
if (event_init(&out->update_event, EVENT_TYPE_AUTO) != 0)
|
||||
goto fail;
|
||||
if (!vo_add_to_media(out))
|
||||
goto fail;
|
||||
|
Reference in New Issue
Block a user