summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-08-20 23:50:38 +0200
committerArun Raghavan <arun.raghavan@collabora.co.uk>2012-10-23 12:12:37 +0530
commitb342daded9f3eed967637bc32ae066bce827c81d (patch)
treee2cd6b53557e6729d6abc14d37db9f720257cb4a /src/utils
parentc327850d9e4479a0572b7baaf8dafd737586e5a1 (diff)
pacat: Replace read(), write() with pa_* equivalent.
Calling pa_read() and pa_write() seems more appropriate since they deal better with platform specific issues. This doesn't actually fix any open issue since only stdio is affected but it seems more future proof.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/pacat.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 734017cd1..2cd8aa588 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -539,7 +539,7 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even
buffer = pa_xmalloc(l);
- if ((r = read(fd, buffer, l)) <= 0) {
+ if ((r = pa_read(fd, buffer, l, userdata)) <= 0) {
if (r == 0) {
if (verbose)
pa_log(_("Got EOF."));
@@ -578,7 +578,7 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve
pa_assert(buffer_length);
- if ((r = write(fd, (uint8_t*) buffer+buffer_index, buffer_length)) <= 0) {
+ if ((r = pa_write(fd, (uint8_t*) buffer+buffer_index, buffer_length, userdata)) <= 0) {
pa_log(_("write() failed: %s"), strerror(errno));
quit(1);
@@ -718,6 +718,8 @@ int main(int argc, char *argv[]) {
char *bn, *server = NULL;
pa_time_event *time_event = NULL;
const char *filename = NULL;
+ /* type for pa_read/_write. passed as userdata to the callbacks */
+ unsigned long type = 0;
static const struct option long_options[] = {
{"record", 0, NULL, 'r'},
@@ -1136,7 +1138,7 @@ int main(int argc, char *argv[]) {
if (!(stdio_event = mainloop_api->io_new(mainloop_api,
mode == PLAYBACK ? STDIN_FILENO : STDOUT_FILENO,
mode == PLAYBACK ? PA_IO_EVENT_INPUT : PA_IO_EVENT_OUTPUT,
- mode == PLAYBACK ? stdin_callback : stdout_callback, NULL))) {
+ mode == PLAYBACK ? stdin_callback : stdout_callback, &type))) {
pa_log(_("io_new() failed."));
goto quit;
}