BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / tv / DeviceRoster.cpp
blobd2fd4da56a2843657d270dc7f650196225311cec
1 /*
2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de>
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify,
8 * merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "DeviceRoster.h"
27 #include <stdio.h>
28 #include <string.h>
29 #include <Debug.h>
32 DeviceRoster *gDeviceRoster;
36 DeviceRoster::DeviceRoster()
38 live_node_info info[MAX_DEVICE_COUNT];
39 int32 info_count = MAX_DEVICE_COUNT;
40 status_t err;
41 err = MediaRoster()->GetLiveNodes(info, &info_count, NULL, NULL, "DVB*",
42 B_BUFFER_PRODUCER | B_PHYSICAL_INPUT);
43 if (err != B_OK || info_count < 1) {
44 printf("Can't find live DVB node. Found %" B_PRId32 " nodes, error %08" B_PRIx32 " (%s)\n",
45 info_count, err, strerror(err));
46 fDeviceCount = 0;
47 } else {
48 fDeviceCount = info_count;
49 for (int i = 0; i < fDeviceCount; i++) {
50 fDeviceInfo[i].node = info[i].node;
51 strcpy(fDeviceInfo[i].name, info[i].name);
57 DeviceRoster::~DeviceRoster()
62 int
63 DeviceRoster::DeviceCount()
65 return fDeviceCount;
69 const char *
70 DeviceRoster::DeviceName(int i)
72 ASSERT(i >= 0 && i < fDeviceCount);
73 return fDeviceInfo[i].name;
77 media_node
78 DeviceRoster::DeviceNode(int i)
80 ASSERT(i >= 0 && i < fDeviceCount);
81 return fDeviceInfo[i].node;
85 bool
86 DeviceRoster::IsRawAudioOutputFree(int i)
88 ASSERT(i >= 0 && i < fDeviceCount);
90 media_output output;
91 int32 count;
92 status_t err;
94 err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
95 &count, B_MEDIA_RAW_AUDIO);
96 return (err == B_OK) && (count == 1);
100 bool
101 DeviceRoster::IsEncAudioOutputFree(int i)
103 ASSERT(i >= 0 && i < fDeviceCount);
105 media_output output;
106 int32 count;
107 status_t err;
109 err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
110 &count, B_MEDIA_ENCODED_AUDIO);
111 return (err == B_OK) && (count == 1);
115 bool
116 DeviceRoster::IsRawVideoOutputFree(int i)
118 ASSERT(i >= 0 && i < fDeviceCount);
120 media_output output;
121 int32 count;
122 status_t err;
124 err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
125 &count, B_MEDIA_RAW_VIDEO);
126 return (err == B_OK) && (count == 1);
130 bool
131 DeviceRoster::IsEncVideoOutputFree(int i)
133 ASSERT(i >= 0 && i < fDeviceCount);
135 media_output output;
136 int32 count;
137 status_t err;
139 err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
140 &count, B_MEDIA_ENCODED_VIDEO);
141 return (err == B_OK) && (count == 1);
145 BMediaRoster *
146 DeviceRoster::MediaRoster()
148 return BMediaRoster::Roster();