1 | /* $Id: tstIoCtl.cpp 4071 2007-08-07 17:07:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * innotek Portable Runtime Testcase - file IoCtl.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek 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 |
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | //#include <sys/types.h>
|
---|
22 | #include "soundcard.h"
|
---|
23 | //#include <VBox/pdm.h>
|
---|
24 | #include <VBox/err.h>
|
---|
25 |
|
---|
26 | #include <iprt/log.h>
|
---|
27 | #include <VBox/log.h>
|
---|
28 | #define LOG_GROUP LOG_GROUP_DEV_AUDIO
|
---|
29 | //#include <iprt/assert.h>
|
---|
30 | //#include <iprt/uuid.h>
|
---|
31 | //#include <iprt/string.h>
|
---|
32 | //#include <iprt/alloc.h>
|
---|
33 | #include <iprt/file.h>
|
---|
34 |
|
---|
35 | //#include "audio.h"
|
---|
36 | //#include "audio_int.h"
|
---|
37 |
|
---|
38 | #include <stdio.h>
|
---|
39 | #include <iprt/uuid.h>
|
---|
40 |
|
---|
41 | #ifdef RT_OS_L4
|
---|
42 | extern char **__environ;
|
---|
43 | char *myenv[] = { "+all.e", NULL };
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | int main()
|
---|
47 | {
|
---|
48 | #ifdef RT_OS_L4
|
---|
49 | __environ = myenv;
|
---|
50 | #endif
|
---|
51 | int rcRet = 0;
|
---|
52 | int ret, err;
|
---|
53 | printf("tstIoCtl: TESTING\n");
|
---|
54 |
|
---|
55 | RTFILE File;
|
---|
56 |
|
---|
57 | if (RT_FAILURE(err = RTFileOpen(&File, "/dev/dsp", (RTFILE_O_READWRITE) | RTFILE_O_NON_BLOCK))) {
|
---|
58 | printf("Fatal error: failed to open /dev/dsp:\n"
|
---|
59 | "VBox error code: %d\n", err);
|
---|
60 | return 1;
|
---|
61 | }
|
---|
62 |
|
---|
63 | int rate = 100;
|
---|
64 |
|
---|
65 | if (RT_FAILURE(err = RTFileIoCtl(File, SNDCTL_DSP_SPEED, &rate, sizeof(rate), &ret)) || ret) {
|
---|
66 | printf("Failed to set playback speed on /dev/dsp\n"
|
---|
67 | "VBox error code: %d, IOCTL return value: %d\n",
|
---|
68 | err, ret);
|
---|
69 | rcRet++;
|
---|
70 | } else printf("Playback speed successfully set to 100, reported speed is %d\n",
|
---|
71 | rate);
|
---|
72 |
|
---|
73 | rate = 48000;
|
---|
74 |
|
---|
75 | if (RT_FAILURE(err = RTFileIoCtl(File, SNDCTL_DSP_SPEED, &rate, sizeof(rate), &ret)) || ret) {
|
---|
76 | printf("Failed to set playback speed on /dev/dsp\n"
|
---|
77 | "VBox error code: %d, IOCTL return value: %d\n",
|
---|
78 | err, ret);
|
---|
79 | rcRet++;
|
---|
80 | } else printf("Playback speed successfully set to 48000, reported speed is %d\n",
|
---|
81 | rate);
|
---|
82 |
|
---|
83 | /*
|
---|
84 | * Cleanup.
|
---|
85 | */
|
---|
86 | ret = RTFileClose(File);
|
---|
87 | if (RT_FAILURE(ret))
|
---|
88 | {
|
---|
89 | printf("Failed to close /dev/dsp. ret=%d\n", ret);
|
---|
90 | rcRet++;
|
---|
91 | }
|
---|
92 |
|
---|
93 | /* Under Linux and L4, this involves ioctls internally */
|
---|
94 | RTUUID TestUuid;
|
---|
95 | if (RT_FAILURE(RTUuidCreate(&TestUuid)))
|
---|
96 | {
|
---|
97 | printf("Failed to create a UUID. ret=%d\n", ret);
|
---|
98 | rcRet++;
|
---|
99 | }
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * Summary
|
---|
103 | */
|
---|
104 | if (rcRet == 0)
|
---|
105 | printf("tstIoCtl: SUCCESS\n");
|
---|
106 | else
|
---|
107 | printf("tstIoCtl: FAILURE - %d errors\n", rcRet);
|
---|
108 | return rcRet;
|
---|
109 | }
|
---|