diff options
author | ben <benjaminfranzke@googlemail.com> | 2010-07-12 11:24:25 +0200 |
---|---|---|
committer | ben <benjaminfranzke@googlemail.com> | 2010-07-12 11:24:25 +0200 |
commit | 56c5f9340057766c66a7814ab71c111eb0d83cdb (patch) | |
tree | 741b32f74fb68a0073ebb0b28bff4a27ced21fec /sink.c | |
parent | f4d6dba742eda3b32d9140d606b2a5d54bc34d38 (diff) | |
download | pa-sink-ctl-56c5f9340057766c66a7814ab71c111eb0d83cdb.tar.gz pa-sink-ctl-56c5f9340057766c66a7814ab71c111eb0d83cdb.tar.bz2 pa-sink-ctl-56c5f9340057766c66a7814ab71c111eb0d83cdb.zip |
move sources to src/
Diffstat (limited to 'sink.c')
-rw-r--r-- | sink.c | 93 |
1 files changed, 0 insertions, 93 deletions
@@ -1,93 +0,0 @@ -#include <stdio.h> -#include <pulse/pulseaudio.h> -#include <ncurses.h> -#include <string.h> -#include <stdlib.h> - -#include "sink_input.h" -#include "sink.h" - -/* - * return an initilized sink - */ -sink_info* sink_init(void) { - - sink_info* sink = (sink_info*) calloc(1, sizeof(sink_info)); - - sink->name = NULL; - sink->input_counter = 0; - sink->input_max = 1; - sink->input_list = NULL; - - sink->input_list = sink_input_list_init(sink->input_max); - - return sink; -} - -/* - * frees all components of a sink - */ -void sink_clear(sink_info* sink) { - - if (sink->name != NULL) - free(sink->name); - - sink_input_list_clear(sink->input_list, &sink->input_max); - - free(sink); - sink = NULL; -} - -void sink_check(sink_info** sink) { - - if ((*sink) == NULL) - (*sink) = (sink_info*) calloc(1, sizeof(sink_input_info)); -} -/* - * check the list length and resize the list, if current position = max - */ -void sink_list_check(sink_info** sink_list, uint32_t* max, uint32_t counter) { - if (counter >= (*max)) { - (*max) *= 2; - sink_list = (sink_info**) realloc(sink_list, (*max) * sizeof(sink_info*)); - for (int i = counter; i < (*max); ++i) - sink_list[i] = NULL; - } -} - -void sink_check_input_list(sink_info* sink) { - - if (sink->input_counter >= sink->input_max) - sink_input_list_enlarge(sink->input_list, &sink->input_max, sink->input_counter); -} - -sink_info** sink_list_init(uint32_t max) { - - sink_info** sink_list = (sink_info**) calloc(max, sizeof(sink_info*)); - - for (int i = 0; i < max; ++i) - sink_list[i] = NULL; - - return sink_list; -} - -void sink_list_reset(sink_info** sink_list, uint32_t* counter) { - - for (int i = 0; i < (*counter); ++i) - sink_list[i]->input_counter = 0; - - (*counter) = 0; -} - -void sink_list_clear(sink_info** sink_list, uint32_t* max, uint32_t* counter) { - - for (int i = 0; i < (*max); ++i) - if (sink_list[i] != NULL) - sink_clear(sink_list[i]); - - (*max) = 0; - (*counter) = 0; - - free(sink_list); - sink_list = NULL; -} |