VirtualBox

source: vbox/trunk/src/VBox/Runtime/testcase/tstIoCtl.cpp@ 1507

Last change on this file since 1507 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1/* $Id: tstIoCtl.cpp 1 1970-01-01 00:00:00Z vboxsync $ */
2/** @file
3 * InnoTek Portable Runtime Testcase - file IoCtl.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25//#include <sys/types.h>
26#include "soundcard.h"
27//#include <VBox/pdm.h>
28#include <VBox/err.h>
29
30#include <iprt/log.h>
31#include <VBox/log.h>
32#define LOG_GROUP LOG_GROUP_DEV_AUDIO
33//#include <iprt/assert.h>
34//#include <iprt/uuid.h>
35//#include <iprt/string.h>
36//#include <iprt/alloc.h>
37#include <iprt/file.h>
38
39//#include "audio.h"
40//#include "audio_int.h"
41
42#include <stdio.h>
43#include <iprt/uuid.h>
44
45#ifdef __L4ENV__
46extern char **__environ;
47char *myenv[] = { "+all.e", NULL };
48#endif
49
50int main()
51{
52#ifdef __L4ENV__
53 __environ = myenv;
54#endif
55 int rcRet = 0;
56 int ret, err;
57 printf("tstIoCtl: TESTING\n");
58
59 RTFILE File;
60
61 if (RT_FAILURE(err = RTFileOpen(&File, "/dev/dsp", (RTFILE_O_READWRITE) | RTFILE_O_NON_BLOCK))) {
62 printf("Fatal error: failed to open /dev/dsp:\n"
63 "VBox error code: %d\n", err);
64 return 1;
65 }
66
67 int rate = 100;
68
69 if (RT_FAILURE(err = RTFileIoCtl(File, SNDCTL_DSP_SPEED, &rate, sizeof(rate), &ret)) || ret) {
70 printf("Failed to set playback speed on /dev/dsp\n"
71 "VBox error code: %d, IOCTL return value: %d\n",
72 err, ret);
73 rcRet++;
74 } else printf("Playback speed successfully set to 100, reported speed is %d\n",
75 rate);
76
77 rate = 48000;
78
79 if (RT_FAILURE(err = RTFileIoCtl(File, SNDCTL_DSP_SPEED, &rate, sizeof(rate), &ret)) || ret) {
80 printf("Failed to set playback speed on /dev/dsp\n"
81 "VBox error code: %d, IOCTL return value: %d\n",
82 err, ret);
83 rcRet++;
84 } else printf("Playback speed successfully set to 48000, reported speed is %d\n",
85 rate);
86
87 /*
88 * Cleanup.
89 */
90 ret = RTFileClose(File);
91 if (RT_FAILURE(ret))
92 {
93 printf("Failed to close /dev/dsp. ret=%d\n", ret);
94 rcRet++;
95 }
96
97 /* Under Linux and L4, this involves ioctls internally */
98 RTUUID TestUuid;
99 if (RT_FAILURE(RTUuidCreate(&TestUuid)))
100 {
101 printf("Failed to create a UUID. ret=%d\n", ret);
102 rcRet++;
103 }
104
105 /*
106 * Summary
107 */
108 if (rcRet == 0)
109 printf("tstIoCtl: SUCCESS\n");
110 else
111 printf("tstIoCtl: FAILURE - %d errors\n", rcRet);
112 return rcRet;
113}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette